Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions xls/interpreter/serial_proc_runtime_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
@@ -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)
}
Loading
Loading