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