YosysHQ / picorv32

PicoRV32 - A Size-Optimized RISC-V CPU
ISC License
3.15k stars 759 forks source link

Incorrect simulation of always block with commercial simulators #135

Closed chiraag closed 5 years ago

chiraag commented 5 years ago

The following always block has incorrect simulation behavior in some commercial simulators.

https://github.com/cliffordwolf/picorv32/blob/881f928e05dca9f1e750ff68793e5cc7653d7ccd/testbench.v#L83-L87

The issue is related to irq being undefined till reset, since no signal in the sensitivity list toggles till then. The resulting x-propagation causes downstream issues with some firmware including the test firmware in the firmware directory.

A simple fix is to rewrite the always block as follows:

wire [31:0] irq = {26'h0, &count_cycle[15:0], &count_cycle[12:0], 4'h0};
cliffordwolf commented 5 years ago

I think 3f9b504 should fix the issue. Please verify.

chiraag commented 5 years ago

This fixes the issue.