simplify experiment4 to an adder, similar to adder benchmark
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 24 Feb 2020 17:44:20 +0000 (17:44 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 24 Feb 2020 17:44:20 +0000 (17:44 +0000)
experiments4/Makefile
experiments4/add.py [new file with mode: 0644]
experiments4/alu_hier.py [deleted file]
experiments4/nets.txt

index effb92a094b220bc4dd7ea420bfc0f985b9e40a1..8addfb50fe2dd275b038d142d808a9464debe835 100755 (executable)
@@ -6,7 +6,7 @@
 
            YOSYS_FLATTEN = Yes
                      CHIP = chip
-                     CORE = alu_hier
+                     CORE = add
                    MARGIN = 5
                   BOOMOPT = -A
                   BOOGOPT =
             USE_CLOCKTREE = Yes
                 USE_DEBUG = No
                  USE_KITE = No
-                 RM_CHIP = Yes
+#                 RM_CHIP = Yes
 
                  NETLISTS = $(shell cat nets.txt)
-                 PATTERNS = alu_hier_r
+                 PATTERNS = add_r
 
 
  include ./mk/design-flow.mk
 
 
-#blif:      alu_hier.blif
-#vst:       alu_hier.vst
+blif:      add.blif
+vst:       add.vst
 dreal:      dreal-chip_cts_r
 flatph:     flatph-chip_cts_r
 layout:    chip_cts_r.ap
@@ -34,4 +34,4 @@ gds:       chip_cts_r.gds
 lvx:       lvx-chip_cts_r
 druc:      druc-chip_cts_r
 view:      cgt-chip_cts_r
-sim:       asimut-alu_hier_cts_r
+sim:       asimut-add_cts_r
diff --git a/experiments4/add.py b/experiments4/add.py
new file mode 100644 (file)
index 0000000..83e7a72
--- /dev/null
@@ -0,0 +1,24 @@
+from nmigen import *
+from nmigen.cli import rtlil
+
+
+class ADD(Elaboratable):
+    def __init__(self, width):
+        self.a   = Signal(width)
+        self.b   = Signal(width)
+        self.o   = Signal(width)
+
+    def elaborate(self, platform):
+        m = Module()
+        m.d.comb += self.eq(self.a + self.b)
+        return m
+
+
+def create_ilang(dut, ports, test_name):
+    vl = rtlil.convert(dut, name=test_name, ports=ports)
+    with open("%s.il" % test_name, "w") as f:
+        f.write(vl)
+
+if __name__ == "__main__":
+    alu = ADD(width=4)
+    create_ilang(alu, [alu.a, alu.b, alu.o], "add")
diff --git a/experiments4/alu_hier.py b/experiments4/alu_hier.py
deleted file mode 100644 (file)
index b42fb1d..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-from nmigen import *
-from nmigen.cli import rtlil
-
-
-class Adder(Elaboratable):
-    def __init__(self, width):
-        self.a   = Signal(width)
-        self.b   = Signal(width)
-        self.o   = Signal(width)
-
-    def elaborate(self, platform):
-        m = Module()
-        m.d.comb += self.o.eq(self.a + self.b)
-        return m
-
-
-class Subtractor(Elaboratable):
-    def __init__(self, width):
-        self.a   = Signal(width)
-        self.b   = Signal(width)
-        self.o   = Signal(width)
-
-    def elaborate(self, platform):
-        m = Module()
-        m.d.comb += self.o.eq(self.a - self.b)
-        return m
-
-
-class ALU(Elaboratable):
-    def __init__(self, width):
-        self.op  = Signal()
-        self.a   = Signal(width)
-        self.b   = Signal(width)
-        self.o   = Signal(width)
-
-        self.add = Adder(width)
-        self.sub = Subtractor(width)
-
-    def elaborate(self, platform):
-
-        m = Module()
-        #m.domains.sync = ClockDomain()
-        #m.d.comb += ClockSignal().eq(self.m_clock)
-
-        m.submodules.add = self.add
-        m.submodules.sub = self.sub
-        m.d.comb += [
-            self.add.a.eq(self.a),
-            self.sub.a.eq(self.a),
-            self.add.b.eq(self.b),
-            self.sub.b.eq(self.b),
-        ]
-        with m.If(self.op):
-            m.d.sync += self.o.eq(self.sub.o)
-        with m.Else():
-            m.d.sync += self.o.eq(self.add.o)
-        return m
-
-
-def create_ilang(dut, ports, test_name):
-    vl = rtlil.convert(dut, name=test_name, ports=ports)
-    with open("%s.il" % test_name, "w") as f:
-        f.write(vl)
-
-if __name__ == "__main__":
-    alu = ALU(width=16)
-    create_ilang(alu, [#alu.m_clock, alu.p_reset,
-                       alu.op, alu.a, alu.b, alu.o], "alu_hier")
index 320e40386813afe5d233647376211a738a760ddb..76d4bb83f8dab3933a481bd2d65fbcc1283ef9b7 100644 (file)
@@ -1 +1 @@
-alu_hier add sub
+add