Loading simulator…
1. Previous-Bit Comparison
Previous_Bit stores the latest transmitted bit. The XNOR detects whether the next source bit matches it.
Same_Bit = Source_Bit XNOR Previous_Bit
Same_Bit = Source_Bit·Previous_Bit + Source_Bit'·Previous_Bit'
The first valid source bit starts a run at 001.
2. Run Counter and Five-Bit Detection
Accept_Bit excludes invalid and stuff cycles. The three-bit counter restarts or increments on accepted bits.
Accept_Bit = Bit_Valid·Stuff_Pending'
Count_0 = R2'·R1'·R0'
Count_4 = R2·R1'·R0'
Restart_Run = Accept_Bit·(Count_0 + Same_Bit')
Increment_Run = Accept_Bit·Count_0'·Same_Bit
Five_Equal = Bit_Valid·Stuff_Pending'·Count_4·Same_Bit
Restart_Run loads 001. Increment_Run advances Run_Count by one. Five_Equal accepts the fifth bit and requests stuffing.
3. Stuff-Pending and Previous-Bit Registers
Stuff_Pending lasts for exactly one output cycle. The previous-bit register also records the inserted bit.
Stuff_Pending_Next = Five_Equal
Previous_Load = Accept_Bit + Stuff_Pending
Previous_Data = Stuff_Pending·TX_BIT + Stuff_Pending'·Source_Bit
The stuff-cycle edge stores TX_BIT in Previous_Bit. It also restarts Run_Count at 001.
4. Output Control
The output MUX selects the held complement during stuffing.
TX_BIT = Stuff_Pending'·Source_Bit
+ Stuff_Pending·Previous_Bit'
STUFF = Stuff_Pending
Source_Advance = Bit_Valid·Stuff_Pending'
Source_Advance at 0 holds the original source bit. After stuffing, that held bit is transmitted normally.
5. Reset and Hold Behavior
nRESET asynchronously initializes the stored values.
Previous_Bit = 0
Run_Count = 000
Stuff_Pending = 0
STUFF = 0
When Bit_Valid is 0, normal run tracking holds.