From e2e9603d4eac47b238c11e42a8a64a15a93e29ab Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Fri, 13 Dec 2019 20:55:28 -0700 Subject: [PATCH] continue work on shift/inhibit rule matcher --- stack.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/stack.py b/stack.py index 84d5413..9582853 100644 --- a/stack.py +++ b/stack.py @@ -171,7 +171,7 @@ class InspectableStack(Elaboratable): class HitOrMiss(Elaboratable): def __init__(self, item_width, stack_depth, reduce_ruleset, shift_ruleset): - assert(len(reduce_ruleset) == len(shift_ruleset)) + #assert(len(reduce_ruleset) == len(shift_ruleset)) # Parameters self.reduce_ruleset = reduce_ruleset @@ -191,20 +191,20 @@ class HitOrMiss(Elaboratable): one_hot_components = [] - for rules in zip(self.reduce_ruleset, self.shift_ruleset): - (hit_rule, miss_rules) = rules - + for rulepack in zip(self.reduce_ruleset, self.shift_ruleset): + (hit_rule, miss_rules) = rulepack + print (hit_rule) reduce_match = Signal(1) # 1 if the reduce rule matches shift_match = Signal(1) # 1 if any one of the shift rules matches - rule_status = Signal(1) # 1 if the reduce rule matched and none of the shift rules matched + filtered_match = Signal(1) # 1 if the reduce rule matched and none of the shift rules matched hit_rule_predicates = [] for hit_predicate in hit_rule: (stack_index, mask, value) = hit_predicate - predicate_good = Signal(1) - m.d.comb += predicate_good.eq(((self.stack_view_in[stack_index] & mask) == value) & self.occupancy_bitmap_in[stack_index]) - hit_rule_predicates.append(predicate_good) + reduce_predicate = Signal(1) + m.d.comb += reduce_predicate.eq(((self.stack_view_in[stack_index] & mask) == value) & self.occupancy_bitmap_in[stack_index]) + hit_rule_predicates.append(reduce_predicate) m.d.comb += reduce_match.eq(reduce(lambda x, y: x & y, hit_rule_predicates)) @@ -215,16 +215,16 @@ class HitOrMiss(Elaboratable): for miss_predicate in miss_subrule: (stack_index, mask, value) = hit_predicate - predicate_good = Signal(1) - m.d.comb += predicate_good.eq(((self.stack_view_in[stack_index] & mask) == value) & self.occupancy_bitmap_in[stack_index]) - miss_subrule_predicates.append(predicate_good) + shift_predicate = Signal(1) + m.d.comb += shift_predicate.eq(((self.stack_view_in[stack_index] & mask) == value) & self.occupancy_bitmap_in[stack_index]) + miss_subrule_predicates.append(shift_predicate) m.d.comb += miss_subrule_matched.eq(reduce(lambda x, y: x & y, miss_subrule_predicates)) miss_subrules_status.append(miss_subrule_matched) - m.d.comb += shift_match.eq(reduce(lambda x, y: x | y, miss_subrules_status)) - m.d.comb += rule_status.eq(reduce_match & ~(shift_match)) - one_hot_components.append(rule_status) + m.d.comb += shift_match.eq(reduce(lambda x, y: x | y, miss_subrules_status, 0)) + m.d.comb += filtered_match.eq(reduce_match & ~(shift_match)) + one_hot_components.append(filtered_match) m.d.comb += self.match_index_out.eq(Cat(one_hot_components)) @@ -310,7 +310,7 @@ class MasterStateMachine(Elaboratable): def elaborate(self, platform): m = Module() stack = InspectableStack(item_width=self.item_width, stack_depth=self.stack_depth) - rule_matcher = HitOrMiss(item_width=self.item_width, stack_depth=self.stack_depth, reduce_ruleset = self.match_rules) + rule_matcher = HitOrMiss(item_width=self.item_width, stack_depth=self.stack_depth, reduce_ruleset = self.match_rules, shift_ruleset = [[], [], [], [], [], []]) rex = RuleExecutor(item_width=self.item_width, stack_depth=self.stack_depth, execution_ruleset=self.execute_rules) skbuffer = NonRegisteredSkidBuffer(width = self.item_width) m.submodules.Stack = stack -- GitLab