From 24d5905312e06f0d696edbcb322e1ede4028daba Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Mon, 23 Dec 2019 17:45:14 -0700 Subject: [PATCH] verify that it's indeed one-hot --- combinatorial_LR_parser.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/combinatorial_LR_parser.py b/combinatorial_LR_parser.py index 69ed85b..ceb2752 100644 --- a/combinatorial_LR_parser.py +++ b/combinatorial_LR_parser.py @@ -227,7 +227,7 @@ class HitOrMiss(Elaboratable): self.stack_depth = stack_depth # Rulepack - self.validitem_ruleset = validitem_ruleset + self.validitem_ruleset = validitem_ruleset self.forceshift_ruleset = forceshift_ruleset self.reduce_ruleset = reduce_ruleset self.pairwise_priority_ruleset = pairwise_priority_ruleset @@ -242,6 +242,7 @@ class HitOrMiss(Elaboratable): self.force_shift = Signal(1) self.invalid_item = Signal(1) + self.internal_fault = Signal(1) def elaborate(self, platform): m = Module() @@ -395,6 +396,18 @@ class HitOrMiss(Elaboratable): m.d.comb += new_inh.eq(inh_value & (~dom_value)) matching_reduce_rules_onehot_components[inhibited_rule_number] = new_inh + # verify it's one-hot + one_hot = Signal(1) + two_hot = Signal(1) + for bit in matching_reduce_rules_onehot_components: + with m.If(bit == 1): + m.d.comb += one_hot.eq(1) + with m.If(one_hot & (bit ==1)): + m.d.comb += two_hot.eq(1) + + with m.If(two_hot == 1): + m.d.comb += internal_fault.eq(1) + matching_reduce_rules_onehot = Signal(len(reduce_ruleset)) m.d.comb += match_index_out.eq(Cat(matching_reduce_rules_onehot_components)) -- GitLab