Skip to content

Commit

Permalink
modified verilator tb to be more aligned with usual UVM practises, ad…
Browse files Browse the repository at this point in the history
…ded a function similar to check Phase
  • Loading branch information
npatsiatzis committed Aug 27, 2023
1 parent be56256 commit 845835e
Showing 1 changed file with 62 additions and 25 deletions.
87 changes: 62 additions & 25 deletions verilator_sim/tb_async_fifo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class OutCoverage {
class Scb {
private:
std::deque<InTx*> in_q;
std::deque<OutTx*> out_q;

public:
// Input interface monitor port
Expand All @@ -92,35 +93,69 @@ class Scb {
}

// Output interface monitor port
void writeOut(OutTx* tx){
// We should never get any data from the output interface
// before an input gets driven to the input interface
if(in_q.empty()){
std::cout <<"Fatal Error in AluScb: empty InTx queue" << std::endl;
exit(1);
}
void writeOut(OutTx *tx){
// Push the received transaction item into a queue for later
out_q.push_back(tx);
}

// Grab the transaction item from the front of the input item queue
InTx* in;
in = in_q.front();
in_q.pop_front();
void checkPhase(){
while(out_q.empty() == 0){
InTx* in;
in = in_q.front();
in_q.pop_front();

OutTx* out;
out = out_q.front();
out_q.pop_front();

if(in->i_data_w != out->o_data){
std::cout << "Test Failure!" << std::endl;
std::cout << "Expected : " << in->i_data_w << std::endl;
std::cout << "Got : " << out->o_data << std::endl;
exit(1);
} else {
std::cout << "Test PASS!" << std::endl;
std::cout << "Expected : " << in->i_data_w << std::endl;
std::cout << "Got : " << out->o_data << std::endl;
}

if(in->i_data_w != tx->o_data){
std::cout << "Test Failure!" << std::endl;
std::cout << "Expected : " << in->i_data_w << std::endl;
std::cout << "Got : " << tx->o_data << std::endl;
exit(1);
} else {
std::cout << "Test PASS!" << std::endl;
std::cout << "Expected : " << in->i_data_w << std::endl;
std::cout << "Got : " << tx->o_data << std::endl;
// As the transaction items were allocated on the heap, it's important
// to free the memory after they have been used
delete in; //input monitor transaction
delete out; //output monitor transaction
}

// As the transaction items were allocated on the heap, it's important
// to free the memory after they have been used
delete in; //input monitor transaction
delete tx; //output monitor transaction
}

// // Output interface monitor port
// void writeOut(OutTx* tx){
// // We should never get any data from the output interface
// // before an input gets driven to the input interface
// if(in_q.empty()){
// std::cout <<"Fatal Error in AluScb: empty InTx queue" << std::endl;
// exit(1);
// }

// // Grab the transaction item from the front of the input item queue
// InTx* in;
// in = in_q.front();
// in_q.pop_front();

// if(in->i_data_w != tx->o_data){
// std::cout << "Test Failure!" << std::endl;
// std::cout << "Expected : " << in->i_data_w << std::endl;
// std::cout << "Got : " << tx->o_data << std::endl;
// exit(1);
// } else {
// std::cout << "Test PASS!" << std::endl;
// std::cout << "Expected : " << in->i_data_w << std::endl;
// std::cout << "Got : " << tx->o_data << std::endl;
// }

// // As the transaction items were allocated on the heap, it's important
// // to free the memory after they have been used
// delete in; //input monitor transaction
// delete tx; //output monitor transaction
// }
};

// interface driver
Expand Down Expand Up @@ -384,6 +419,8 @@ int main(int argc, char** argv, char** env) {
sim_time++;
}


scb->checkPhase();
m_trace->close();
exit(EXIT_SUCCESS);
}

0 comments on commit 845835e

Please sign in to comment.