From a8a541b35723b4dbc936d99978ffc489f65301cf Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Tue, 24 Mar 2026 23:26:47 -0700 Subject: [PATCH] sim/compiler: fix registers so they properly retain their old value when not written --- crates/fayalite/src/sim/compiler.rs | 9 + .../tests/sim/expected/counter_async.txt | 34 ++-- .../tests/sim/expected/counter_sync.txt | 44 ++--- crates/fayalite/tests/sim/expected/enums.txt | 90 +++++----- .../tests/sim/expected/ripple_counter.txt | 165 ++++++++++-------- .../tests/sim/expected/shift_register.txt | 113 +++++++----- .../tests/sim/expected/sim_only_connects.txt | 101 ++++++----- 7 files changed, 311 insertions(+), 245 deletions(-) diff --git a/crates/fayalite/src/sim/compiler.rs b/crates/fayalite/src/sim/compiler.rs index 07621c5..e85ff0f 100644 --- a/crates/fayalite/src/sim/compiler.rs +++ b/crates/fayalite/src/sim/compiler.rs @@ -4087,6 +4087,15 @@ impl Compiler { let init = self.compiled_expr_to_value(init, reg.source_location()); (reg.clock_domain().rst, init) }); + + // next value defaults to current value + self.compile_simple_connect( + [].intern_slice(), + value.into(), + value, + reg.source_location(), + ); + self.compile_reg( clk, reset_and_init, diff --git a/crates/fayalite/tests/sim/expected/counter_async.txt b/crates/fayalite/tests/sim/expected/counter_async.txt index 86bde88..2bdd665 100644 --- a/crates/fayalite/tests/sim/expected/counter_async.txt +++ b/crates/fayalite/tests/sim/expected/counter_async.txt @@ -123,58 +123,62 @@ Simulation { dest: StatePartIndex(3), // (0x3) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg", ty: UInt<4> }, src: StatePartIndex(5), // (0x3) SlotDebugData { name: "", ty: UInt<4> }, }, + 8: Copy { + dest: StatePartIndex(4), // (0x4) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg$next", ty: UInt<4> }, + src: StatePartIndex(3), // (0x3) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg", ty: UInt<4> }, + }, // at: module-XXXXXXXXXX.rs:1:1 - 8: Add { + 9: Add { dest: StatePartIndex(8), // (0x4) SlotDebugData { name: "", ty: UInt<5> }, lhs: StatePartIndex(3), // (0x3) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg", ty: UInt<4> }, rhs: StatePartIndex(7), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, }, - 9: CastToUInt { + 10: CastToUInt { dest: StatePartIndex(9), // (0x4) SlotDebugData { name: "", ty: UInt<4> }, src: StatePartIndex(8), // (0x4) SlotDebugData { name: "", ty: UInt<5> }, dest_width: 4, }, // at: module-XXXXXXXXXX.rs:4:1 - 10: Copy { + 11: Copy { dest: StatePartIndex(4), // (0x4) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg$next", ty: UInt<4> }, src: StatePartIndex(9), // (0x4) SlotDebugData { name: "", ty: UInt<4> }, }, // at: module-XXXXXXXXXX.rs:6:1 - 11: Copy { + 12: Copy { dest: StatePartIndex(2), // (0x3) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count", ty: UInt<4> }, src: StatePartIndex(3), // (0x3) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg", ty: UInt<4> }, }, // at: module-XXXXXXXXXX.rs:3:1 - 12: BranchIfSmallNonZero { - target: 16, + 13: BranchIfSmallNonZero { + target: 17, value: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 13: BranchIfSmallZero { - target: 17, + 14: BranchIfSmallZero { + target: 18, value: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 14: Copy { + 15: Copy { dest: StatePartIndex(3), // (0x3) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg", ty: UInt<4> }, src: StatePartIndex(4), // (0x4) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg$next", ty: UInt<4> }, }, - 15: Branch { - target: 17, + 16: Branch { + target: 18, }, - 16: Copy { + 17: Copy { dest: StatePartIndex(3), // (0x3) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg", ty: UInt<4> }, src: StatePartIndex(5), // (0x3) SlotDebugData { name: "", ty: UInt<4> }, }, - 17: XorSmallImmediate { + 18: XorSmallImmediate { dest: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, rhs: 0x1, }, // at: module-XXXXXXXXXX.rs:1:1 - 18: Return, + 19: Return, ], .. }, - pc: 18, + pc: 19, memory_write_log: [], memories: StatePart { value: [], diff --git a/crates/fayalite/tests/sim/expected/counter_sync.txt b/crates/fayalite/tests/sim/expected/counter_sync.txt index 0a7517e..87c2098 100644 --- a/crates/fayalite/tests/sim/expected/counter_sync.txt +++ b/crates/fayalite/tests/sim/expected/counter_sync.txt @@ -102,61 +102,65 @@ Simulation { src: StatePartIndex(7), // (0x4) SlotDebugData { name: "", ty: UInt<5> }, dest_width: 4, }, - // at: module-XXXXXXXXXX.rs:4:1 - 4: Copy { - dest: StatePartIndex(4), // (0x4) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg$next", ty: UInt<4> }, - src: StatePartIndex(8), // (0x4) SlotDebugData { name: "", ty: UInt<4> }, - }, // at: module-XXXXXXXXXX.rs:3:1 - 5: IsNonZeroDestIsSmall { + 4: IsNonZeroDestIsSmall { dest: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(1), // (0x0) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::cd.rst", ty: SyncReset }, }, - 6: IsNonZeroDestIsSmall { + 5: IsNonZeroDestIsSmall { dest: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(0), // (0x1) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::cd.clk", ty: Clock }, }, - 7: AndSmall { + 6: AndSmall { dest: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, rhs: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, + 7: Copy { + dest: StatePartIndex(4), // (0x4) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg$next", ty: UInt<4> }, + src: StatePartIndex(3), // (0x3) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg", ty: UInt<4> }, + }, + // at: module-XXXXXXXXXX.rs:4:1 + 8: Copy { + dest: StatePartIndex(4), // (0x4) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg$next", ty: UInt<4> }, + src: StatePartIndex(8), // (0x4) SlotDebugData { name: "", ty: UInt<4> }, + }, // at: module-XXXXXXXXXX.rs:1:1 - 8: Const { + 9: Const { dest: StatePartIndex(5), // (0x3) SlotDebugData { name: "", ty: UInt<4> }, value: 0x3, }, // at: module-XXXXXXXXXX.rs:3:1 - 9: BranchIfSmallZero { - target: 14, + 10: BranchIfSmallZero { + target: 15, value: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 10: BranchIfSmallNonZero { - target: 13, + 11: BranchIfSmallNonZero { + target: 14, value: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 11: Copy { + 12: Copy { dest: StatePartIndex(3), // (0x3) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg", ty: UInt<4> }, src: StatePartIndex(4), // (0x4) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg$next", ty: UInt<4> }, }, - 12: Branch { - target: 14, + 13: Branch { + target: 15, }, - 13: Copy { + 14: Copy { dest: StatePartIndex(3), // (0x3) SlotDebugData { name: "InstantiatedModule(counter: counter).counter::count_reg", ty: UInt<4> }, src: StatePartIndex(5), // (0x3) SlotDebugData { name: "", ty: UInt<4> }, }, - 14: XorSmallImmediate { + 15: XorSmallImmediate { dest: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, rhs: 0x1, }, // at: module-XXXXXXXXXX.rs:1:1 - 15: Return, + 16: Return, ], .. }, - pc: 15, + pc: 16, memory_write_log: [], memories: StatePart { value: [], diff --git a/crates/fayalite/tests/sim/expected/enums.txt b/crates/fayalite/tests/sim/expected/enums.txt index a193e92..a3a52cb 100644 --- a/crates/fayalite/tests/sim/expected/enums.txt +++ b/crates/fayalite/tests/sim/expected/enums.txt @@ -1012,173 +1012,177 @@ Simulation { lhs: StatePartIndex(4), // (0x1 1) SlotDebugData { name: "", ty: Bool }, rhs: StatePartIndex(2), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, + 99: Copy { + dest: StatePartIndex(24), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + src: StatePartIndex(23), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + }, // at: module-XXXXXXXXXX.rs:1:1 - 99: Const { + 100: Const { dest: StatePartIndex(25), // (0x0) SlotDebugData { name: "", ty: UInt<6> }, value: 0x0, }, - 100: Copy { + 101: Copy { dest: StatePartIndex(26), // (0x0) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, src: StatePartIndex(25), // (0x0) SlotDebugData { name: "", ty: UInt<6> }, }, // at: module-XXXXXXXXXX.rs:12:1 - 101: BranchIfZero { - target: 109, + 102: BranchIfZero { + target: 110, value: StatePartIndex(2), // (0x1) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::en", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:13:1 - 102: BranchIfZero { - target: 104, + 103: BranchIfZero { + target: 105, value: StatePartIndex(46), // (0x0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:14:1 - 103: Copy { + 104: Copy { dest: StatePartIndex(24), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, src: StatePartIndex(26), // (0x0) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, }, // at: module-XXXXXXXXXX.rs:13:1 - 104: BranchIfNonZero { - target: 109, + 105: BranchIfNonZero { + target: 110, value: StatePartIndex(46), // (0x0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:15:1 - 105: BranchIfZero { - target: 107, + 106: BranchIfZero { + target: 108, value: StatePartIndex(48), // (0x0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:16:1 - 106: Copy { + 107: Copy { dest: StatePartIndex(24), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, src: StatePartIndex(65), // (0xd) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, }, // at: module-XXXXXXXXXX.rs:15:1 - 107: BranchIfNonZero { - target: 109, + 108: BranchIfNonZero { + target: 110, value: StatePartIndex(48), // (0x0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:17:1 - 108: Copy { + 109: Copy { dest: StatePartIndex(24), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, src: StatePartIndex(87), // (0x3e) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, }, // at: module-XXXXXXXXXX.rs:10:1 - 109: Copy { + 110: Copy { dest: StatePartIndex(15), // (0x0) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::b2_out", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, src: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::b_out", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, }, // at: module-XXXXXXXXXX.rs:1:1 - 110: Copy { + 111: Copy { dest: StatePartIndex(18), // (0x0) SlotDebugData { name: "", ty: UInt<3> }, src: StatePartIndex(15), // (0x0) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::b2_out", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, }, - 111: SliceInt { + 112: SliceInt { dest: StatePartIndex(19), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, src: StatePartIndex(18), // (0x0) SlotDebugData { name: "", ty: UInt<3> }, start: 1, len: 2, }, - 112: SliceInt { + 113: SliceInt { dest: StatePartIndex(20), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, src: StatePartIndex(19), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, start: 0, len: 1, }, - 113: SliceInt { + 114: SliceInt { dest: StatePartIndex(21), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, src: StatePartIndex(19), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, start: 1, len: 1, }, - 114: Copy { + 115: Copy { dest: StatePartIndex(22), // (0x0) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(21), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, }, - 115: Copy { + 116: Copy { dest: StatePartIndex(16), // (0x0) SlotDebugData { name: ".0", ty: UInt<1> }, src: StatePartIndex(20), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, }, - 116: Copy { + 117: Copy { dest: StatePartIndex(17), // (0x0) SlotDebugData { name: ".1", ty: Bool }, src: StatePartIndex(22), // (0x0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:9:1 - 117: AndBigWithSmallImmediate { + 118: AndBigWithSmallImmediate { dest: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Enum {HdlNone, HdlSome} }, lhs: StatePartIndex(15), // (0x0) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::b2_out", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, rhs: 0x1, }, // at: module-XXXXXXXXXX.rs:1:1 - 118: Copy { + 119: Copy { dest: StatePartIndex(10), // (0x0) SlotDebugData { name: "", ty: UInt<3> }, src: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::b_out", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, }, - 119: SliceInt { + 120: SliceInt { dest: StatePartIndex(11), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, src: StatePartIndex(10), // (0x0) SlotDebugData { name: "", ty: UInt<3> }, start: 1, len: 2, }, - 120: SliceInt { + 121: SliceInt { dest: StatePartIndex(12), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, src: StatePartIndex(11), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, start: 0, len: 1, }, - 121: SliceInt { + 122: SliceInt { dest: StatePartIndex(13), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, src: StatePartIndex(11), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, start: 1, len: 1, }, - 122: Copy { + 123: Copy { dest: StatePartIndex(14), // (0x0) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(13), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, }, - 123: Copy { + 124: Copy { dest: StatePartIndex(8), // (0x0) SlotDebugData { name: ".0", ty: UInt<1> }, src: StatePartIndex(12), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, }, - 124: Copy { + 125: Copy { dest: StatePartIndex(9), // (0x0) SlotDebugData { name: ".1", ty: Bool }, src: StatePartIndex(14), // (0x0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:8:1 - 125: AndBigWithSmallImmediate { + 126: AndBigWithSmallImmediate { dest: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Enum {HdlNone, HdlSome} }, lhs: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::b_out", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, rhs: 0x1, }, // at: module-XXXXXXXXXX.rs:11:1 - 126: BranchIfSmallZero { - target: 131, + 127: BranchIfSmallZero { + target: 132, value: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 127: BranchIfSmallNonZero { - target: 130, + 128: BranchIfSmallNonZero { + target: 131, value: StatePartIndex(5), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 128: Copy { + 129: Copy { dest: StatePartIndex(23), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, src: StatePartIndex(24), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, }, - 129: Branch { - target: 131, + 130: Branch { + target: 132, }, - 130: Copy { + 131: Copy { dest: StatePartIndex(23), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, src: StatePartIndex(26), // (0x0) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, }, - 131: XorSmallImmediate { + 132: XorSmallImmediate { dest: StatePartIndex(2), // (0x0 0) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(4), // (0x1 1) SlotDebugData { name: "", ty: Bool }, rhs: 0x1, }, // at: module-XXXXXXXXXX.rs:1:1 - 132: Return, + 133: Return, ], .. }, - pc: 132, + pc: 133, memory_write_log: [], memories: StatePart { value: [], diff --git a/crates/fayalite/tests/sim/expected/ripple_counter.txt b/crates/fayalite/tests/sim/expected/ripple_counter.txt index 2be69b5..1fb5fee 100644 --- a/crates/fayalite/tests/sim/expected/ripple_counter.txt +++ b/crates/fayalite/tests/sim/expected/ripple_counter.txt @@ -314,55 +314,56 @@ Simulation { src: StatePartIndex(47), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_4", ty: Bool }, width: 1, }, - // at: module-XXXXXXXXXX.rs:8:1 - 3: Copy { - dest: StatePartIndex(48), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_4$next", ty: Bool }, - src: StatePartIndex(52), // (0x1) SlotDebugData { name: "", ty: Bool }, - }, // at: module-XXXXXXXXXX.rs:7:1 - 4: Copy { + 3: Copy { dest: StatePartIndex(6), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[4]", ty: Bool }, src: StatePartIndex(47), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_4", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:1:1 - 5: Copy { + 4: Copy { dest: StatePartIndex(57), // (0x0) SlotDebugData { name: "", ty: Clock }, src: StatePartIndex(6), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[4]", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:10:1 - 6: Copy { + 5: Copy { dest: StatePartIndex(53), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_5.clk", ty: Clock }, src: StatePartIndex(57), // (0x0) SlotDebugData { name: "", ty: Clock }, }, // at: module-XXXXXXXXXX.rs:9:1 - 7: Copy { + 6: Copy { dest: StatePartIndex(55), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter.bit_reg_5: sw_reg).sw_reg::clk", ty: Clock }, src: StatePartIndex(53), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_5.clk", ty: Clock }, }, + // at: module-XXXXXXXXXX.rs:6:1 + 7: Copy { + dest: StatePartIndex(48), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_4$next", ty: Bool }, + src: StatePartIndex(47), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_4", ty: Bool }, + }, + // at: module-XXXXXXXXXX.rs:8:1 8: Copy { + dest: StatePartIndex(48), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_4$next", ty: Bool }, + src: StatePartIndex(52), // (0x1) SlotDebugData { name: "", ty: Bool }, + }, + // at: module-XXXXXXXXXX.rs:9:1 + 9: Copy { dest: StatePartIndex(43), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_3.o", ty: Bool }, src: StatePartIndex(45), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter.bit_reg_3: sw_reg).sw_reg::o", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:11:1 - 9: Copy { + 10: Copy { dest: StatePartIndex(5), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[3]", ty: Bool }, src: StatePartIndex(43), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_3.o", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:1:1 - 10: Copy { + 11: Copy { dest: StatePartIndex(51), // (0x0) SlotDebugData { name: "", ty: Clock }, src: StatePartIndex(5), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[3]", ty: Bool }, }, - 11: NotU { + 12: NotU { dest: StatePartIndex(41), // (0x1) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(36), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_2", ty: Bool }, width: 1, }, - // at: module-XXXXXXXXXX.rs:8:1 - 12: Copy { - dest: StatePartIndex(37), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_2$next", ty: Bool }, - src: StatePartIndex(41), // (0x1) SlotDebugData { name: "", ty: Bool }, - }, // at: module-XXXXXXXXXX.rs:7:1 13: Copy { dest: StatePartIndex(4), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[2]", ty: Bool }, @@ -383,241 +384,257 @@ Simulation { dest: StatePartIndex(44), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter.bit_reg_3: sw_reg).sw_reg::clk", ty: Clock }, src: StatePartIndex(42), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_3.clk", ty: Clock }, }, + // at: module-XXXXXXXXXX.rs:6:1 17: Copy { + dest: StatePartIndex(37), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_2$next", ty: Bool }, + src: StatePartIndex(36), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_2", ty: Bool }, + }, + // at: module-XXXXXXXXXX.rs:8:1 + 18: Copy { + dest: StatePartIndex(37), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_2$next", ty: Bool }, + src: StatePartIndex(41), // (0x1) SlotDebugData { name: "", ty: Bool }, + }, + // at: module-XXXXXXXXXX.rs:9:1 + 19: Copy { dest: StatePartIndex(32), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_1.o", ty: Bool }, src: StatePartIndex(34), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter.bit_reg_1: sw_reg).sw_reg::o", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:11:1 - 18: Copy { + 20: Copy { dest: StatePartIndex(3), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[1]", ty: Bool }, src: StatePartIndex(32), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_1.o", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:1:1 - 19: Copy { + 21: Copy { dest: StatePartIndex(40), // (0x0) SlotDebugData { name: "", ty: Clock }, src: StatePartIndex(3), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[1]", ty: Bool }, }, - 20: NotU { + 22: NotU { dest: StatePartIndex(30), // (0x1) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(24), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_0", ty: Bool }, width: 1, }, - // at: module-XXXXXXXXXX.rs:8:1 - 21: Copy { - dest: StatePartIndex(25), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_0$next", ty: Bool }, - src: StatePartIndex(30), // (0x1) SlotDebugData { name: "", ty: Bool }, - }, // at: module-XXXXXXXXXX.rs:7:1 - 22: Copy { + 23: Copy { dest: StatePartIndex(2), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[0]", ty: Bool }, src: StatePartIndex(24), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_0", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:1:1 - 23: Copy { + 24: Copy { dest: StatePartIndex(35), // (0x0) SlotDebugData { name: "", ty: Clock }, src: StatePartIndex(2), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[0]", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:10:1 - 24: Copy { + 25: Copy { dest: StatePartIndex(31), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_1.clk", ty: Clock }, src: StatePartIndex(35), // (0x0) SlotDebugData { name: "", ty: Clock }, }, // at: module-XXXXXXXXXX.rs:9:1 - 25: Copy { + 26: Copy { dest: StatePartIndex(33), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter.bit_reg_1: sw_reg).sw_reg::clk", ty: Clock }, src: StatePartIndex(31), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_1.clk", ty: Clock }, }, + // at: module-XXXXXXXXXX.rs:6:1 + 27: Copy { + dest: StatePartIndex(25), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_0$next", ty: Bool }, + src: StatePartIndex(24), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_0", ty: Bool }, + }, + // at: module-XXXXXXXXXX.rs:8:1 + 28: Copy { + dest: StatePartIndex(25), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_0$next", ty: Bool }, + src: StatePartIndex(30), // (0x1) SlotDebugData { name: "", ty: Bool }, + }, // at: module-XXXXXXXXXX.rs:1:1 - 26: Const { + 29: Const { dest: StatePartIndex(28), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, value: 0x0, }, - 27: Copy { + 30: Copy { dest: StatePartIndex(29), // (0x0) SlotDebugData { name: "", ty: SyncReset }, src: StatePartIndex(28), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, }, - 28: Copy { + 31: Copy { dest: StatePartIndex(26), // (0x1) SlotDebugData { name: ".clk", ty: Clock }, src: StatePartIndex(0), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::clk", ty: Clock }, }, - 29: Copy { + 32: Copy { dest: StatePartIndex(27), // (0x0) SlotDebugData { name: ".rst", ty: SyncReset }, src: StatePartIndex(29), // (0x0) SlotDebugData { name: "", ty: SyncReset }, }, // at: module-XXXXXXXXXX.rs:6:1 - 30: IsNonZeroDestIsSmall { + 33: IsNonZeroDestIsSmall { dest: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(26), // (0x1) SlotDebugData { name: ".clk", ty: Clock }, }, - 31: AndSmall { + 34: AndSmall { dest: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, rhs: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:1:1 - 32: Copy { + 35: Copy { dest: StatePartIndex(38), // (0x0) SlotDebugData { name: ".clk", ty: Clock }, src: StatePartIndex(40), // (0x0) SlotDebugData { name: "", ty: Clock }, }, - 33: Copy { + 36: Copy { dest: StatePartIndex(39), // (0x0) SlotDebugData { name: ".rst", ty: SyncReset }, src: StatePartIndex(29), // (0x0) SlotDebugData { name: "", ty: SyncReset }, }, // at: module-XXXXXXXXXX.rs:6:1 - 34: IsNonZeroDestIsSmall { + 37: IsNonZeroDestIsSmall { dest: StatePartIndex(5), // (0x0 0) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(38), // (0x0) SlotDebugData { name: ".clk", ty: Clock }, }, - 35: AndSmall { + 38: AndSmall { dest: StatePartIndex(4), // (0x0 0) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(5), // (0x0 0) SlotDebugData { name: "", ty: Bool }, rhs: StatePartIndex(3), // (0x1 1) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:1:1 - 36: Copy { + 39: Copy { dest: StatePartIndex(49), // (0x0) SlotDebugData { name: ".clk", ty: Clock }, src: StatePartIndex(51), // (0x0) SlotDebugData { name: "", ty: Clock }, }, - 37: Copy { + 40: Copy { dest: StatePartIndex(50), // (0x0) SlotDebugData { name: ".rst", ty: SyncReset }, src: StatePartIndex(29), // (0x0) SlotDebugData { name: "", ty: SyncReset }, }, // at: module-XXXXXXXXXX.rs:6:1 - 38: IsNonZeroDestIsSmall { + 41: IsNonZeroDestIsSmall { dest: StatePartIndex(8), // (0x0 0) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(49), // (0x0) SlotDebugData { name: ".clk", ty: Clock }, }, - 39: AndSmall { + 42: AndSmall { dest: StatePartIndex(7), // (0x0 0) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(8), // (0x0 0) SlotDebugData { name: "", ty: Bool }, rhs: StatePartIndex(6), // (0x1 1) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:1:1 - 40: Copy { + 43: Copy { dest: StatePartIndex(21), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, src: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[5]", ty: Bool }, }, - 41: Shl { + 44: Shl { dest: StatePartIndex(22), // (0x0) SlotDebugData { name: "", ty: UInt<6> }, lhs: StatePartIndex(21), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, rhs: 5, }, - 42: Copy { + 45: Copy { dest: StatePartIndex(18), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, src: StatePartIndex(6), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[4]", ty: Bool }, }, - 43: Shl { + 46: Shl { dest: StatePartIndex(19), // (0x0) SlotDebugData { name: "", ty: UInt<5> }, lhs: StatePartIndex(18), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, rhs: 4, }, - 44: Copy { + 47: Copy { dest: StatePartIndex(15), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, src: StatePartIndex(5), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[3]", ty: Bool }, }, - 45: Shl { + 48: Shl { dest: StatePartIndex(16), // (0x0) SlotDebugData { name: "", ty: UInt<4> }, lhs: StatePartIndex(15), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, rhs: 3, }, - 46: Copy { + 49: Copy { dest: StatePartIndex(12), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, src: StatePartIndex(4), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[2]", ty: Bool }, }, - 47: Shl { + 50: Shl { dest: StatePartIndex(13), // (0x0) SlotDebugData { name: "", ty: UInt<3> }, lhs: StatePartIndex(12), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, rhs: 2, }, - 48: Copy { + 51: Copy { dest: StatePartIndex(9), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, src: StatePartIndex(3), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[1]", ty: Bool }, }, - 49: Shl { + 52: Shl { dest: StatePartIndex(10), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, lhs: StatePartIndex(9), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, rhs: 1, }, - 50: Copy { + 53: Copy { dest: StatePartIndex(8), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, src: StatePartIndex(2), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bits[0]", ty: Bool }, }, - 51: Or { + 54: Or { dest: StatePartIndex(11), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, lhs: StatePartIndex(8), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, rhs: StatePartIndex(10), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, }, - 52: Or { + 55: Or { dest: StatePartIndex(14), // (0x0) SlotDebugData { name: "", ty: UInt<3> }, lhs: StatePartIndex(11), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, rhs: StatePartIndex(13), // (0x0) SlotDebugData { name: "", ty: UInt<3> }, }, - 53: Or { + 56: Or { dest: StatePartIndex(17), // (0x0) SlotDebugData { name: "", ty: UInt<4> }, lhs: StatePartIndex(14), // (0x0) SlotDebugData { name: "", ty: UInt<3> }, rhs: StatePartIndex(16), // (0x0) SlotDebugData { name: "", ty: UInt<4> }, }, - 54: Or { + 57: Or { dest: StatePartIndex(20), // (0x0) SlotDebugData { name: "", ty: UInt<5> }, lhs: StatePartIndex(17), // (0x0) SlotDebugData { name: "", ty: UInt<4> }, rhs: StatePartIndex(19), // (0x0) SlotDebugData { name: "", ty: UInt<5> }, }, - 55: Or { + 58: Or { dest: StatePartIndex(23), // (0x0) SlotDebugData { name: "", ty: UInt<6> }, lhs: StatePartIndex(20), // (0x0) SlotDebugData { name: "", ty: UInt<5> }, rhs: StatePartIndex(22), // (0x0) SlotDebugData { name: "", ty: UInt<6> }, }, // at: module-XXXXXXXXXX.rs:5:1 - 56: Copy { + 59: Copy { dest: StatePartIndex(1), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::o", ty: UInt<6> }, src: StatePartIndex(23), // (0x0) SlotDebugData { name: "", ty: UInt<6> }, }, // at: module-XXXXXXXXXX.rs:6:1 - 57: BranchIfSmallZero { - target: 59, + 60: BranchIfSmallZero { + target: 62, value: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 58: Copy { + 61: Copy { dest: StatePartIndex(24), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_0", ty: Bool }, src: StatePartIndex(25), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_0$next", ty: Bool }, }, - 59: BranchIfSmallZero { - target: 61, + 62: BranchIfSmallZero { + target: 64, value: StatePartIndex(4), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 60: Copy { + 63: Copy { dest: StatePartIndex(36), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_2", ty: Bool }, src: StatePartIndex(37), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_2$next", ty: Bool }, }, - 61: BranchIfSmallZero { - target: 63, + 64: BranchIfSmallZero { + target: 66, value: StatePartIndex(7), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 62: Copy { + 65: Copy { dest: StatePartIndex(47), // (0x0) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_4", ty: Bool }, src: StatePartIndex(48), // (0x1) SlotDebugData { name: "InstantiatedModule(ripple_counter: ripple_counter).ripple_counter::bit_reg_4$next", ty: Bool }, }, - 63: XorSmallImmediate { + 66: XorSmallImmediate { dest: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, rhs: 0x1, }, - 64: XorSmallImmediate { + 67: XorSmallImmediate { dest: StatePartIndex(3), // (0x1 1) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(5), // (0x0 0) SlotDebugData { name: "", ty: Bool }, rhs: 0x1, }, - 65: XorSmallImmediate { + 68: XorSmallImmediate { dest: StatePartIndex(6), // (0x1 1) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(8), // (0x0 0) SlotDebugData { name: "", ty: Bool }, rhs: 0x1, }, // at: module-XXXXXXXXXX.rs:1:1 - 66: Return, + 69: Return, ], .. }, - pc: 66, + pc: 69, memory_write_log: [], memories: StatePart { value: [], diff --git a/crates/fayalite/tests/sim/expected/shift_register.txt b/crates/fayalite/tests/sim/expected/shift_register.txt index 7dcf26c..2e1b176 100644 --- a/crates/fayalite/tests/sim/expected/shift_register.txt +++ b/crates/fayalite/tests/sim/expected/shift_register.txt @@ -103,137 +103,156 @@ Simulation { dest: StatePartIndex(3), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::q", ty: Bool }, src: StatePartIndex(11), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg3", ty: Bool }, }, - // at: module-XXXXXXXXXX.rs:12:1 + // at: module-XXXXXXXXXX.rs:11:1 1: Copy { + dest: StatePartIndex(12), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg3$next", ty: Bool }, + src: StatePartIndex(11), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg3", ty: Bool }, + }, + // at: module-XXXXXXXXXX.rs:12:1 + 2: Copy { dest: StatePartIndex(12), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg3$next", ty: Bool }, src: StatePartIndex(9), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg2", ty: Bool }, }, + // at: module-XXXXXXXXXX.rs:9:1 + 3: Copy { + dest: StatePartIndex(10), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg2$next", ty: Bool }, + src: StatePartIndex(9), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg2", ty: Bool }, + }, // at: module-XXXXXXXXXX.rs:10:1 - 2: Copy { + 4: Copy { dest: StatePartIndex(10), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg2$next", ty: Bool }, src: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg1", ty: Bool }, }, + // at: module-XXXXXXXXXX.rs:7:1 + 5: Copy { + dest: StatePartIndex(8), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg1$next", ty: Bool }, + src: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg1", ty: Bool }, + }, // at: module-XXXXXXXXXX.rs:8:1 - 3: Copy { + 6: Copy { dest: StatePartIndex(8), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg1$next", ty: Bool }, src: StatePartIndex(4), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg0", ty: Bool }, }, - // at: module-XXXXXXXXXX.rs:6:1 - 4: Copy { - dest: StatePartIndex(5), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg0$next", ty: Bool }, - src: StatePartIndex(2), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::d", ty: Bool }, - }, // at: module-XXXXXXXXXX.rs:5:1 - 5: IsNonZeroDestIsSmall { + 7: IsNonZeroDestIsSmall { dest: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(1), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::cd.rst", ty: SyncReset }, }, - 6: IsNonZeroDestIsSmall { + 8: IsNonZeroDestIsSmall { dest: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(0), // (0x1) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::cd.clk", ty: Clock }, }, - 7: AndSmall { + 9: AndSmall { dest: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, rhs: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, + 10: Copy { + dest: StatePartIndex(5), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg0$next", ty: Bool }, + src: StatePartIndex(4), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg0", ty: Bool }, + }, + // at: module-XXXXXXXXXX.rs:6:1 + 11: Copy { + dest: StatePartIndex(5), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg0$next", ty: Bool }, + src: StatePartIndex(2), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::d", ty: Bool }, + }, // at: module-XXXXXXXXXX.rs:1:1 - 8: Const { + 12: Const { dest: StatePartIndex(6), // (0x0) SlotDebugData { name: "", ty: Bool }, value: 0x0, }, // at: module-XXXXXXXXXX.rs:5:1 - 9: BranchIfSmallZero { - target: 14, + 13: BranchIfSmallZero { + target: 18, value: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 10: BranchIfSmallNonZero { - target: 13, + 14: BranchIfSmallNonZero { + target: 17, value: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 11: Copy { + 15: Copy { dest: StatePartIndex(4), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg0", ty: Bool }, src: StatePartIndex(5), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg0$next", ty: Bool }, }, - 12: Branch { - target: 14, + 16: Branch { + target: 18, }, - 13: Copy { + 17: Copy { dest: StatePartIndex(4), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg0", ty: Bool }, src: StatePartIndex(6), // (0x0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:7:1 - 14: BranchIfSmallZero { - target: 19, + 18: BranchIfSmallZero { + target: 23, value: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 15: BranchIfSmallNonZero { - target: 18, + 19: BranchIfSmallNonZero { + target: 22, value: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 16: Copy { + 20: Copy { dest: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg1", ty: Bool }, src: StatePartIndex(8), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg1$next", ty: Bool }, }, - 17: Branch { - target: 19, + 21: Branch { + target: 23, }, - 18: Copy { + 22: Copy { dest: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg1", ty: Bool }, src: StatePartIndex(6), // (0x0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:9:1 - 19: BranchIfSmallZero { - target: 24, + 23: BranchIfSmallZero { + target: 28, value: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 20: BranchIfSmallNonZero { - target: 23, + 24: BranchIfSmallNonZero { + target: 27, value: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 21: Copy { + 25: Copy { dest: StatePartIndex(9), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg2", ty: Bool }, src: StatePartIndex(10), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg2$next", ty: Bool }, }, - 22: Branch { - target: 24, + 26: Branch { + target: 28, }, - 23: Copy { + 27: Copy { dest: StatePartIndex(9), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg2", ty: Bool }, src: StatePartIndex(6), // (0x0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:11:1 - 24: BranchIfSmallZero { - target: 29, + 28: BranchIfSmallZero { + target: 33, value: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 25: BranchIfSmallNonZero { - target: 28, + 29: BranchIfSmallNonZero { + target: 32, value: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 26: Copy { + 30: Copy { dest: StatePartIndex(11), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg3", ty: Bool }, src: StatePartIndex(12), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg3$next", ty: Bool }, }, - 27: Branch { - target: 29, + 31: Branch { + target: 33, }, - 28: Copy { + 32: Copy { dest: StatePartIndex(11), // (0x0) SlotDebugData { name: "InstantiatedModule(shift_register: shift_register).shift_register::reg3", ty: Bool }, src: StatePartIndex(6), // (0x0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:5:1 - 29: XorSmallImmediate { + 33: XorSmallImmediate { dest: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, rhs: 0x1, }, // at: module-XXXXXXXXXX.rs:1:1 - 30: Return, + 34: Return, ], .. }, - pc: 30, + pc: 34, memory_write_log: [], memories: StatePart { value: [], diff --git a/crates/fayalite/tests/sim/expected/sim_only_connects.txt b/crates/fayalite/tests/sim/expected/sim_only_connects.txt index af41fe2..827f3cc 100644 --- a/crates/fayalite/tests/sim/expected/sim_only_connects.txt +++ b/crates/fayalite/tests/sim/expected/sim_only_connects.txt @@ -212,55 +212,55 @@ Simulation { dest: StatePartIndex(9), // (0x0) SlotDebugData { name: "", ty: Bool }, value: 0x0, }, - // at: module-XXXXXXXXXX.rs:17:1 - 7: Copy { - dest: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1_empty$next", ty: Bool }, - src: StatePartIndex(9), // (0x0) SlotDebugData { name: "", ty: Bool }, - }, - // at: module-XXXXXXXXXX.rs:16:1 - 8: CloneSimOnly { - dest: StatePartIndex(9), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1$next", ty: SimOnly>> }, - src: StatePartIndex(0), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::inp", ty: SimOnly>> }, - }, // at: module-XXXXXXXXXX.rs:12:1 - 9: CloneSimOnly { + 7: CloneSimOnly { dest: StatePartIndex(1), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::out1", ty: SimOnly>> }, src: StatePartIndex(8), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1", ty: SimOnly>> }, }, // at: module-XXXXXXXXXX.rs:13:1 - 10: BranchIfZero { - target: 12, + 8: BranchIfZero { + target: 10, value: StatePartIndex(6), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1_empty", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:15:1 - 11: CloneSimOnly { + 9: CloneSimOnly { dest: StatePartIndex(1), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::out1", ty: SimOnly>> }, src: StatePartIndex(0), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::inp", ty: SimOnly>> }, }, // at: module-XXXXXXXXXX.rs:11:1 - 12: CloneSimOnly { + 10: CloneSimOnly { dest: StatePartIndex(4), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::helper1.inp", ty: SimOnly>> }, src: StatePartIndex(8), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1", ty: SimOnly>> }, }, // at: module-XXXXXXXXXX.rs:13:1 - 13: BranchIfZero { - target: 15, + 11: BranchIfZero { + target: 13, value: StatePartIndex(6), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1_empty", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:14:1 - 14: CloneSimOnly { + 12: CloneSimOnly { dest: StatePartIndex(4), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::helper1.inp", ty: SimOnly>> }, src: StatePartIndex(0), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::inp", ty: SimOnly>> }, }, // at: module-XXXXXXXXXX.rs:10:1 - 15: Copy { + 13: Copy { dest: StatePartIndex(2), // (0x1) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::helper1.cd.clk", ty: Clock }, src: StatePartIndex(0), // (0x1) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::cd.clk", ty: Clock }, }, - 16: Copy { + 14: Copy { dest: StatePartIndex(3), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::helper1.cd.rst", ty: SyncReset }, src: StatePartIndex(1), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::cd.rst", ty: SyncReset }, }, + // at: module-XXXXXXXXXX.rs:9:1 + 15: Copy { + dest: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1_empty$next", ty: Bool }, + src: StatePartIndex(6), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1_empty", ty: Bool }, + }, + // at: module-XXXXXXXXXX.rs:17:1 + 16: Copy { + dest: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1_empty$next", ty: Bool }, + src: StatePartIndex(9), // (0x0) SlotDebugData { name: "", ty: Bool }, + }, // at: module-XXXXXXXXXX.rs:1:1 17: Const { dest: StatePartIndex(8), // (0x1) SlotDebugData { name: "", ty: Bool }, @@ -280,91 +280,100 @@ Simulation { lhs: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, rhs: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - // at: module-XXXXXXXXXX.rs:7:1 21: CloneSimOnly { + dest: StatePartIndex(9), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1$next", ty: SimOnly>> }, + src: StatePartIndex(8), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1", ty: SimOnly>> }, + }, + // at: module-XXXXXXXXXX.rs:16:1 + 22: CloneSimOnly { + dest: StatePartIndex(9), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1$next", ty: SimOnly>> }, + src: StatePartIndex(0), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::inp", ty: SimOnly>> }, + }, + // at: module-XXXXXXXXXX.rs:7:1 + 23: CloneSimOnly { dest: StatePartIndex(5), // ({"bar": "", "extra": "value", "foo": "baz"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::helper1.out", ty: SimOnly>> }, src: StatePartIndex(7), // ({"bar": "", "extra": "value", "foo": "baz"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects.helper1: sim_only_connects_helper).sim_only_connects_helper::out", ty: SimOnly>> }, }, // at: module-XXXXXXXXXX.rs:18:1 - 22: CloneSimOnly { + 24: CloneSimOnly { dest: StatePartIndex(2), // ({"bar": "", "extra": "value", "foo": "baz"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::out2", ty: SimOnly>> }, src: StatePartIndex(5), // ({"bar": "", "extra": "value", "foo": "baz"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::helper1.out", ty: SimOnly>> }, }, // at: module-XXXXXXXXXX.rs:21:1 - 23: CloneSimOnly { + 25: CloneSimOnly { dest: StatePartIndex(11), // ({"bar": "", "extra": "value", "foo": "baz"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::helper2.inp", ty: SimOnly>> }, src: StatePartIndex(2), // ({"bar": "", "extra": "value", "foo": "baz"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::out2", ty: SimOnly>> }, }, // at: module-XXXXXXXXXX.rs:19:1 - 24: CloneSimOnly { + 26: CloneSimOnly { dest: StatePartIndex(13), // ({"bar": "", "extra": "value", "foo": "baz"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects.helper2: sim_only_connects_helper).sim_only_connects_helper::inp", ty: SimOnly>> }, src: StatePartIndex(11), // ({"bar": "", "extra": "value", "foo": "baz"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::helper2.inp", ty: SimOnly>> }, }, // at: module-XXXXXXXXXX.rs:7:1 - 25: CloneSimOnly { + 27: CloneSimOnly { dest: StatePartIndex(6), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects.helper1: sim_only_connects_helper).sim_only_connects_helper::inp", ty: SimOnly>> }, src: StatePartIndex(4), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::helper1.inp", ty: SimOnly>> }, }, - 26: Copy { + 28: Copy { dest: StatePartIndex(4), // (0x1) SlotDebugData { name: "InstantiatedModule(sim_only_connects.helper1: sim_only_connects_helper).sim_only_connects_helper::cd.clk", ty: Clock }, src: StatePartIndex(2), // (0x1) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::helper1.cd.clk", ty: Clock }, }, - 27: Copy { + 29: Copy { dest: StatePartIndex(5), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects.helper1: sim_only_connects_helper).sim_only_connects_helper::cd.rst", ty: SyncReset }, src: StatePartIndex(3), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::helper1.cd.rst", ty: SyncReset }, }, // at: module-XXXXXXXXXX.rs:8:1 - 28: BranchIfSmallZero { - target: 33, + 30: BranchIfSmallZero { + target: 35, value: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 29: BranchIfSmallNonZero { - target: 32, + 31: BranchIfSmallNonZero { + target: 34, value: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 30: CloneSimOnly { + 32: CloneSimOnly { dest: StatePartIndex(8), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1", ty: SimOnly>> }, src: StatePartIndex(9), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1$next", ty: SimOnly>> }, }, - 31: Branch { - target: 33, + 33: Branch { + target: 35, }, - 32: CloneSimOnly { + 34: CloneSimOnly { dest: StatePartIndex(8), // ({"extra": "value"}) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1", ty: SimOnly>> }, src: StatePartIndex(10), // ({}) SlotDebugData { name: "", ty: SimOnly>> }, }, // at: module-XXXXXXXXXX.rs:9:1 - 33: BranchIfSmallZero { - target: 38, + 35: BranchIfSmallZero { + target: 40, value: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 34: BranchIfSmallNonZero { - target: 37, + 36: BranchIfSmallNonZero { + target: 39, value: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, }, - 35: Copy { + 37: Copy { dest: StatePartIndex(6), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1_empty", ty: Bool }, src: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1_empty$next", ty: Bool }, }, - 36: Branch { - target: 38, + 38: Branch { + target: 40, }, - 37: Copy { + 39: Copy { dest: StatePartIndex(6), // (0x0) SlotDebugData { name: "InstantiatedModule(sim_only_connects: sim_only_connects).sim_only_connects::delay1_empty", ty: Bool }, src: StatePartIndex(8), // (0x1) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:8:1 - 38: XorSmallImmediate { + 40: XorSmallImmediate { dest: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Bool }, lhs: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, rhs: 0x1, }, // at: module-XXXXXXXXXX.rs:1:1 - 39: Return, + 41: Return, ], .. }, - pc: 39, + pc: 41, memory_write_log: [], memories: StatePart { value: [],