self.sto_rel_o = Signal(reset_less=True) # request store (to mem)
self.req_rel_o = Signal(reset_less=True) # request write (result)
self.data_o = Signal(rwid, reset_less=True) # Dest out (LD or ALU)
+ self.addr_o = Signal(rwid, reset_less=True) # Address out (LD or ST)
# hmm... TODO... move these to outside of LDSTCompUnit
self.load_mem_o = Signal(reset_less=True) # activate memory LOAD
m.d.comb += self.alu.p_valid_i.eq(1) # so indicate valid
# put the register directly onto the output
- comb += self.data_o.eq(data_r)
+ with m.If((self.go_wr_i & ~op_ldst) | (self.go_st_i & op_is_st)):
+ comb += self.data_o.eq(data_r)
+
+ # put the register directly onto the address bus
+ with m.If(self.go_ad_i):
+ comb += self.addr_o.eq(data_r)
return m
self.req_rel_o = Signal(n_units, reset_less=True)
self.load_mem_o = Signal(n_units, reset_less=True)
self.stwd_mem_o = Signal(n_units, reset_less=True)
+ self.addr_o = Signal(rwid, reset_less=True)
# in/out register data (note: not register#, actual data)
self.data_o = Signal(rwid, reset_less=True)
# connect data register input/output
# merge (OR) all integer FU / ALU outputs to a single value
- # bit of a hack: treereduce needs a list with an item named "data_o"
if self.units:
- data_o = treereduce(self.units)
+ data_o = treereduce(self.units, "data_o")
comb += self.data_o.eq(data_o)
+ if self.ldstmode:
+ addr_o = treereduce(self.units, "addr_o")
+ comb += self.addr_o.eq(addr_o)
for i, alu in enumerate(self.units):
comb += alu.src1_i.eq(self.src1_i)
comb += cul.go_ad_i.eq(cul.adr_rel_o)
# connect up address data
- comb += memfus.addrs_i[0].eq(cul.units[0].data_o)
- comb += memfus.addrs_i[1].eq(cul.units[1].data_o)
+ comb += memfus.addrs_i[0].eq(cul.units[0].addr_o)
+ comb += memfus.addrs_i[1].eq(cul.units[1].addr_o)
# connect loadable / storable to go_ld/go_st.
# XXX should only be done when the memory ld/st has actually happened!
class Register(Elaboratable):
- def __init__(self, width, writethru=False):
+ def __init__(self, width, writethru=True):
self.width = width
self.writethru = writethru
self._rdports = []
def ports(self):
res = list(self)
-def treereduce(tree):
+def treereduce(tree, attr="data_o"):
#print ("treereduce", tree)
if not isinstance(tree, list):
return tree
if len(tree) == 1:
- return tree[0].data_o
+ return getattr(tree[0], attr)
if len(tree) == 2:
- return tree[0].data_o | tree[1].data_o
- splitpoint = len(tree) // 2
- return treereduce(tree[:splitpoint]) | treereduce(tree[splitpoint:])
+ return getattr(tree[0], attr) | getattr(tree[1], attr)
+ split = len(tree) // 2
+ return treereduce(tree[:split], attr) | treereduce(tree[split:], attr)
class RegFileArray(Elaboratable):