1 from nmutil
.concurrentunit
import PipeContext
2 from nmutil
.dynamicpipe
import SimpleHandshakeRedir
3 from nmigen
import Signal
4 from soc
.decoder
.power_decoder2
import Data
5 from soc
.fu
.regspec
import get_regspec_bitwidth
10 def __init__(self
, pspec
, output
):
11 self
.ctx
= PipeContext(pspec
) # context for ReservationStation usage
12 self
.muxid
= self
.ctx
.muxid
14 self
.is_output
= output
15 for i
, (regfile
, regname
, widspec
) in enumerate(self
.regspec
):
16 wid
= get_regspec_bitwidth([self
.regspec
], 0, i
)
18 sig
= Data(wid
, name
=regname
)
20 sig
= Signal(wid
, name
=regname
, reset_less
=True)
21 setattr(self
, regname
, sig
)
29 eqs
= [self
.ctx
.eq(i
.ctx
)]
30 assert len(self
.data
) == len(i
.data
), \
31 "length of %s mismatch against %s: %s %s" % \
32 (repr(self
), repr(i
), repr(self
.data
), repr(i
.data
))
33 for j
in range(len(self
.data
)):
34 assert type(self
.data
[j
]) == type(i
.data
[j
]), \
35 "type mismatch in IntegerData %s %s" % \
36 (repr(self
.data
[j
]), repr(i
.data
[j
]))
37 eqs
.append(self
.data
[j
].eq(i
.data
[j
]))
41 return self
.ctx
.ports() # TODO: include self.data
44 # hmmm there has to be a better way than this
45 def get_rec_width(rec
):
47 # Setup random inputs for dut.op
55 def __init__(self
, id_wid
):
56 self
.pipekls
= SimpleHandshakeRedir
58 self
.opkls
= lambda _
: self
.opsubsetkls(name
="op")
59 self
.op_wid
= get_rec_width(self
.opkls(None)) # hmm..