We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e6ea642 commit f0a3afeCopy full SHA for f0a3afe
deploy/src/shift_driver.jl
@@ -124,9 +124,19 @@ end
124
125
# --- Flush ---
126
127
+function _bitreverse(x::UInt32, nbits::Integer)
128
+ r = UInt32(0)
129
+ for i in 0:nbits-1
130
+ r |= ((x >> i) & UInt32(1)) << (nbits - 1 - i)
131
+ end
132
+ r
133
+end
134
+
135
function flush!(chain::ShiftRegisterChain)
- # Left-align: OSR shifts left, so MSB goes out first
- shift_out!(chain.sm, (chain.state & 0x00FFFFFF) << (32 - NBITS))
136
+ # OSR shifts left (MSB first). Bit-reverse so shadow bit 0 → Q0,
137
+ # then left-align into the top of the 32-bit word.
138
+ reversed = _bitreverse(chain.state & 0x00FFFFFF, NBITS)
139
+ shift_out!(chain.sm, reversed << (32 - NBITS))
140
end
141
142
# --- Bulk writes (update shadow + flush) ---
0 commit comments