ucb-bar / chiseltest

The batteries-included testing and formal verification library for Chisel-based RTL designs.
Other
221 stars 74 forks source link

No Reset Signal for DUT in Chisel Formal #563

Closed B10615053 closed 1 year ago

B10615053 commented 1 year ago

I tried to verify following Register File with Chisel Formal, and I got an assertion failed.

[RFFormal] found an assertion violation 0 steps after reset!
Assertion failed: RS2 Index:   2, Data Expected: 0x00000001, Data Actual: 0x80000000

To solve this problem, I dumped the waveform file, and found out the DUT didn't seem to be Reset. If the DUT had been Reset, the io_dataRS2 should be 0 instead of 8000_0000. image I also found the register in the RFFormal was not been Reset. image My running environment are listed below:

My Chisel code are listed as following:

ekiwi commented 1 year ago

Memories are not reset by default since that is the behavior you would expect on an ASIC. Thus your two memories will start out with potentially different data and thus your check fails. You can initialize both memories to zero through a firrtl annotation: https://github.com/ucb-bar/chiseltest/blob/0894e8fba74674bcd32e7070211b40eb5be1b20b/src/test/scala/chiseltest/formal/MemoryTests.scala#L179

Please let me know if this fixes your issue.

B10615053 commented 1 year ago

Hi @ekiwi , I appreciate your reply. Add the following code indeed solve the Reset problem.

// Initial with all zeros
annotate(new ChiselAnnotation {
        override def toFirrtl = MemoryScalarInitAnnotation(rf.toTarget, 0)
})

But I was facing another issue of dumping waveform with following command.

testOnly cpu.RFTest -- -DwriteVcd=1

Why won't this generate vcd waveform file under test_run_dir direcotry? Will Seq(BoundedCheck(6)) generate a cover waveform of 6 cycle clock? Thank you again for the help!:smile:

ekiwi commented 1 year ago

Why won't this generate vcd waveform file under test_run_dir direcotry?

The formal verify command only generates a VCD if it find an assertion violation. No flag needed in that case.

Will Seq(BoundedCheck(6)) generate a cover waveform of 6 cycle clock?

Unfortunately cover trace generation is not implemented yet :(. Haven't had time to work on that.