1 from nmigen
.compat
.sim
import run_simulation
2 from nmigen
.cli
import verilog
, rtlil
3 from nmigen
import Module
, Signal
, Mux
, Elaboratable
, Array
4 from nmutil
.iocontrol
import RecordObject
6 from nmutil
.latch
import SRLatch
, latchregister
7 from soc
.decoder
.power_decoder2
import Data
8 from soc
.decoder
.power_enums
import InternalOp
10 from soc
.experiment
.compldst
import CompLDSTOpSubset
11 from soc
.decoder
.power_decode2
import Data
14 class PortInterface(RecordObject
):
16 def __init__(self
, name
=None):
18 RecordObject
.__init
__(self
, name
=name
)
20 # distinguish op type (ld/st)
21 self
.is_ld_i
= Signal(reset_less
=True)
22 self
.is_st_i
= Signal(reset_less
=True)
23 self
.op
= CompLDSTOpSubset() # hm insn_type ld/st duplicates here
26 self
.busy_o
= Signal(reset_less
=True) # do not use if busy
27 self
.go_die_i
= Signal(reset_less
=True) # back to reset
28 self
.addr
= Data(48, "addr_i") # addr/addr-ok
29 self
.addr_ok_o
= Signal(reset_less
=True) # addr is valid (TLB, L1 etc.)
30 self
.addr_exc_o
= Signal(reset_less
=True) # TODO, "type" of exception
33 self
.ld
= Data(64, "ld_data_o") # ok to be set by L0 Cache/Buf
34 self
.st
= Data(64, "st_data_i") # ok to be set by CompUnit
37 class L0CacheBuffer(Elaboratable
):
40 Note that the final version will have *two* interfaces per LDSTCompUnit,
41 to cover mis-aligned requests.
44 def __init__(self
, n_units
):
45 self
.n_units
= n_units
47 for i
in range(n_units
):
48 ul
.append(PortInterface("ldst_port%d" % i
))
49 self
.ports
= Array(ul
)
53 from alu_hier
import ALU
56 dut
= ComputationUnitNoDelay(16, alu
)
57 vl
= rtlil
.convert(dut
, ports
=dut
.ports())
58 with
open("test_compalu.il", "w") as f
:
61 run_simulation(dut
, scoreboard_sim(dut
), vcd_name
='test_compalu.vcd')
64 if __name__
== '__main__':