aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAlbert Magyar2019-09-12 17:06:01 -0700
committerAlbert Magyar2019-09-30 16:22:01 -0700
commit082bc994457cc5f6780b58fb914a6ab3eb8a021f (patch)
treec0998198ebc9036308754826ffb863e43259f3fa /src/test
parent01399dd00ba18b1e4d5c1f773ca33f077c53c534 (diff)
Implement read-first memories in VerilogMemDelays
* Corrects behavior under write collisions * Avoids heavily refactoring pass
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/firrtlTests/VerilogMemDelaySpec.scala49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/VerilogMemDelaySpec.scala b/src/test/scala/firrtlTests/VerilogMemDelaySpec.scala
index 405f5ab5..e7f27d0e 100644
--- a/src/test/scala/firrtlTests/VerilogMemDelaySpec.scala
+++ b/src/test/scala/firrtlTests/VerilogMemDelaySpec.scala
@@ -49,4 +49,53 @@ class VerilogMemDelaySpec extends FreeSpec with Matchers {
CheckHighForm.run(result2)
//result.circuit.serialize.length > 0 should be (true)
}
+
+ "Using a read-first memory should be allowed in VerilogMemDelays" in {
+ val input =
+ """
+ |circuit Test :
+ | module Test :
+ | input clock : Clock
+ | input waddr : UInt<5>
+ | input wdata : UInt<32>
+ | input raddr : UInt<5>
+ | input rw_wen : UInt<1>
+ | output rdata : UInt<32>
+ | output rw_rdata : UInt<32>
+ | mem m :
+ | data-type => UInt<32>
+ | depth => 32
+ | read-latency => 1
+ | write-latency => 1
+ | read-under-write => old
+ | reader => read
+ | writer => write
+ | readwriter => rw
+ | m.read.clk <= clock
+ | m.read.en <= UInt<1>(1)
+ | m.read.addr <= raddr
+ | rdata <= m.read.data
+ |
+ | m.write.clk <= clock
+ | m.write.en <= UInt<1>(1)
+ | m.write.mask <= UInt<1>(1)
+ | m.write.addr <= waddr
+ | m.write.data <= wdata
+ |
+ | m.rw.clk <= clock
+ | m.rw.en <= UInt<1>(1)
+ | m.rw.wmode <= rw_wen
+ | m.rw.wmask <= UInt<1>(1)
+ | m.rw.addr <= waddr
+ | m.rw.wdata <= wdata
+ | rw_rdata <= m.rw.rdata
+ """.stripMargin
+
+ val circuit = Parser.parse(input)
+ val compiler = new LowFirrtlCompiler
+
+ val result = compiler.compile(CircuitState(circuit, ChirrtlForm), Seq.empty)
+ val result2 = VerilogMemDelays.run(result.circuit)
+ CheckHighForm.run(result2)
+ }
}