From b7a69557de412aa1faa9c1dcaf6405dd09cf5f3a Mon Sep 17 00:00:00 2001 From: Donald Sebastian Leung Date: Wed, 21 Oct 2020 13:09:54 +0800 Subject: [PATCH] Add assertion for no replacements given unique inputs --- rtio/sed/output_network.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rtio/sed/output_network.py b/rtio/sed/output_network.py index c789627..25fdeca 100644 --- a/rtio/sed/output_network.py +++ b/rtio/sed/output_network.py @@ -165,5 +165,22 @@ class OutputNetwork(Elaboratable): # for i in range(len(self.input)): # m.d.comb += Assert(appeared[i]) + # If the valid bit / channel no. combinations of all input data are + # unique then there should be no replacements + with m.If(f_output_valid): + nodes_unique = Signal(reset=1) + for node1 in range(len(self.input)): + for node2 in range(node1): + k1 = Cat(Past(self.input[node1].payload.channel, clocks=network_latency), ~Past(self.input[node1].valid, clocks=network_latency)) + k2 = Cat(Past(self.input[node2].payload.channel, clocks=network_latency), ~Past(self.input[node2].valid, clocks=network_latency)) + with m.If(k1 == k2): + m.d.comb += nodes_unique.eq(0) + with m.If(nodes_unique): + replacement_occurred = Signal() + for output_node in self.output: + with m.If(output_node.replace_occured): + m.d.comb += replacement_occurred.eq(1) + m.d.comb += Assert(~replacement_occurred) + def elaborate(self, platform): return self.m