PPT Slide
7 – Sequential Logic Examples
Digital combination lock (introduce intermediate signals)
interface (clk, rst, new, C1_1..C1_4, C2_1..C2_4, C3_1..C3_4, value1..value4 -> out);
title 'digital combination lock'
out pin istype 'reg,buffer';
mux1..mux3 node istype 'reg,buffer';
code1..code4 node istype 'keep';
equal1,equal2 node istype 'keep';
"Alias for state register and encoding
cntrl1 = [mux1, mux1, mux1, mux1];
ntrl2 = [mux2, mux2, mux2, mux2];
cntrl3 = [mux3, mux3, mux3, mux3];
[code1..code4] = ( (cntrl1 & [C1_1..C1_4])
# (cntrl2 & [C2_1..C2_4])
# (cntrl3 & [C3_1..C3_4]) );
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;