ABEL help needed

T

Tim

Guest
Hi there

I like to realize a counter, which has an UP and DOWN (and others).
I know, I need a clock for realizing asynchronious reset.
UP and DOWN are triggered by user switches. But I just found a
possiblity for realisation by using an extra Clock-Button - that's a
pretty bad solution!

Can somebody help me and tell me what to change in my ABEL-Code, so I
don't need the Clock-Button??

I use this code

MODULE unicnt


title '6 bit universal counter with parallel load' ;
"constants
X,C,Z = .X., .C., .Z. ;


"inputs
D5..D0 pin ; "Data inputs, 4 bits wide
clk pin ; "Clock input
rst pin ; "Asynchronous reset
cnten pin ; "Count enable
ld pin ; "Load counter with input data value
up pin ; "Up/Down selector: HIGH selects up
down pin;

"outputs
q5..q0 pin istype 'reg'; "Counter outputs

"sets
data = [D5..D0]; "Data set
count = [q5..q0]; "Counter set

"mode equations
MODE = [cnten,ld,up,down]; "Mode set composed of control pins.
LOAD = (MODE == [ X , 1, X, X ]);"Various modes are defined by
HOLD = (MODE == [ 0 , 0, X, X ]);"values applied to control pins.
UP = (MODE == [ 1 , 0, 1, 0 ]);"Symbolic name may be defined as
DOWN = (MODE == [ 1 , 0, 0, 1 ]);"a set equated to a value.

equations
when LOAD then count := data "Load counter with data
else when UP then count := count + 1 "Count up
else when DOWN then count := count - 1 "Count down
else when HOLD then count := count "Hold count
else count := count;

count.clk = clk;
"Counter clock input
count.ar = rst; "Counter reset input

END


Thanks


Tim
 
Tim schrieb:
Hi there

I like to realize a counter, which has an UP and DOWN (and others).
I know, I need a clock for realizing asynchronious reset.
UP and DOWN are triggered by user switches. But I just found a
possiblity for realisation by using an extra Clock-Button - that's a
pretty bad solution!

Can somebody help me and tell me what to change in my ABEL-Code, so I
don't need the Clock-Button??

I use this code

MODULE unicnt


title '6 bit universal counter with parallel load' ;
"constants
X,C,Z = .X., .C., .Z. ;


"inputs
D5..D0 pin ; "Data inputs, 4 bits wide
clk pin ; "Clock input
rst pin ; "Asynchronous reset
cnten pin ; "Count enable
ld pin ; "Load counter with input data value
up pin ; "Up/Down selector: HIGH selects up
down pin;

"outputs
q5..q0 pin istype 'reg'; "Counter outputs

"sets
data = [D5..D0]; "Data set
count = [q5..q0]; "Counter set

"mode equations
MODE = [cnten,ld,up,down]; "Mode set composed of control pins.
LOAD = (MODE == [ X , 1, X, X ]);"Various modes are defined by
HOLD = (MODE == [ 0 , 0, X, X ]);"values applied to control pins.
UP = (MODE == [ 1 , 0, 1, 0 ]);"Symbolic name may be defined as
DOWN = (MODE == [ 1 , 0, 0, 1 ]);"a set equated to a value.

equations
when LOAD then count := data "Load counter with data
else when UP then count := count + 1 "Count up
else when DOWN then count := count - 1 "Count down
else when HOLD then count := count "Hold count
else count := count;

count.clk = clk;
"Counter clock input
count.ar = rst; "Counter reset input

END
may be i not really understand what you want to do, but any action of
your counter (except reset) can only take place, if there is an counter
clock present. Therefore you need clock for LOAD too :-(

You could synchronize your input signal with a higher frequency clock
or use asynchronous set and preset to load the counter


this line is redundant:
else when HOLD then count := count "Hold count
regards, Bertram


--
Bertram Geiger, Graz - Austria
 

Welcome to EDABoard.com

Sponsor

Back
Top