module Ring8 
title '8-bit Ring Counter' 

" Inputs and Outputs
MCLK, CNTEN, RESTART               pin;
S0..S7                             pin istype 'reg';

equations

[S0..S7].CLK = MCLK;

S0 := CNTEN & !S0 & !S1 & !S2 & !S3 & !S4 & !S5 & !S6  " Self-sync
    # !CNTEN & S0                                      " Hold
    # RESTART;                                         " Start with one 1
[S1..S7] := !RESTART & ( !CNTEN & [S1..S7]     " Shift
                        # CNTEN & [S0..S6] );  " Hold

end Ring8 
