From 5406ab64add64f95c1f34547c7b409c99b38db89 Mon Sep 17 00:00:00 2001 From: Akash Dhiraj Date: Tue, 24 Sep 2024 15:47:21 -0400 Subject: [PATCH] Factor out binheap/round_robin.py state updates --- .../queues/queues/binheap/round_robin.py | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/frontends/queues/queues/binheap/round_robin.py b/frontends/queues/queues/binheap/round_robin.py index 8385c5392..7e02d1ffd 100644 --- a/frontends/queues/queues/binheap/round_robin.py +++ b/frontends/queues/queues/binheap/round_robin.py @@ -68,6 +68,19 @@ def binheap_invoke(value, rank): for i in range(n) ]) + update_state_pop = [ + infer_flow_out, + cb.while_with( + turn_neq_flow_out, + [ + comp.case(turn.out, rank_ptr_incrs), + turn_incr_mod_n + ] + ), + turn_incr_mod_n + ] + update_state_push = comp.case(flow_in.out, rank_ptr_incrs) + comp.control += [ init_state, infer_flow_in, @@ -76,22 +89,7 @@ def binheap_invoke(value, rank): err_eq_0, comp.case( cmd, - { - 0: - [ - infer_flow_out, - cb.while_with( - turn_neq_flow_out, - [ - comp.case(turn.out, rank_ptr_incrs), - turn_incr_mod_n - ] - ), - turn_incr_mod_n - ], - 1: - comp.case(flow_in.out, rank_ptr_incrs) - } + { 0: update_state_pop, 1: update_state_push } ) ) ]