VUnit的仿真时间非常慢
我正在使用VUnit和 Questasim运行examples/vhdl/uart的仿真。test_tvalid_low_at_start 的测试大约在12秒内完成,但 test_receives_one_byte 已经运行超过45分钟仍未完成。
我也尝试了我自己的UART仿真。若是我不检查接收到的数据,它会很快完成;但在主进程中加入任何数据检查都会大幅降低速度。
设置:
- 以115200波特率发送8 字节
uart_rx_fifo以20 MHz时钟运行tx_bytes是一个8 字节的数组
如果我从主模块移除这一行:wait until rx_count = tx_bytes'length;,仿真会很快完成。否则,就会一直拖延。示例片段:
capture_rx: process(uart_tx_fifo_wr)
begin
if rising_edge(uart_tx_fifo_wr) then
rx_log(rx_count) <= uart_rx_fifo_rdata;
rx_count <= rx_count + 1;
report "Received byte: " & to_hstring(uart_rx_fifo_rdata);
end if;
end process;
main : process
variable rx_index : integer := 0;
begin
test_runner_setup(runner, runner_cfg);
if run("uart_loopback_test") then
wait until gsr = '0';
wait for 100 ns;
-- Send bytes
for i in tx_bytes'range loop
uart_send_byte(tx, tx_bytes(i));
end loop;
-- Wait for all bytes to be captured
wait until rx_count = tx_bytes'length;
-- Verify correctness
for i in 0 to tx_bytes'length-1 loop
if rx_log(i) /= tx_bytes(i) then
report "Mismatch at index " & integer'image(i)
severity error;
end if;
end loop;
info("All UART bytes correctly received.");
end if;
test_runner_cleanup(runner);
wait;
end process;
问题:
这种长时间的仿真时间正常吗,还是与我的设置/电脑有关?我想使用VUnit进行自动数据检查,而不是手动检查波形,但慢速仿真让它变得不可行。有什么建议可以加速吗?
解决方案
如评论中所述,问题由以下这条语句引起:
wait until rx_count = tx_bytes'length;
在VHDL中,wait until 语句只有在信号发生 变化、且条件变为真时才会继续执行。此时,rx_count 已经在进程执行 wait 语句之前达到 tx_bytes'length,而在此之后对 rx_count 没有再发生变化,进程因此从未被唤醒,一直在等待。
解决方法是在等待之前就检查条件:
if rx_count /= tx_bytes'length then
wait until rx_count = tx_bytes'length;
end if;
这可以避免在条件已满足时继续等待,并防止错过事件。
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。