Creating Counters Using ABEL
The following equations show how to implement up, down, and bidirectional counters:
EQUATIONS;
// Up Counter
upcount := (upcount.q + 1) & up & !reset ``Count up.
# upcount.q & !up & !reset; ``Hold clear if reset is high.
upcount.clk = clock;
// Down Counter
dncount := (dncount.q - 1) & dn & !reset ``Count down.
# dncount.q & !dn & !reset; ``Hold Clear if reset is high.
dncount.clk = clock;
// Bidirectional Counter
bicount := (bicount.q + 1) & up & !reset ``Count up.
# (bicount.q - 1) & dn & !reset ``Count down.
# bicount.q & !up & !dn & !reset;
``Hold Clear if reset is high.
bicount.clk = clock;