diff --git a/xls/interpreter/serial_proc_runtime_test.cc b/xls/interpreter/serial_proc_runtime_test.cc index 9249da3f45..48d84c8a5a 100644 --- a/xls/interpreter/serial_proc_runtime_test.cc +++ b/xls/interpreter/serial_proc_runtime_test.cc @@ -249,6 +249,12 @@ TEST_F(ExplicitStateRuntimeTest, ExplicitStateAccessReadWithLabeledRead) { "State element read after read in same activation."))); } +TEST_F(ExplicitStateRuntimeTest, + ExplicitStateAccessMultipleBranchingLabeledReads) { + XLS_ASSERT_OK_AND_ASSIGN(auto interpreter, CreateRuntime(GetTestDataPath())); + EXPECT_THAT(interpreter->Tick(), absl_testing::IsOk()); +} + TEST_F(ExplicitStateRuntimeTest, ExplicitStateAccessMultipleStates) { XLS_ASSERT_OK_AND_ASSIGN(auto interpreter, CreateRuntime(GetTestDataPath())); EXPECT_THAT(interpreter->Tick(), absl_testing::IsOk()); diff --git a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessLabeledReadAndWrite.ir b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessLabeledReadAndWrite.ir index 581e4e1839..94da6f910c 100644 --- a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessLabeledReadAndWrite.ir +++ b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessLabeledReadAndWrite.ir @@ -3,29 +3,17 @@ package test_module file_number 0 "test_module.x" top proc __test_module__main_0_next<>(__state: bits[32], init={0}) { - literal.5: bits[1] = literal(value=1, id=5) - literal.3: bits[1] = literal(value=0, id=3) - not.7: bits[1] = not(literal.5, id=7) - not.8: bits[1] = not(literal.3, id=8) + literal.2: bits[1] = literal(value=1, id=2) + __state: bits[32] = state_read(state_element=__state, predicate=literal.2, label="main_read", id=4) + not.8: bits[1] = not(literal.2, id=8) + x: bits[32] = identity(__state, id=5) + literal.6: bits[32] = literal(value=1, id=6) __token: token = literal(value=token, id=1) - or.9: bits[1] = or(not.7, not.8, id=9) - not.15: bits[1] = not(literal.5, id=15) - or.11: bits[1] = or(literal.3, literal.5, id=11) - literal.4: bits[1] = literal(value=0, id=4) - __state: bits[32] = state_read(state_element=__state, label="main_read", id=2) - assert.10: token = assert(__token, or.9, message="State element read after read in same activation.", id=10) - or.16: bits[1] = or(not.15, or.11, id=16) - not.18: bits[1] = not(literal.5, id=18) - not.19: bits[1] = not(literal.4, id=19) - x: bits[32] = identity(__state, id=12) - literal.13: bits[32] = literal(value=1, id=13) - assert.17: token = assert(assert.10, or.16, message="State element written before read in same activation.", id=17) - or.20: bits[1] = or(not.18, not.19, id=20) - y: bits[32] = add(x, literal.13, id=14) - tuple.6: () = tuple(id=6) - assert.21: token = assert(assert.17, or.20, message="State element written after write in same activation.", id=21) - or.22: bits[1] = or(literal.4, literal.5, id=22) - next_value.23: () = next_value(param=__state, value=y, predicate=literal.5, label="main_write", id=23) - tuple.24: () = tuple(id=24) - tuple.25: () = tuple(id=25) + or.9: bits[1] = or(not.8, literal.2, id=9) + y: bits[32] = add(x, literal.6, id=7) + tuple.3: () = tuple(id=3) + assert.10: token = assert(__token, or.9, message="State element written before read in same activation.", id=10) + next_value.11: () = next_value(param=__state, value=y, predicate=literal.2, label="main_write", id=11) + tuple.12: () = tuple(id=12) + tuple.13: () = tuple(id=13) } diff --git a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMatch.ir b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMatch.ir index 2430c961fb..5fca02c1bb 100644 --- a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMatch.ir +++ b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMatch.ir @@ -3,68 +3,56 @@ package test_module file_number 0 "test_module.x" top proc __test_module__main_0_next<>(__state: bits[32], init={0}) { - __state: bits[32] = state_read(state_element=__state, id=2) - current: bits[32] = identity(__state, id=12) - literal.13: bits[32] = literal(value=2, id=13) - literal.15: bits[32] = literal(value=0, id=15) - even_or_odd: bits[32] = umod(current, literal.13, id=14) - literal.5: bits[1] = literal(value=1, id=5) - literal.3: bits[1] = literal(value=0, id=3) - literal.19: bits[1] = literal(value=1, id=19) - eq.16: bits[1] = eq(literal.15, even_or_odd, id=16) - not.7: bits[1] = not(literal.5, id=7) - not.8: bits[1] = not(literal.3, id=8) - and.20: bits[1] = and(literal.5, literal.19, eq.16, id=20) - literal.32: bits[32] = literal(value=1, id=32) + literal.2: bits[1] = literal(value=1, id=2) + __state: bits[32] = state_read(state_element=__state, predicate=literal.2, id=4) + current: bits[32] = identity(__state, id=5) + literal.6: bits[32] = literal(value=2, id=6) + literal.8: bits[32] = literal(value=0, id=8) + even_or_odd: bits[32] = umod(current, literal.6, id=7) + literal.12: bits[1] = literal(value=1, id=12) + eq.9: bits[1] = eq(literal.8, even_or_odd, id=9) + literal.20: bits[32] = literal(value=1, id=20) + and.13: bits[1] = and(literal.2, literal.12, eq.9, id=13) + not.24: bits[1] = not(eq.9, id=24) + eq.21: bits[1] = eq(literal.20, even_or_odd, id=21) + not.14: bits[1] = not(and.13, id=14) + and.25: bits[1] = and(literal.2, not.24, eq.21, id=25) __token: token = literal(value=token, id=1) - or.9: bits[1] = or(not.7, not.8, id=9) - not.21: bits[1] = not(and.20, id=21) - or.11: bits[1] = or(literal.3, literal.5, id=11) - literal.4: bits[1] = literal(value=0, id=4) - not.36: bits[1] = not(eq.16, id=36) - eq.33: bits[1] = eq(literal.32, even_or_odd, id=33) - assert.10: token = assert(__token, or.9, message="State element read after read in same activation.", id=10) - or.22: bits[1] = or(not.21, or.11, id=22) - not.24: bits[1] = not(and.20, id=24) - not.25: bits[1] = not(literal.4, id=25) - and.37: bits[1] = and(literal.5, not.36, eq.33, id=37) - assert.23: token = assert(assert.10, or.22, message="State element written before read in same activation.", id=23) - or.26: bits[1] = or(not.24, not.25, id=26) - not.38: bits[1] = not(and.37, id=38) - or.28: bits[1] = or(literal.4, and.20, id=28) - nor.50: bits[1] = nor(eq.16, eq.33, id=50) - assert.27: token = assert(assert.23, or.26, message="State element written after write in same activation.", id=27) - or.39: bits[1] = or(not.38, or.11, id=39) - not.41: bits[1] = not(and.37, id=41) - not.42: bits[1] = not(or.28, id=42) - and.51: bits[1] = and(literal.5, nor.50, id=51) - assert.40: token = assert(assert.27, or.39, message="State element written before read in same activation.", id=40) - or.43: bits[1] = or(not.41, not.42, id=43) - not.52: bits[1] = not(and.51, id=52) - or.45: bits[1] = or(or.28, and.37, id=45) - literal.17: bits[32] = literal(value=1, id=17) - literal.34: bits[32] = literal(value=2, id=34) - assert.44: token = assert(assert.40, or.43, message="State element written after write in same activation.", id=44) - or.53: bits[1] = or(not.52, or.11, id=53) - not.55: bits[1] = not(and.51, id=55) - not.56: bits[1] = not(or.45, id=56) - add.18: bits[32] = add(current, literal.17, id=18) - umul.35: bits[32] = umul(current, literal.34, id=35) - assert.54: token = assert(assert.44, or.53, message="State element written before read in same activation.", id=54) - or.57: bits[1] = or(not.55, not.56, id=57) - concat.63: bits[2] = concat(eq.33, eq.16, id=63) - tuple.31: () = tuple(id=31) - tuple.48: () = tuple(id=48) - tuple.62: () = tuple(id=62) - tuple.6: () = tuple(id=6) - next_value.29: () = next_value(param=__state, value=add.18, predicate=and.20, id=29) - tuple.30: () = tuple(id=30) - next_value.46: () = next_value(param=__state, value=umul.35, predicate=and.37, id=46) - tuple.47: () = tuple(id=47) - literal.49: bits[1] = literal(value=1, id=49) - assert.58: token = assert(assert.54, or.57, message="State element written after write in same activation.", id=58) - or.59: bits[1] = or(or.45, and.51, id=59) - next_value.60: () = next_value(param=__state, value=current, predicate=and.51, id=60) - tuple.61: () = tuple(id=61) - priority_sel.64: () = priority_sel(concat.63, cases=[tuple.31, tuple.48], default=tuple.62, id=64) + or.15: bits[1] = or(not.14, literal.2, id=15) + not.26: bits[1] = not(and.25, id=26) + nor.38: bits[1] = nor(eq.9, eq.21, id=38) + assert.16: token = assert(__token, or.15, message="State element written before read in same activation.", id=16) + or.27: bits[1] = or(not.26, literal.2, id=27) + not.29: bits[1] = not(and.25, id=29) + not.30: bits[1] = not(and.13, id=30) + and.39: bits[1] = and(literal.2, nor.38, id=39) + assert.28: token = assert(assert.16, or.27, message="State element written before read in same activation.", id=28) + or.31: bits[1] = or(not.29, not.30, id=31) + not.40: bits[1] = not(and.39, id=40) + or.33: bits[1] = or(and.13, and.25, id=33) + literal.10: bits[32] = literal(value=1, id=10) + literal.22: bits[32] = literal(value=2, id=22) + assert.32: token = assert(assert.28, or.31, message="State element written after write in same activation.", id=32) + or.41: bits[1] = or(not.40, literal.2, id=41) + not.43: bits[1] = not(and.39, id=43) + not.44: bits[1] = not(or.33, id=44) + add.11: bits[32] = add(current, literal.10, id=11) + umul.23: bits[32] = umul(current, literal.22, id=23) + assert.42: token = assert(assert.32, or.41, message="State element written before read in same activation.", id=42) + or.45: bits[1] = or(not.43, not.44, id=45) + concat.51: bits[2] = concat(eq.21, eq.9, id=51) + tuple.19: () = tuple(id=19) + tuple.36: () = tuple(id=36) + tuple.50: () = tuple(id=50) + tuple.3: () = tuple(id=3) + next_value.17: () = next_value(param=__state, value=add.11, predicate=and.13, id=17) + tuple.18: () = tuple(id=18) + next_value.34: () = next_value(param=__state, value=umul.23, predicate=and.25, id=34) + tuple.35: () = tuple(id=35) + literal.37: bits[1] = literal(value=1, id=37) + assert.46: token = assert(assert.42, or.45, message="State element written after write in same activation.", id=46) + or.47: bits[1] = or(or.33, and.39, id=47) + next_value.48: () = next_value(param=__state, value=current, predicate=and.39, id=48) + tuple.49: () = tuple(id=49) + priority_sel.52: () = priority_sel(concat.51, cases=[tuple.19, tuple.36], default=tuple.50, id=52) } diff --git a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMatchMultipleWrites.ir b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMatchMultipleWrites.ir index eea3c33520..69b7d139d3 100644 --- a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMatchMultipleWrites.ir +++ b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMatchMultipleWrites.ir @@ -3,76 +3,64 @@ package test_module file_number 0 "test_module.x" top proc __test_module__main_0_next<>(__state: bits[1], init={1}) { - __state: bits[1] = state_read(state_element=__state, id=2) - literal.13: bits[1] = literal(value=1, id=13) - val: bits[1] = identity(__state, id=12) - literal.5: bits[1] = literal(value=1, id=5) - literal.3: bits[1] = literal(value=0, id=3) - literal.16: bits[1] = literal(value=1, id=16) - eq.14: bits[1] = eq(literal.13, val, id=14) - not.7: bits[1] = not(literal.5, id=7) - not.8: bits[1] = not(literal.3, id=8) - and.17: bits[1] = and(literal.5, literal.16, eq.14, id=17) + literal.2: bits[1] = literal(value=1, id=2) + __state: bits[1] = state_read(state_element=__state, predicate=literal.2, id=4) + literal.6: bits[1] = literal(value=1, id=6) + val: bits[1] = identity(__state, id=5) + literal.9: bits[1] = literal(value=1, id=9) + eq.7: bits[1] = eq(literal.6, val, id=7) + and.10: bits[1] = and(literal.2, literal.9, eq.7, id=10) + literal.17: bits[1] = literal(value=1, id=17) + not.11: bits[1] = not(and.10, id=11) + and.18: bits[1] = and(literal.2, literal.17, eq.7, id=18) __token: token = literal(value=token, id=1) - or.9: bits[1] = or(not.7, not.8, id=9) - not.18: bits[1] = not(and.17, id=18) - or.11: bits[1] = or(literal.3, literal.5, id=11) - literal.4: bits[1] = literal(value=0, id=4) - literal.29: bits[1] = literal(value=1, id=29) - assert.10: token = assert(__token, or.9, message="State element read after read in same activation.", id=10) - or.19: bits[1] = or(not.18, or.11, id=19) - not.21: bits[1] = not(and.17, id=21) - not.22: bits[1] = not(literal.4, id=22) - and.30: bits[1] = and(literal.5, literal.29, eq.14, id=30) - assert.20: token = assert(assert.10, or.19, message="State element written before read in same activation.", id=20) - or.23: bits[1] = or(not.21, not.22, id=23) - not.31: bits[1] = not(and.30, id=31) - or.25: bits[1] = or(literal.4, and.17, id=25) - not.45: bits[1] = not(eq.14, id=45) - assert.24: token = assert(assert.20, or.23, message="State element written after write in same activation.", id=24) - or.32: bits[1] = or(not.31, or.11, id=32) - not.34: bits[1] = not(and.30, id=34) - not.35: bits[1] = not(or.25, id=35) - and.46: bits[1] = and(literal.5, not.45, id=46) - assert.33: token = assert(assert.24, or.32, message="State element written before read in same activation.", id=33) - or.36: bits[1] = or(not.34, not.35, id=36) - not.47: bits[1] = not(and.46, id=47) - or.38: bits[1] = or(or.25, and.30, id=38) - not.58: bits[1] = not(eq.14, id=58) - assert.37: token = assert(assert.33, or.36, message="State element written after write in same activation.", id=37) - or.48: bits[1] = or(not.47, or.11, id=48) - not.50: bits[1] = not(and.46, id=50) - not.51: bits[1] = not(or.38, id=51) - and.59: bits[1] = and(literal.5, not.58, id=59) - assert.49: token = assert(assert.37, or.48, message="State element written before read in same activation.", id=49) - or.52: bits[1] = or(not.50, not.51, id=52) - not.60: bits[1] = not(and.59, id=60) - or.54: bits[1] = or(or.38, and.46, id=54) - assert.53: token = assert(assert.49, or.52, message="State element written after write in same activation.", id=53) - or.61: bits[1] = or(not.60, or.11, id=61) - not.63: bits[1] = not(and.59, id=63) - not.64: bits[1] = not(or.54, id=64) - literal.15: bits[1] = literal(value=0, id=15) - literal.28: bits[1] = literal(value=0, id=28) - literal.42: bits[1] = literal(value=0, id=42) - literal.44: bits[1] = literal(value=1, id=44) - assert.62: token = assert(assert.53, or.61, message="State element written before read in same activation.", id=62) - or.65: bits[1] = or(not.63, not.64, id=65) - literal.57: bits[1] = literal(value=1, id=57) - concat.71: bits[1] = concat(eq.14, id=71) - tuple.41: () = tuple(id=41) - tuple.70: () = tuple(id=70) - tuple.6: () = tuple(id=6) - next_value.26: () = next_value(param=__state, value=literal.15, predicate=and.17, id=26) - tuple.27: () = tuple(id=27) - next_value.39: () = next_value(param=__state, value=literal.28, predicate=and.30, id=39) - tuple.40: () = tuple(id=40) - eq.43: bits[1] = eq(literal.42, val, id=43) - next_value.55: () = next_value(param=__state, value=literal.44, predicate=and.46, id=55) - tuple.56: () = tuple(id=56) - assert.66: token = assert(assert.62, or.65, message="State element written after write in same activation.", id=66) - or.67: bits[1] = or(or.54, and.59, id=67) - next_value.68: () = next_value(param=__state, value=literal.57, predicate=and.59, id=68) - tuple.69: () = tuple(id=69) - priority_sel.72: () = priority_sel(concat.71, cases=[tuple.41], default=tuple.70, id=72) + or.12: bits[1] = or(not.11, literal.2, id=12) + not.19: bits[1] = not(and.18, id=19) + not.33: bits[1] = not(eq.7, id=33) + assert.13: token = assert(__token, or.12, message="State element written before read in same activation.", id=13) + or.20: bits[1] = or(not.19, literal.2, id=20) + not.22: bits[1] = not(and.18, id=22) + not.23: bits[1] = not(and.10, id=23) + and.34: bits[1] = and(literal.2, not.33, id=34) + assert.21: token = assert(assert.13, or.20, message="State element written before read in same activation.", id=21) + or.24: bits[1] = or(not.22, not.23, id=24) + not.35: bits[1] = not(and.34, id=35) + or.26: bits[1] = or(and.10, and.18, id=26) + not.46: bits[1] = not(eq.7, id=46) + assert.25: token = assert(assert.21, or.24, message="State element written after write in same activation.", id=25) + or.36: bits[1] = or(not.35, literal.2, id=36) + not.38: bits[1] = not(and.34, id=38) + not.39: bits[1] = not(or.26, id=39) + and.47: bits[1] = and(literal.2, not.46, id=47) + assert.37: token = assert(assert.25, or.36, message="State element written before read in same activation.", id=37) + or.40: bits[1] = or(not.38, not.39, id=40) + not.48: bits[1] = not(and.47, id=48) + or.42: bits[1] = or(or.26, and.34, id=42) + assert.41: token = assert(assert.37, or.40, message="State element written after write in same activation.", id=41) + or.49: bits[1] = or(not.48, literal.2, id=49) + not.51: bits[1] = not(and.47, id=51) + not.52: bits[1] = not(or.42, id=52) + literal.8: bits[1] = literal(value=0, id=8) + literal.16: bits[1] = literal(value=0, id=16) + literal.30: bits[1] = literal(value=0, id=30) + literal.32: bits[1] = literal(value=1, id=32) + assert.50: token = assert(assert.41, or.49, message="State element written before read in same activation.", id=50) + or.53: bits[1] = or(not.51, not.52, id=53) + literal.45: bits[1] = literal(value=1, id=45) + concat.59: bits[1] = concat(eq.7, id=59) + tuple.29: () = tuple(id=29) + tuple.58: () = tuple(id=58) + tuple.3: () = tuple(id=3) + next_value.14: () = next_value(param=__state, value=literal.8, predicate=and.10, id=14) + tuple.15: () = tuple(id=15) + next_value.27: () = next_value(param=__state, value=literal.16, predicate=and.18, id=27) + tuple.28: () = tuple(id=28) + eq.31: bits[1] = eq(literal.30, val, id=31) + next_value.43: () = next_value(param=__state, value=literal.32, predicate=and.34, id=43) + tuple.44: () = tuple(id=44) + assert.54: token = assert(assert.50, or.53, message="State element written after write in same activation.", id=54) + or.55: bits[1] = or(or.42, and.47, id=55) + next_value.56: () = next_value(param=__state, value=literal.45, predicate=and.47, id=56) + tuple.57: () = tuple(id=57) + priority_sel.60: () = priority_sel(concat.59, cases=[tuple.29], default=tuple.58, id=60) } diff --git a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleBranchingLabeledReads.ir b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleBranchingLabeledReads.ir new file mode 100644 index 0000000000..df5101acf8 --- /dev/null +++ b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleBranchingLabeledReads.ir @@ -0,0 +1,55 @@ +package test_module + +file_number 0 "test_module.x" + +top proc __test_module__main_0_next<>(__val: bits[32], __switch: bits[1], init={0, 1}) { + literal.2: bits[1] = literal(value=1, id=2) + __switch: bits[1] = state_read(state_element=__switch, predicate=literal.2, id=4) + switch_val: bits[1] = identity(__switch, id=5) + and.11: bits[1] = and(literal.2, switch_val, id=11) + not.18: bits[1] = not(switch_val, id=18) + not.12: bits[1] = not(and.11, id=12) + and.6: bits[1] = and(literal.2, switch_val, id=6) + and.19: bits[1] = and(literal.2, not.18, id=19) + not.29: bits[1] = not(switch_val, id=29) + __token: token = literal(value=token, id=1) + or.13: bits[1] = or(not.12, and.6, id=13) + not.20: bits[1] = not(and.19, id=20) + not.21: bits[1] = not(and.6, id=21) + and.30: bits[1] = and(literal.2, not.29, id=30) + assert.14: token = assert(__token, or.13, message="State element written before read in same activation.", id=14) + or.22: bits[1] = or(not.20, not.21, id=22) + not.31: bits[1] = not(and.30, id=31) + or.26: bits[1] = or(and.6, and.19, id=26) + __val: bits[32] = state_read(state_element=__val, predicate=and.6, label="EvenRead", id=7) + __val__1: bits[32] = state_read(state_element=__val, predicate=and.19, label="OddRead", id=24) + assert.23: token = assert(assert.14, or.22, message="State element read after read in same activation.", id=23) + or.32: bits[1] = or(not.31, or.26, id=32) + not.34: bits[1] = not(and.30, id=34) + not.35: bits[1] = not(and.11, id=35) + even: bits[32] = identity(__val, id=8) + literal.9: bits[32] = literal(value=1, id=9) + odd: bits[32] = identity(__val__1, id=25) + literal.27: bits[32] = literal(value=1, id=27) + assert.33: token = assert(assert.23, or.32, message="State element written before read in same activation.", id=33) + or.36: bits[1] = or(not.34, not.35, id=36) + not.44: bits[1] = not(literal.2, id=44) + add.10: bits[32] = add(even, literal.9, id=10) + add.28: bits[32] = add(odd, literal.27, id=28) + tuple.41: () = tuple(id=41) + tuple.17: () = tuple(id=17) + assert.37: token = assert(assert.33, or.36, message="State element written after write in same activation.", id=37) + or.45: bits[1] = or(not.44, literal.2, id=45) + not.43: bits[1] = not(switch_val, id=43) + tuple.3: () = tuple(id=3) + next_value.15: () = next_value(param=__val, value=add.10, predicate=and.11, label="EvenWrite", id=15) + tuple.16: () = tuple(id=16) + or.38: bits[1] = or(and.11, and.30, id=38) + next_value.39: () = next_value(param=__val, value=add.28, predicate=and.30, label="OddWrite", id=39) + tuple.40: () = tuple(id=40) + sel.42: () = sel(switch_val, cases=[tuple.41, tuple.17], id=42) + assert.46: token = assert(assert.37, or.45, message="State element written before read in same activation.", id=46) + next_value.47: () = next_value(param=__switch, value=not.43, predicate=literal.2, id=47) + tuple.48: () = tuple(id=48) + tuple.49: () = tuple(id=49) +} diff --git a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleReads.ir b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleReads.ir index a081aba348..b795e7659b 100644 --- a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleReads.ir +++ b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleReads.ir @@ -1,39 +1,19 @@ -// Copyright 2026 The XLS Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package test_module file_number 0 "test_module.x" top proc __test_module__main_0_next<>(__state: bits[32], init={0}) { - literal.5: bits[1] = literal(value=1, id=5) - literal.3: bits[1] = literal(value=0, id=3) - not.7: bits[1] = not(literal.5, id=7) - not.8: bits[1] = not(literal.3, id=8) - or.11: bits[1] = or(literal.3, literal.5, id=11) + literal.2: bits[1] = literal(value=1, id=2) + not.6: bits[1] = not(literal.2, id=6) + not.7: bits[1] = not(literal.2, id=7) + __state: bits[32] = state_read(state_element=__state, predicate=literal.2, id=4) __token: token = literal(value=token, id=1) - or.9: bits[1] = or(not.7, not.8, id=9) - not.13: bits[1] = not(literal.5, id=13) - not.14: bits[1] = not(or.11, id=14) - __state: bits[32] = state_read(state_element=__state, id=2) - assert.10: token = assert(__token, or.9, message="State element read after read in same activation.", id=10) - or.15: bits[1] = or(not.13, not.14, id=15) - literal.4: bits[1] = literal(value=0, id=4) - tuple.6: () = tuple(id=6) - first: bits[32] = identity(__state, id=12) - assert.16: token = assert(assert.10, or.15, message="State element read after read in same activation.", id=16) - or.17: bits[1] = or(or.11, literal.5, id=17) - second: bits[32] = identity(__state, id=18) - tuple.19: () = tuple(id=19) -} \ No newline at end of file + or.8: bits[1] = or(not.6, not.7, id=8) + __state__1: bits[32] = state_read(state_element=__state, predicate=literal.2, id=10) + tuple.3: () = tuple(id=3) + first: bits[32] = identity(__state, id=5) + assert.9: token = assert(__token, or.8, message="State element read after read in same activation.", id=9) + second: bits[32] = identity(__state__1, id=11) + or.12: bits[1] = or(literal.2, literal.2, id=12) + tuple.13: () = tuple(id=13) +} diff --git a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStates.ir b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStates.ir index 875becaad7..ca827df6c7 100644 --- a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStates.ir +++ b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStates.ir @@ -3,81 +3,45 @@ package test_module file_number 0 "test_module.x" top proc __test_module__main_0_next<>(__state_0: (bits[32], bits[32]), __state_1: (bits[32], bits[32]), __state_2: bits[32], init={(0, 1), (2, 3), 4}) { - literal.11: bits[1] = literal(value=1, id=11) - literal.2: bits[1] = literal(value=0, id=2) - not.13: bits[1] = not(literal.11, id=13) - not.14: bits[1] = not(literal.2, id=14) - literal.4: bits[1] = literal(value=0, id=4) + literal.2: bits[1] = literal(value=1, id=2) + __state_0: (bits[32], bits[32]) = state_read(state_element=__state_0, predicate=literal.2, id=4) + __state_1: (bits[32], bits[32]) = state_read(state_element=__state_1, predicate=literal.2, id=6) + a: (bits[32], bits[32]) = identity(__state_0, id=5) + b: (bits[32], bits[32]) = identity(__state_1, id=7) + __state_2: bits[32] = state_read(state_element=__state_2, predicate=literal.2, id=8) + not.24: bits[1] = not(literal.2, id=24) + a_x: bits[32] = tuple_index(a, index=0, id=10) + literal.11: bits[32] = literal(value=1, id=11) + tuple_index.14: bits[32] = tuple_index(b, index=1, id=14) + c: bits[32] = identity(__state_2, id=9) + tuple_index.18: bits[32] = tuple_index(b, index=0, id=18) + literal.19: bits[32] = literal(value=1, id=19) + literal.21: bits[32] = literal(value=1, id=21) __token: token = literal(value=token, id=1) - or.15: bits[1] = or(not.13, not.14, id=15) - not.19: bits[1] = not(literal.11, id=19) - not.20: bits[1] = not(literal.4, id=20) - literal.6: bits[1] = literal(value=0, id=6) - assert.16: token = assert(__token, or.15, message="State element read after read in same activation.", id=16) - or.21: bits[1] = or(not.19, not.20, id=21) - not.25: bits[1] = not(literal.11, id=25) - not.26: bits[1] = not(literal.6, id=26) - assert.22: token = assert(assert.16, or.21, message="State element read after read in same activation.", id=22) - or.27: bits[1] = or(not.25, not.26, id=27) - not.45: bits[1] = not(literal.11, id=45) - or.17: bits[1] = or(literal.2, literal.11, id=17) - literal.3: bits[1] = literal(value=0, id=3) - assert.28: token = assert(assert.22, or.27, message="State element read after read in same activation.", id=28) - or.46: bits[1] = or(not.45, or.17, id=46) - not.48: bits[1] = not(literal.11, id=48) - not.49: bits[1] = not(literal.3, id=49) - __state_0: (bits[32], bits[32]) = state_read(state_element=__state_0, id=8) - __state_1: (bits[32], bits[32]) = state_read(state_element=__state_1, id=9) - assert.47: token = assert(assert.28, or.46, message="State element written before read in same activation.", id=47) - or.50: bits[1] = or(not.48, not.49, id=50) - not.55: bits[1] = not(literal.11, id=55) - or.23: bits[1] = or(literal.4, literal.11, id=23) - literal.5: bits[1] = literal(value=0, id=5) - a: (bits[32], bits[32]) = identity(__state_0, id=18) - b: (bits[32], bits[32]) = identity(__state_1, id=24) - __state_2: bits[32] = state_read(state_element=__state_2, id=10) - assert.51: token = assert(assert.47, or.50, message="State element written after write in same activation.", id=51) - or.56: bits[1] = or(not.55, or.23, id=56) - not.58: bits[1] = not(literal.11, id=58) - not.59: bits[1] = not(literal.5, id=59) - a_x: bits[32] = tuple_index(a, index=0, id=31) - literal.32: bits[32] = literal(value=1, id=32) - tuple_index.35: bits[32] = tuple_index(b, index=1, id=35) - c: bits[32] = identity(__state_2, id=30) - tuple_index.39: bits[32] = tuple_index(b, index=0, id=39) - literal.40: bits[32] = literal(value=1, id=40) - literal.42: bits[32] = literal(value=1, id=42) - assert.57: token = assert(assert.51, or.56, message="State element written before read in same activation.", id=57) - or.60: bits[1] = or(not.58, not.59, id=60) - not.67: bits[1] = not(literal.11, id=67) - or.29: bits[1] = or(literal.6, literal.11, id=29) - literal.7: bits[1] = literal(value=0, id=7) - add.33: bits[32] = add(a_x, literal.32, id=33) - add.36: bits[32] = add(tuple_index.35, c, id=36) - add.41: bits[32] = add(tuple_index.39, literal.40, id=41) - add.43: bits[32] = add(c, literal.42, id=43) - assert.61: token = assert(assert.57, or.60, message="State element written after write in same activation.", id=61) - or.68: bits[1] = or(not.67, or.29, id=68) - not.70: bits[1] = not(literal.11, id=70) - not.71: bits[1] = not(literal.7, id=71) - literal.65: bits[32] = literal(value=2, id=65) - new_a: (bits[32], bits[32]) = tuple(add.33, add.36, id=37) - new_b: (bits[32], bits[32]) = tuple(add.41, add.43, id=44) - assert.69: token = assert(assert.61, or.68, message="State element written before read in same activation.", id=69) - or.72: bits[1] = or(not.70, not.71, id=72) - add.66: bits[32] = add(c, literal.65, id=66) - tuple.12: () = tuple(id=12) - literal.34: bits[32] = literal(value=1, id=34) - literal.38: bits[32] = literal(value=0, id=38) - or.52: bits[1] = or(literal.3, literal.11, id=52) - next_value.53: () = next_value(param=__state_0, value=new_a, predicate=literal.11, id=53) - tuple.54: () = tuple(id=54) - or.62: bits[1] = or(literal.5, literal.11, id=62) - next_value.63: () = next_value(param=__state_1, value=new_b, predicate=literal.11, id=63) - tuple.64: () = tuple(id=64) - assert.73: token = assert(assert.69, or.72, message="State element written after write in same activation.", id=73) - or.74: bits[1] = or(literal.7, literal.11, id=74) - next_value.75: () = next_value(param=__state_2, value=add.66, predicate=literal.11, id=75) - tuple.76: () = tuple(id=76) - tuple.77: () = tuple(id=77) + or.25: bits[1] = or(not.24, literal.2, id=25) + not.29: bits[1] = not(literal.2, id=29) + add.12: bits[32] = add(a_x, literal.11, id=12) + add.15: bits[32] = add(tuple_index.14, c, id=15) + add.20: bits[32] = add(tuple_index.18, literal.19, id=20) + add.22: bits[32] = add(c, literal.21, id=22) + assert.26: token = assert(__token, or.25, message="State element written before read in same activation.", id=26) + or.30: bits[1] = or(not.29, literal.2, id=30) + not.36: bits[1] = not(literal.2, id=36) + literal.34: bits[32] = literal(value=2, id=34) + new_a: (bits[32], bits[32]) = tuple(add.12, add.15, id=16) + new_b: (bits[32], bits[32]) = tuple(add.20, add.22, id=23) + assert.31: token = assert(assert.26, or.30, message="State element written before read in same activation.", id=31) + or.37: bits[1] = or(not.36, literal.2, id=37) + add.35: bits[32] = add(c, literal.34, id=35) + tuple.3: () = tuple(id=3) + literal.13: bits[32] = literal(value=1, id=13) + literal.17: bits[32] = literal(value=0, id=17) + next_value.27: () = next_value(param=__state_0, value=new_a, predicate=literal.2, id=27) + tuple.28: () = tuple(id=28) + next_value.32: () = next_value(param=__state_1, value=new_b, predicate=literal.2, id=32) + tuple.33: () = tuple(id=33) + assert.38: token = assert(assert.31, or.37, message="State element written before read in same activation.", id=38) + next_value.39: () = next_value(param=__state_2, value=add.35, predicate=literal.2, id=39) + tuple.40: () = tuple(id=40) + tuple.41: () = tuple(id=41) } diff --git a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStatesMultipleReads.ir b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStatesMultipleReads.ir index f58bf2d2f6..71d30c116a 100644 --- a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStatesMultipleReads.ir +++ b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStatesMultipleReads.ir @@ -3,26 +3,17 @@ package test_module file_number 0 "test_module.x" top proc __test_module__main_0_next<>(__state_0: bits[32], __state_1: bits[32], init={0, 1}) { - literal.8: bits[1] = literal(value=1, id=8) - literal.4: bits[1] = literal(value=0, id=4) - not.10: bits[1] = not(literal.8, id=10) - not.11: bits[1] = not(literal.4, id=11) - or.14: bits[1] = or(literal.4, literal.8, id=14) + literal.2: bits[1] = literal(value=1, id=2) + not.6: bits[1] = not(literal.2, id=6) + not.7: bits[1] = not(literal.2, id=7) + __state_1: bits[32] = state_read(state_element=__state_1, predicate=literal.2, id=4) __token: token = literal(value=token, id=1) - or.12: bits[1] = or(not.10, not.11, id=12) - not.16: bits[1] = not(literal.8, id=16) - not.17: bits[1] = not(or.14, id=17) - __state_1: bits[32] = state_read(state_element=__state_1, id=7) - assert.13: token = assert(__token, or.12, message="State element read after read in same activation.", id=13) - or.18: bits[1] = or(not.16, not.17, id=18) - literal.2: bits[1] = literal(value=0, id=2) - literal.3: bits[1] = literal(value=0, id=3) - literal.5: bits[1] = literal(value=0, id=5) - __state_0: bits[32] = state_read(state_element=__state_0, id=6) - tuple.9: () = tuple(id=9) - b_0: bits[32] = identity(__state_1, id=15) - assert.19: token = assert(assert.13, or.18, message="State element read after read in same activation.", id=19) - or.20: bits[1] = or(or.14, literal.8, id=20) - b_1: bits[32] = identity(__state_1, id=21) - tuple.22: () = tuple(id=22) + or.8: bits[1] = or(not.6, not.7, id=8) + __state_1__1: bits[32] = state_read(state_element=__state_1, predicate=literal.2, id=10) + tuple.3: () = tuple(id=3) + b_0: bits[32] = identity(__state_1, id=5) + assert.9: token = assert(__token, or.8, message="State element read after read in same activation.", id=9) + b_1: bits[32] = identity(__state_1__1, id=11) + or.12: bits[1] = or(literal.2, literal.2, id=12) + tuple.13: () = tuple(id=13) } diff --git a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStatesMultipleWrites.ir b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStatesMultipleWrites.ir index 009d02b1c5..c7734662f5 100644 --- a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStatesMultipleWrites.ir +++ b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStatesMultipleWrites.ir @@ -3,49 +3,30 @@ package test_module file_number 0 "test_module.x" top proc __test_module__main_0_next<>(__state_0: bits[32], __state_1: bits[32], init={0, 1}) { - literal.8: bits[1] = literal(value=1, id=8) - literal.2: bits[1] = literal(value=0, id=2) - not.10: bits[1] = not(literal.8, id=10) - not.11: bits[1] = not(literal.2, id=11) - literal.4: bits[1] = literal(value=0, id=4) + literal.2: bits[1] = literal(value=1, id=2) + not.9: bits[1] = not(literal.2, id=9) + __state_0: bits[32] = state_read(state_element=__state_0, predicate=literal.2, id=4) + __state_1: bits[32] = state_read(state_element=__state_1, predicate=literal.2, id=6) __token: token = literal(value=token, id=1) - or.12: bits[1] = or(not.10, not.11, id=12) - not.16: bits[1] = not(literal.8, id=16) - not.17: bits[1] = not(literal.4, id=17) - assert.13: token = assert(__token, or.12, message="State element read after read in same activation.", id=13) - or.18: bits[1] = or(not.16, not.17, id=18) - not.23: bits[1] = not(literal.8, id=23) - or.20: bits[1] = or(literal.4, literal.8, id=20) - literal.5: bits[1] = literal(value=0, id=5) - assert.19: token = assert(assert.13, or.18, message="State element read after read in same activation.", id=19) - or.24: bits[1] = or(not.23, or.20, id=24) - not.26: bits[1] = not(literal.8, id=26) - not.27: bits[1] = not(literal.5, id=27) - __state_0: bits[32] = state_read(state_element=__state_0, id=6) - __state_1: bits[32] = state_read(state_element=__state_1, id=7) - assert.25: token = assert(assert.19, or.24, message="State element written before read in same activation.", id=25) - or.28: bits[1] = or(not.26, not.27, id=28) - not.35: bits[1] = not(literal.8, id=35) - or.30: bits[1] = or(literal.5, literal.8, id=30) - a: bits[32] = identity(__state_0, id=15) - b: bits[32] = identity(__state_1, id=21) - assert.29: token = assert(assert.25, or.28, message="State element written after write in same activation.", id=29) - or.36: bits[1] = or(not.35, or.20, id=36) - not.38: bits[1] = not(literal.8, id=38) - not.39: bits[1] = not(or.30, id=39) - literal.33: bits[32] = literal(value=1, id=33) - add.22: bits[32] = add(a, b, id=22) - assert.37: token = assert(assert.29, or.36, message="State element written before read in same activation.", id=37) - or.40: bits[1] = or(not.38, not.39, id=40) - add.34: bits[32] = add(a, literal.33, id=34) - literal.3: bits[1] = literal(value=0, id=3) - tuple.9: () = tuple(id=9) - or.14: bits[1] = or(literal.2, literal.8, id=14) - next_value.31: () = next_value(param=__state_1, value=add.22, predicate=literal.8, id=31) - tuple.32: () = tuple(id=32) - assert.41: token = assert(assert.37, or.40, message="State element written after write in same activation.", id=41) - or.42: bits[1] = or(or.30, literal.8, id=42) - next_value.43: () = next_value(param=__state_1, value=add.34, predicate=literal.8, id=43) - tuple.44: () = tuple(id=44) - tuple.45: () = tuple(id=45) + or.10: bits[1] = or(not.9, literal.2, id=10) + not.16: bits[1] = not(literal.2, id=16) + a: bits[32] = identity(__state_0, id=5) + b: bits[32] = identity(__state_1, id=7) + assert.11: token = assert(__token, or.10, message="State element written before read in same activation.", id=11) + or.17: bits[1] = or(not.16, literal.2, id=17) + not.19: bits[1] = not(literal.2, id=19) + not.20: bits[1] = not(literal.2, id=20) + literal.14: bits[32] = literal(value=1, id=14) + add.8: bits[32] = add(a, b, id=8) + assert.18: token = assert(assert.11, or.17, message="State element written before read in same activation.", id=18) + or.21: bits[1] = or(not.19, not.20, id=21) + add.15: bits[32] = add(a, literal.14, id=15) + tuple.3: () = tuple(id=3) + next_value.12: () = next_value(param=__state_1, value=add.8, predicate=literal.2, id=12) + tuple.13: () = tuple(id=13) + assert.22: token = assert(assert.18, or.21, message="State element written after write in same activation.", id=22) + or.23: bits[1] = or(literal.2, literal.2, id=23) + next_value.24: () = next_value(param=__state_1, value=add.15, predicate=literal.2, id=24) + tuple.25: () = tuple(id=25) + tuple.26: () = tuple(id=26) } diff --git a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStatesWriteBeforeRead.ir b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStatesWriteBeforeRead.ir index 93dce8c99c..948e497744 100644 --- a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStatesWriteBeforeRead.ir +++ b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleStatesWriteBeforeRead.ir @@ -3,30 +3,14 @@ package test_module file_number 0 "test_module.x" top proc __test_module__main_0_next<>(__state_0: bits[32], __state_1: bits[32], init={0, 1}) { - literal.8: bits[1] = literal(value=1, id=8) - literal.2: bits[1] = literal(value=0, id=2) - not.10: bits[1] = not(literal.8, id=10) - not.11: bits[1] = not(literal.2, id=11) + literal.2: bits[1] = literal(value=1, id=2) + __state_0: bits[32] = state_read(state_element=__state_0, predicate=literal.2, id=4) __token: token = literal(value=token, id=1) - or.12: bits[1] = or(not.10, not.11, id=12) - not.16: bits[1] = not(literal.8, id=16) - literal.4: bits[1] = literal(value=0, id=4) - literal.5: bits[1] = literal(value=0, id=5) - assert.13: token = assert(__token, or.12, message="State element read after read in same activation.", id=13) - or.17: bits[1] = or(not.16, literal.4, id=17) - not.19: bits[1] = not(literal.8, id=19) - not.20: bits[1] = not(literal.5, id=20) - __state_0: bits[32] = state_read(state_element=__state_0, id=6) - assert.18: token = assert(assert.13, or.17, message="State element written before read in same activation.", id=18) - or.21: bits[1] = or(not.19, not.20, id=21) - __state_1: bits[32] = state_read(state_element=__state_1, id=7) - a: bits[32] = identity(__state_0, id=15) - literal.3: bits[1] = literal(value=0, id=3) + not.6: bits[1] = not(literal.2, id=6) + a: bits[32] = identity(__state_0, id=5) + tuple.3: () = tuple(id=3) + assert.7: token = assert(__token, not.6, message="State element written before read in same activation.", id=7) + next_value.8: () = next_value(param=__state_1, value=a, predicate=literal.2, id=8) tuple.9: () = tuple(id=9) - or.14: bits[1] = or(literal.2, literal.8, id=14) - assert.22: token = assert(assert.18, or.21, message="State element written after write in same activation.", id=22) - or.23: bits[1] = or(literal.5, literal.8, id=23) - next_value.24: () = next_value(param=__state_1, value=a, predicate=literal.8, id=24) - tuple.25: () = tuple(id=25) - tuple.26: () = tuple(id=26) + tuple.10: () = tuple(id=10) } diff --git a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleWrites.ir b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleWrites.ir index 60acb57ff4..d84a108cb6 100644 --- a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleWrites.ir +++ b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessMultipleWrites.ir @@ -3,41 +3,29 @@ package test_module file_number 0 "test_module.x" top proc __test_module__main_0_next<>(__state: bits[32], init={0}) { - literal.5: bits[1] = literal(value=1, id=5) - literal.3: bits[1] = literal(value=0, id=3) - not.7: bits[1] = not(literal.5, id=7) - not.8: bits[1] = not(literal.3, id=8) + literal.2: bits[1] = literal(value=1, id=2) + not.8: bits[1] = not(literal.2, id=8) + __state: bits[32] = state_read(state_element=__state, predicate=literal.2, id=4) __token: token = literal(value=token, id=1) - or.9: bits[1] = or(not.7, not.8, id=9) - not.15: bits[1] = not(literal.5, id=15) - or.11: bits[1] = or(literal.3, literal.5, id=11) - literal.4: bits[1] = literal(value=0, id=4) - assert.10: token = assert(__token, or.9, message="State element read after read in same activation.", id=10) - or.16: bits[1] = or(not.15, or.11, id=16) - not.18: bits[1] = not(literal.5, id=18) - not.19: bits[1] = not(literal.4, id=19) - __state: bits[32] = state_read(state_element=__state, id=2) + or.9: bits[1] = or(not.8, literal.2, id=9) + not.15: bits[1] = not(literal.2, id=15) + identity.5: bits[32] = identity(__state, id=5) + literal.6: bits[32] = literal(value=1, id=6) + assert.10: token = assert(__token, or.9, message="State element written before read in same activation.", id=10) + or.16: bits[1] = or(not.15, literal.2, id=16) + not.18: bits[1] = not(literal.2, id=18) + not.19: bits[1] = not(literal.2, id=19) + accum: bits[32] = add(identity.5, literal.6, id=7) + literal.13: bits[32] = literal(value=1, id=13) assert.17: token = assert(assert.10, or.16, message="State element written before read in same activation.", id=17) or.20: bits[1] = or(not.18, not.19, id=20) - not.27: bits[1] = not(literal.5, id=27) - or.22: bits[1] = or(literal.4, literal.5, id=22) - identity.12: bits[32] = identity(__state, id=12) - literal.13: bits[32] = literal(value=1, id=13) + accum__1: bits[32] = add(accum, literal.13, id=14) + tuple.3: () = tuple(id=3) + next_value.11: () = next_value(param=__state, value=accum, predicate=literal.2, id=11) + tuple.12: () = tuple(id=12) assert.21: token = assert(assert.17, or.20, message="State element written after write in same activation.", id=21) - or.28: bits[1] = or(not.27, or.11, id=28) - not.30: bits[1] = not(literal.5, id=30) - not.31: bits[1] = not(or.22, id=31) - accum: bits[32] = add(identity.12, literal.13, id=14) - literal.25: bits[32] = literal(value=1, id=25) - assert.29: token = assert(assert.21, or.28, message="State element written before read in same activation.", id=29) - or.32: bits[1] = or(not.30, not.31, id=32) - accum__1: bits[32] = add(accum, literal.25, id=26) - tuple.6: () = tuple(id=6) - next_value.23: () = next_value(param=__state, value=accum, predicate=literal.5, id=23) + or.22: bits[1] = or(literal.2, literal.2, id=22) + next_value.23: () = next_value(param=__state, value=accum__1, predicate=literal.2, id=23) tuple.24: () = tuple(id=24) - assert.33: token = assert(assert.29, or.32, message="State element written after write in same activation.", id=33) - or.34: bits[1] = or(or.22, literal.5, id=34) - next_value.35: () = next_value(param=__state, value=accum__1, predicate=literal.5, id=35) - tuple.36: () = tuple(id=36) - tuple.37: () = tuple(id=37) + tuple.25: () = tuple(id=25) } diff --git a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessReadWithLabeledRead.ir b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessReadWithLabeledRead.ir index 14cca82c27..eebeb4e3c7 100644 --- a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessReadWithLabeledRead.ir +++ b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessReadWithLabeledRead.ir @@ -3,36 +3,25 @@ package test_module file_number 0 "test_module.x" top proc __test_module__main_0_next<>(__state: bits[32], init={0}) { - literal.5: bits[1] = literal(value=1, id=5) - literal.3: bits[1] = literal(value=0, id=3) - not.7: bits[1] = not(literal.5, id=7) - not.8: bits[1] = not(literal.3, id=8) - or.11: bits[1] = or(literal.3, literal.5, id=11) + literal.2: bits[1] = literal(value=1, id=2) + __state__1: bits[32] = state_read(state_element=__state, predicate=literal.2, label="main_read", id=10) + not.6: bits[1] = not(literal.2, id=6) + not.7: bits[1] = not(literal.2, id=7) + x: bits[32] = identity(__state__1, id=11) + literal.13: bits[32] = literal(value=1, id=13) + __state: bits[32] = state_read(state_element=__state, predicate=literal.2, id=4) __token: token = literal(value=token, id=1) - or.9: bits[1] = or(not.7, not.8, id=9) - not.13: bits[1] = not(literal.5, id=13) - not.14: bits[1] = not(or.11, id=14) - __state: bits[32] = state_read(state_element=__state, label="main_read", id=2) - assert.10: token = assert(__token, or.9, message="State element read after read in same activation.", id=10) - or.15: bits[1] = or(not.13, not.14, id=15) - not.22: bits[1] = not(literal.5, id=22) - or.17: bits[1] = or(or.11, literal.5, id=17) - literal.4: bits[1] = literal(value=0, id=4) - x: bits[32] = identity(__state, id=18) - literal.19: bits[32] = literal(value=1, id=19) - assert.16: token = assert(assert.10, or.15, message="State element read after read in same activation.", id=16) - or.23: bits[1] = or(not.22, or.17, id=23) - not.25: bits[1] = not(literal.5, id=25) - not.26: bits[1] = not(literal.4, id=26) - add.20: bits[32] = add(x, literal.19, id=20) - curr: bits[32] = identity(__state, id=12) - assert.24: token = assert(assert.16, or.23, message="State element written before read in same activation.", id=24) - or.27: bits[1] = or(not.25, not.26, id=27) - y: bits[32] = add(add.20, curr, id=21) - tuple.6: () = tuple(id=6) - assert.28: token = assert(assert.24, or.27, message="State element written after write in same activation.", id=28) - or.29: bits[1] = or(literal.4, literal.5, id=29) - next_value.30: () = next_value(param=__state, value=y, predicate=literal.5, label="main_write", id=30) - tuple.31: () = tuple(id=31) - tuple.32: () = tuple(id=32) + or.8: bits[1] = or(not.6, not.7, id=8) + not.16: bits[1] = not(literal.2, id=16) + or.12: bits[1] = or(literal.2, literal.2, id=12) + add.14: bits[32] = add(x, literal.13, id=14) + curr: bits[32] = identity(__state, id=5) + assert.9: token = assert(__token, or.8, message="State element read after read in same activation.", id=9) + or.17: bits[1] = or(not.16, or.12, id=17) + y: bits[32] = add(add.14, curr, id=15) + tuple.3: () = tuple(id=3) + assert.18: token = assert(assert.9, or.17, message="State element written before read in same activation.", id=18) + next_value.19: () = next_value(param=__state, value=y, predicate=literal.2, label="main_write", id=19) + tuple.20: () = tuple(id=20) + tuple.21: () = tuple(id=21) } diff --git a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessWriteBeforeRead.ir b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessWriteBeforeRead.ir index 020c9c01e2..cd75f578a5 100644 --- a/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessWriteBeforeRead.ir +++ b/xls/interpreter/testdata/serial_proc_runtime_test_ExplicitStateAccessWriteBeforeRead.ir @@ -3,22 +3,13 @@ package test_module file_number 0 "test_module.x" top proc __test_module__main_0_next<>(__state: bits[32], init={0}) { - literal.5: bits[1] = literal(value=1, id=5) - not.8: bits[1] = not(literal.5, id=8) - literal.3: bits[1] = literal(value=0, id=3) - literal.4: bits[1] = literal(value=0, id=4) + literal.2: bits[1] = literal(value=1, id=2) __token: token = literal(value=token, id=1) - or.9: bits[1] = or(not.8, literal.3, id=9) - not.11: bits[1] = not(literal.5, id=11) - not.12: bits[1] = not(literal.4, id=12) - assert.10: token = assert(__token, or.9, message="State element written before read in same activation.", id=10) - or.13: bits[1] = or(not.11, not.12, id=13) - __state: bits[32] = state_read(state_element=__state, id=2) - literal.7: bits[32] = literal(value=1, id=7) - tuple.6: () = tuple(id=6) - assert.14: token = assert(assert.10, or.13, message="State element written after write in same activation.", id=14) - or.15: bits[1] = or(literal.4, literal.5, id=15) - next_value.16: () = next_value(param=__state, value=literal.7, predicate=literal.5, id=16) - tuple.17: () = tuple(id=17) - tuple.18: () = tuple(id=18) + not.5: bits[1] = not(literal.2, id=5) + literal.4: bits[32] = literal(value=1, id=4) + tuple.3: () = tuple(id=3) + assert.6: token = assert(__token, not.5, message="State element written before read in same activation.", id=6) + next_value.7: () = next_value(param=__state, value=literal.4, predicate=literal.2, id=7) + tuple.8: () = tuple(id=8) + tuple.9: () = tuple(id=9) }