def __init__(self, lane_count, seqn_width, layout_payload): self.input = [ Record(layouts.output_network_node(seqn_width, layout_payload)) for _ in range(lane_count) ] self.output = None step_input = self.input for step in boms_steps_pairs(lane_count): step_output = [] for i in range(lane_count): rec = Record(layouts.output_network_node( seqn_width, layout_payload), reset_less=True) rec.valid.reset_less = False step_output.append(rec) for node1, node2 in step: nondata_difference = Signal() for field, _ in layout_payload: if field != "data": f1 = getattr(step_input[node1].payload, field) f2 = getattr(step_input[node2].payload, field) self.comb += If(f1 != f2, nondata_difference.eq(1)) k1 = Cat(step_input[node1].payload.channel, ~step_input[node1].valid) k2 = Cat(step_input[node2].payload.channel, ~step_input[node2].valid) self.sync += [ If( k1 == k2, If( cmp_wrap(step_input[node1].seqn, step_input[node2].seqn), step_output[node1].eq(step_input[node2]), step_output[node2].eq(step_input[node1])).Else( step_output[node1].eq(step_input[node1]), step_output[node2].eq(step_input[node2])), step_output[node1].replace_occured.eq(1), step_output[node1].nondata_replace_occured.eq( nondata_difference), step_output[node2].valid.eq(0), ).Elif(k1 < k2, step_output[node1].eq(step_input[node1]), step_output[node2].eq(step_input[node2])).Else( step_output[node1].eq(step_input[node2]), step_output[node2].eq(step_input[node1])) ] unchanged = list(range(lane_count)) for node1, node2 in step: unchanged.remove(node1) unchanged.remove(node2) for node in unchanged: self.sync += step_output[node].eq(step_input[node]) self.output = step_output step_input = step_output
def __init__(self, lane_count, seqn_width, layout_payload): self.input = [Record(layouts.output_network_node(seqn_width, layout_payload)) for _ in range(lane_count)] self.output = None step_input = self.input for step in boms_steps_pairs(lane_count): step_output = [] for i in range(lane_count): rec = Record(layouts.output_network_node(seqn_width, layout_payload), reset_less=True) rec.valid.reset_less = False step_output.append(rec) for node1, node2 in step: nondata_difference = Signal() for field, _ in layout_payload: if field != "data": f1 = getattr(step_input[node1].payload, field) f2 = getattr(step_input[node2].payload, field) self.comb += If(f1 != f2, nondata_difference.eq(1)) k1 = Cat(step_input[node1].payload.channel, ~step_input[node1].valid) k2 = Cat(step_input[node2].payload.channel, ~step_input[node2].valid) self.sync += [ If(k1 == k2, If(cmp_wrap(step_input[node1].seqn, step_input[node2].seqn), step_output[node1].eq(step_input[node2]), step_output[node2].eq(step_input[node1]) ).Else( step_output[node1].eq(step_input[node1]), step_output[node2].eq(step_input[node2]) ), step_output[node1].replace_occured.eq(1), step_output[node1].nondata_replace_occured.eq(nondata_difference), step_output[node2].valid.eq(0), ).Elif(k1 < k2, step_output[node1].eq(step_input[node1]), step_output[node2].eq(step_input[node2]) ).Else( step_output[node1].eq(step_input[node2]), step_output[node2].eq(step_input[node1]) ) ] unchanged = list(range(lane_count)) for node1, node2 in step: unchanged.remove(node1) unchanged.remove(node2) for node in unchanged: self.sync += step_output[node].eq(step_input[node]) self.output = step_output step_input = step_output
def __init__(self, lane_count, seqn_width, layout_fifo_payload, layout_output_network_payload): self.input = [Record(layouts.fifo_egress(seqn_width, layout_fifo_payload)) for _ in range(lane_count)] self.output = [Record(layouts.output_network_node(seqn_width, layout_output_network_payload), reset_less=True) for _ in range(lane_count)] if hasattr(self.output[0].payload, "fine_ts"): glbl_fine_ts_width = len(self.output[0].payload.fine_ts) else: glbl_fine_ts_width = 0 self.coarse_timestamp = Signal(64-glbl_fine_ts_width) # # # for input, output in zip(self.input, self.output): for field, _ in output.payload.layout: if field == "fine_ts": self.sync += output.payload.fine_ts.eq(input.payload.timestamp[:glbl_fine_ts_width]) else: self.sync += getattr(output.payload, field).eq(getattr(input.payload, field)) self.sync += output.seqn.eq(input.seqn) self.comb += [ output.replace_occured.eq(0), output.nondata_replace_occured.eq(0) ] self.comb += input.re.eq(input.payload.timestamp[glbl_fine_ts_width:] == self.coarse_timestamp) output.valid.reset_less = False self.sync += output.valid.eq(input.re & input.readable)