Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions tests/benches/tx_frontend/tb_tx_frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ class TB_Tx_frontend : public Testbench<Vtb_tx_frontend> {
}

float get_generated_baudrate(uint32_t baudrate) {
this->reset();
this->_nop();

this->core->rst_i = 1;
for(int i = 0; i < 5; i++) {
this->tick();
}
this->core->rst_i = 0;

core->cr_acc_incr_i = ((double)baudrate * (1 << 16)) / 24000000;
core->cr_acc_incr_i = ((double)baudrate * (1 << 16)) / 60000000;
core->cr_ds_i = 1;
core->cr_p_i = 1;
core->cr_s_i = 1;
Expand All @@ -115,7 +121,7 @@ class TB_Tx_frontend : public Testbench<Vtb_tx_frontend> {
}

// Compute the baudrate
float duration = (counter / 24000000.0);
float duration = (counter / 60000000.0);
float baud_period = duration / 12;
float generated_baudrate = (1.0 / baud_period);
return generated_baudrate;
Expand Down Expand Up @@ -2777,10 +2783,20 @@ void tb_tx_frontend_baudrate(TB_Tx_frontend * tb) {
float generated_baudrate = tb->get_generated_baudrate(baudrates[i]);
float precision = (1.0 - (generated_baudrate / baudrates[i]));

if(tb->debug_log) {
printf("Baudrate: %d, acc: %d, precision: %f -> ", baudrates[i], core->cr_acc_incr_i, precision);

if(precision >= 0.02) {
printf("BAD\n");
} else {
printf("OK\n");
}
}

//`````````````````````````````````
// Checks

tb->check(COND_baudrate, (precision < 0.01));
tb->check(COND_baudrate, (precision < 0.02));
}

//`````````````````````````````````
Expand All @@ -2803,8 +2819,8 @@ int main(int argc, char ** argv, char ** env) {
tb->set_debug_log(verbose);
tb->init_conditions(__CondIdEnd);

// 24MHz
tb->clk_period_in_ps = 41667;
// 60MHz
tb->clk_period_in_ps = 16667;

/************************************************************/

Expand Down
Loading