cores
cores copied to clipboard
uart/testbench does not work
For me uart_cfg_div does not get set:

Moreover above vardump diverges from what $display outputs:
rst_i = 0, write_en_w = 0, addr_i = 0, data_i = 15
rst_i = 0, write_en_w = 1, addr_i = 0, data_i = 0
In last output write_en_w becomes 1 only after data_i is already zero.
How can it be possible?
According to discussion in https://github.com/steveicarus/iverilog/issues/223 seems that it is better not to use zero delay inertial updates from VPI for clock synchronized data. It is because Icarus is free to choose between this update and other already pending events.
In this concrete testbench what happens is:
sc_vpi_module::value_changeis called fortb_top.clk_i.- From SystemC code change of
stb_i,we_i,data_iis scheduled with zero inertial delay. - Icarus processes change of
stb_i,we_i,data_iand schedules change ofwrite_en_wdue toassign write_en_w = stb_i & we_i & ~ack_o. - Icarus processes
always @ (posedge clk_i or posedge rst_i)because ofclk_ichange before. This is how it ends up thatstb_iandwe_iare updated butwrite_en_wis still zero.
Together with using non-zero inertial delay it makes sense in uart_wb_vpi to subscribe only to clock change because everything should be syncrhonized to it.