PPT Slide
7 – Sequential Logic Examples
Digital combination lock (HDL description of new data-path)
WHEN ld1 THEN C1 := value ELSE C1 := C1.fb;
WHEN ld2 THEN C2 := value ELSE C2 := C2.fb;
WHEN ld3 THEN C3 := value ELSE C3 := C3.fb;
[code1..code4] = ( (cntrl1 & C1.fb)
equal1 = (code1 == value1) & (code2 == value2);
equal2 = (code3 == value3) & (code4 == value4);
state S1: if !new then S1
else if equal then S2 else ERR;
state S2: if !new then S2
else if equal then S3 else ERR;
state S3: if !new then S3
else if equal then OPEN else ERR;
interface (clk, rst, new, ld1..ld3, value1..value4 -> out);
title 'digital combination lock'
out pin istype 'reg,buffer';
C1_1..C1_4 node istype 'reg';
C2_1..C2_4 node istype 'reg';
C3_1..C3_4 node istype 'reg';
mux1..mux3 node istype 'reg';
code1..code4 node istype 'keep';
equal1,equal2 node istype 'keep';
"Alias for state register and encoding
value = [value1..value4];
cntrl1 = [mux1, mux1, mux1, mux1];
cntrl2 = [mux2, mux2, mux2, mux2];
cntrl3 = [mux3, mux3, mux3, mux3];