1 from nmigen
import Elaboratable
, Cat
, Module
, Signal
, ClockSignal
, Instance
2 from nmigen
.cli
import rtlil
5 class ADD(Elaboratable
):
6 def __init__(self
, width
):
10 self
.f
= Signal(width
)
12 def elaborate(self
, platform
):
14 result
= Signal
.like(self
.f
)
15 m
.d
.sync
+= result
.eq(self
.a
+ self
.b
)
19 q
= Signal(64) # output
20 d
= Signal(64) # input
21 sram
= Instance("SPBlock_512W64B8W", i_a
=a
, o_q
=q
, i_d
=d
,
22 i_we
=self
.we
, i_clk
=ClockSignal())
25 # connect up some arbitrary signals
26 m
.d
.comb
+= a
.eq(Cat(self
.a
, self
.b
, self
.a
[0]))
27 m
.d
.comb
+= d
.eq(result
)
28 m
.d
.comb
+= self
.f
.eq(q
)
33 def create_ilang(dut
, ports
, test_name
):
34 vl
= rtlil
.convert(dut
, name
=test_name
, ports
=ports
)
35 with
open("%s.il" % test_name
, "w") as f
:
38 if __name__
== "__main__":
40 create_ilang(alu
, [alu
.a
, alu
.b
, alu
.f
, alu
.we
], "memory")