n_i_readyn = Array(n_i_readyn)
data_valid = Array(data_valid)
- ni = 0 # TODO: use n_nux to decide which to select
+ ni = 0 # TODO: use n_mux to decide which to select
if self.p_mux:
mid = self.p_mux.m_id
for i in range(p_len):
+ m.d.sync += data_valid[i].eq(0)
+ m.d.comb += n_i_readyn[i].eq(1)
m.d.comb += p_i_valid[i].eq(0)
m.d.comb += self.p[i].o_ready.eq(0)
m.d.comb += p_i_valid[mid].eq(self.p_mux.active)
m.d.comb += self.p[mid].o_ready.eq(~data_valid[mid] | \
self.n[ni].i_ready)
- m.d.comb += self.n[ni].o_valid.eq(data_valid[mid])
+ m.d.comb += n_i_readyn[mid].eq(~self.n[ni].i_ready & \
+ data_valid[mid])
+ anyvalid = Signal(i, reset_less=True)
+ av = []
+ for i in range(p_len):
+ av.append(data_valid[i])
+ anyvalid = Cat(*av)
+ m.d.comb += self.n[ni].o_valid.eq(anyvalid.bool())
+ m.d.sync += data_valid[mid].eq(p_i_valid[mid] | \
+ (n_i_readyn[mid] & data_valid[mid]))
for i in range(p_len):
- m.d.comb += n_i_readyn[i].eq(~self.n[ni].i_ready & \
- data_valid[i])
- m.d.sync += data_valid[i].eq(p_i_valid[i] | \
- (n_i_readyn[i] & data_valid[i]))
with m.If(self.p[i].i_valid & self.p[i].o_ready):
m.d.sync += eq(r_data[i], self.p[i].i_data)
self.di[mid] = {}
self.do[mid] = {}
for i in range(self.tlen):
- self.di[mid][i] = randint(0, 100)
+ self.di[mid][i] = randint(0, 100) + (mid<<8)
self.do[mid][i] = self.di[mid][i]
def send(self, mid):
for i in range(self.tlen):
op2 = self.di[mid][i]
rs = dut.p[mid]
- yield rs.i_valid.eq(0)
+ yield rs.i_valid.eq(1)
o_p_ready = yield rs.o_ready
while not o_p_ready:
yield
o_p_ready = yield rs.o_ready
- print ("send", mid, i, op2)
+ print ("send", mid, i, hex(op2))
- yield rs.i_valid.eq(1)
yield rs.i_data.data.eq(op2)
yield rs.i_data.idx.eq(i)
yield rs.i_data.mid.eq(mid)
#for v in self.dut.set_input((op2, i, mid)):
# yield v
yield
+ yield rs.i_valid.eq(0)
yield rs.i_valid.eq(0)
## wait random period of time before queueing another value
out_i = yield n.o_data.idx
out_v = yield n.o_data.data
- print ("recv", mid, out_i, out_v)
+ print ("recv", mid, out_i, hex(out_v))
# see if this output has occurred already, delete it if it has
assert out_i in self.do[mid], "out_i %d not in array %s" % \