add SRlatch async mode
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 5 May 2019 13:40:47 +0000 (14:40 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 5 May 2019 13:40:47 +0000 (14:40 +0100)
src/nmutil/latch.py
src/scoreboard/int_fn_unit.py

index dbdb23e55b76e660cec8a2c2b7ec80393147da7f..41a8df9442920e67336fd9a35604ae64442ec008 100644 (file)
@@ -4,7 +4,8 @@ from nmigen import Signal, Module, Elaboratable
 
 
 class SRLatch(Elaboratable):
 
 
 class SRLatch(Elaboratable):
-    def __init__(self):
+    def __init__(self, sync=True):
+        self.sync = sync
         self.s = Signal(reset_less=True)
         self.r = Signal(reset_less=True)
         self.q = Signal(reset_less=True)
         self.s = Signal(reset_less=True)
         self.r = Signal(reset_less=True)
         self.q = Signal(reset_less=True)
@@ -14,13 +15,25 @@ class SRLatch(Elaboratable):
         m = Module()
         q_int = Signal(reset_less=True)
 
         m = Module()
         q_int = Signal(reset_less=True)
 
-        with m.If(self.s):
-            m.d.sync += q_int.eq(1)
-        with m.Elif(self.r):
-            m.d.sync += q_int.eq(0)
-
-        m.d.comb += self.q.eq(q_int)
-        m.d.comb += self.qn.eq(~q_int)
+        if self.sync:
+            with m.If(self.s):
+                m.d.sync += q_int.eq(1)
+            with m.Elif(self.r):
+                m.d.sync += q_int.eq(0)
+            m.d.comb += self.q.eq(q_int)
+            m.d.comb += self.qn.eq(~q_int)
+        else:
+            with m.If(self.s):
+                m.d.sync += q_int.eq(1)
+                m.d.comb += self.q.eq(1)
+                m.d.comb += self.qn.eq(0)
+            with m.Elif(self.r):
+                m.d.sync += q_int.eq(0)
+                m.d.comb += self.q.eq(0)
+                m.d.comb += self.qn.eq(1)
+            with m.Else():
+                m.d.comb += self.q.eq(q_int)
+                m.d.comb += self.qn.eq(~q_int)
 
         return m
 
 
         return m
 
index 93f95be3d4313c5910925c7d21088af6f9b4caea..ca8bc1a28ad44447ad09c31614cd5f397569fed7 100644 (file)
@@ -38,8 +38,8 @@ class IntFnUnit(Elaboratable):
 
     def elaborate(self, platform):
         m = Module()
 
     def elaborate(self, platform):
         m = Module()
-        m.submodules.rd_l = rd_l = SRLatch()
-        m.submodules.wr_l = wr_l = SRLatch()
+        m.submodules.rd_l = rd_l = SRLatch(sync=False)
+        m.submodules.wr_l = wr_l = SRLatch(sync=False)
         m.submodules.dest_d = dest_d = Decoder(self.reg_width)
         m.submodules.src1_d = src1_d = Decoder(self.reg_width)
         m.submodules.src2_d = src2_d = Decoder(self.reg_width)
         m.submodules.dest_d = dest_d = Decoder(self.reg_width)
         m.submodules.src1_d = src1_d = Decoder(self.reg_width)
         m.submodules.src2_d = src2_d = Decoder(self.reg_width)