separated tests
This commit is contained in:
2
hw/unit_tests/cache/cachesim.cpp
vendored
2
hw/unit_tests/cache/cachesim.cpp
vendored
@@ -254,12 +254,14 @@ void CacheSim::get_core_rsp(unsigned int (&rsp)[4]){
|
|||||||
rsp[1] = cache_->core_rsp_data[1];
|
rsp[1] = cache_->core_rsp_data[1];
|
||||||
rsp[2] = cache_->core_rsp_data[2];
|
rsp[2] = cache_->core_rsp_data[2];
|
||||||
rsp[3] = cache_->core_rsp_data[3];
|
rsp[3] = cache_->core_rsp_data[3];
|
||||||
|
|
||||||
//std::cout << std::hex << "core_rsp_valid: " << cache_->core_rsp_valid << std::endl;
|
//std::cout << std::hex << "core_rsp_valid: " << cache_->core_rsp_valid << std::endl;
|
||||||
//std::cout << std::hex << "core_rsp_data: " << cache_->core_rsp_data << std::endl;
|
//std::cout << std::hex << "core_rsp_data: " << cache_->core_rsp_data << std::endl;
|
||||||
//std::cout << std::hex << "core_rsp_tag: " << cache_->core_rsp_tag << std::endl;
|
//std::cout << std::hex << "core_rsp_tag: " << cache_->core_rsp_tag << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CacheSim::get_core_req(){
|
void CacheSim::get_core_req(){
|
||||||
|
std::cout << cache_->genblk5_BRA_0_KET_->bank->is_fill_in_pipe<< std::endl;
|
||||||
char check = cache_->core_req_valid;
|
char check = cache_->core_req_valid;
|
||||||
std::cout << std::hex << "core_req_valid: " << check << std::endl;
|
std::cout << std::hex << "core_req_valid: " << check << std::endl;
|
||||||
std::cout << std::hex << "core_req_data[0]: " << cache_->core_req_data[0] << std::endl;
|
std::cout << std::hex << "core_req_data[0]: " << cache_->core_req_data[0] << std::endl;
|
||||||
|
|||||||
1
hw/unit_tests/cache/cachesim.h
vendored
1
hw/unit_tests/cache/cachesim.h
vendored
@@ -52,6 +52,7 @@ public:
|
|||||||
void clear_req();
|
void clear_req();
|
||||||
void send_req(core_req_t *req);
|
void send_req(core_req_t *req);
|
||||||
bool assert_equal(unsigned int* data, unsigned int tag);
|
bool assert_equal(unsigned int* data, unsigned int tag);
|
||||||
|
//void time_analyisis
|
||||||
|
|
||||||
//display funcs
|
//display funcs
|
||||||
|
|
||||||
|
|||||||
116
hw/unit_tests/cache/testbench.cpp
vendored
116
hw/unit_tests/cache/testbench.cpp
vendored
@@ -6,7 +6,7 @@
|
|||||||
#define VCD_OUTPUT 1
|
#define VCD_OUTPUT 1
|
||||||
|
|
||||||
|
|
||||||
int REQ_RSP(CacheSim *sim){
|
int REQ_RSP(CacheSim *sim){ //verified
|
||||||
unsigned int addr[4] = {0x12222222, 0xabbbbbbb, 0xcddddddd, 0xe4444444};
|
unsigned int addr[4] = {0x12222222, 0xabbbbbbb, 0xcddddddd, 0xe4444444};
|
||||||
unsigned int data[4] = {0xffffffff, 0x11111111, 0x22222222, 0x33333333};
|
unsigned int data[4] = {0xffffffff, 0x11111111, 0x22222222, 0x33333333};
|
||||||
unsigned int rsp[4] = {0,0,0,0};
|
unsigned int rsp[4] = {0,0,0,0};
|
||||||
@@ -43,6 +43,117 @@ int REQ_RSP(CacheSim *sim){
|
|||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int HIT_1(CacheSim *sim){
|
||||||
|
unsigned int addr[4] = {0x12222222, 0xabbbbbbb, 0xcddddddd, 0xe4444444};
|
||||||
|
unsigned int data[4] = {0xffffffff, 0x11111111, 0x22222222, 0x33333333};
|
||||||
|
unsigned int rsp[4] = {0,0,0,0};
|
||||||
|
char responded = 0;
|
||||||
|
//write req
|
||||||
|
core_req_t* write = new core_req_t;
|
||||||
|
write->valid = 0xf;
|
||||||
|
write->rw = 0xf;
|
||||||
|
write->byteen = 0xffff;
|
||||||
|
write->addr = addr;
|
||||||
|
write->data = data;
|
||||||
|
write->tag = 0x11;
|
||||||
|
|
||||||
|
//read req
|
||||||
|
core_req_t* read = new core_req_t;
|
||||||
|
read->valid = 0xf;
|
||||||
|
read->rw = 0;
|
||||||
|
read->byteen = 0xffff;
|
||||||
|
read->addr = addr;
|
||||||
|
read->data = addr;
|
||||||
|
read->tag = 0x22;
|
||||||
|
|
||||||
|
// reset the device
|
||||||
|
sim->reset();
|
||||||
|
|
||||||
|
//queue reqs
|
||||||
|
sim->send_req(write);
|
||||||
|
sim->send_req(read);
|
||||||
|
|
||||||
|
sim->run();
|
||||||
|
|
||||||
|
bool check = sim->assert_equal(data, write->tag);
|
||||||
|
|
||||||
|
return check;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MISS_1(CacheSim *sim){
|
||||||
|
unsigned int addr[4] = {0x12222222, 0xabbbbbbb, 0xcddddddd, 0xe4444444};
|
||||||
|
unsigned int data[4] = {0xffffffff, 0x11111111, 0x22222222, 0x33333333};
|
||||||
|
unsigned int rsp[4] = {0,0,0,0};
|
||||||
|
char responded = 0;
|
||||||
|
//write req
|
||||||
|
core_req_t* write = new core_req_t;
|
||||||
|
write->valid = 0xf;
|
||||||
|
write->rw = 0xf;
|
||||||
|
write->byteen = 0xffff;
|
||||||
|
write->addr = addr;
|
||||||
|
write->data = data;
|
||||||
|
write->tag = 0xff;
|
||||||
|
|
||||||
|
//read req
|
||||||
|
core_req_t* read = new core_req_t;
|
||||||
|
read->valid = 0xf;
|
||||||
|
read->rw = 0;
|
||||||
|
read->byteen = 0xffff;
|
||||||
|
read->addr = addr;
|
||||||
|
read->data = addr;
|
||||||
|
read->tag = 0xff;
|
||||||
|
|
||||||
|
// reset the device
|
||||||
|
sim->reset();
|
||||||
|
|
||||||
|
//queue reqs
|
||||||
|
sim->send_req(write);
|
||||||
|
sim->send_req(read);
|
||||||
|
|
||||||
|
sim->run();
|
||||||
|
|
||||||
|
bool check = sim->assert_equal(data, write->tag);
|
||||||
|
|
||||||
|
return check;
|
||||||
|
}
|
||||||
|
int FLUSH(CacheSim *sim){
|
||||||
|
unsigned int addr[4] = {0x12222222, 0xabbbbbbb, 0xcddddddd, 0xe4444444};
|
||||||
|
unsigned int data[4] = {0xffffffff, 0x11111111, 0x22222222, 0x33333333};
|
||||||
|
unsigned int rsp[4] = {0,0,0,0};
|
||||||
|
char responded = 0;
|
||||||
|
//write req
|
||||||
|
core_req_t* write = new core_req_t;
|
||||||
|
write->valid = 0xf;
|
||||||
|
write->rw = 0xf;
|
||||||
|
write->byteen = 0xffff;
|
||||||
|
write->addr = addr;
|
||||||
|
write->data = data;
|
||||||
|
write->tag = 0xff;
|
||||||
|
|
||||||
|
//read req
|
||||||
|
core_req_t* read = new core_req_t;
|
||||||
|
read->valid = 0xf;
|
||||||
|
read->rw = 0;
|
||||||
|
read->byteen = 0xffff;
|
||||||
|
read->addr = addr;
|
||||||
|
read->data = addr;
|
||||||
|
read->tag = 0xff;
|
||||||
|
|
||||||
|
// reset the device
|
||||||
|
sim->reset();
|
||||||
|
|
||||||
|
//queue reqs
|
||||||
|
sim->send_req(write);
|
||||||
|
sim->send_req(read);
|
||||||
|
|
||||||
|
sim->run();
|
||||||
|
|
||||||
|
bool check = sim->assert_equal(data, write->tag);
|
||||||
|
|
||||||
|
return check;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int BACK_PRESSURE(CacheSim *sim){
|
int BACK_PRESSURE(CacheSim *sim){
|
||||||
unsigned int addr[4] = {0x12222222, 0xabbbbbbb, 0xcddddddd, 0xe4444444};
|
unsigned int addr[4] = {0x12222222, 0xabbbbbbb, 0xcddddddd, 0xe4444444};
|
||||||
unsigned int data[4] = {0xffffffff, 0x11111111, 0x22222222, 0x33333333};
|
unsigned int data[4] = {0xffffffff, 0x11111111, 0x22222222, 0x33333333};
|
||||||
@@ -83,13 +194,14 @@ int BACK_PRESSURE(CacheSim *sim){
|
|||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
//init
|
//init
|
||||||
RAM ram;
|
RAM ram;
|
||||||
CacheSim cachesim;
|
CacheSim cachesim;
|
||||||
cachesim.attach_ram(&ram);
|
cachesim.attach_ram(&ram);
|
||||||
int check = REQ_RSP(&cachesim);
|
int check = HIT_1(&cachesim);
|
||||||
if(check){
|
if(check){
|
||||||
std::cout << "PASSED" << std::endl;
|
std::cout << "PASSED" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user