Draft preview. Lessons are being written and reviewed.

Verilog practice / Problem 21

MediumCounters

Up/down counter with load

At each rising clock edge, check the controls in this order: rst sets q to 0; else load copies d into q; else if en is 1, q counts up when up is 1 and down when up is 0. The count wraps both ways, so 0 − 1 gives 15.

Ports

NameDirectionBits
clkinput1
rstinput1
loadinput1
eninput1
upinput1
dinput4
qoutput4

How it's checked

Each cycle: the test sets the inputs, waits for your logic to settle, checks the outputs, then gives one rising clock edge. It holds rst high for the first two cycles and once more later on.

Stuck? Read the lesson Up, down and loadable counters.

updown.vCtrl + Enter runs