Mod 8 Counter AHDL Design w/ External Source

  • Thread starter Thread starter lespaul5895
  • Start date Start date
AI Thread Summary
The discussion focuses on designing a mod 8 counter using AHDL that holds at 7 until an external signal resets it. The initial code provided was functional but needed modification to prevent counting beyond 7. A suggested solution involves adding a conditional statement to check if the count is less than 7 before incrementing. The revised code successfully implements this logic and has been simulated with positive results. Overall, the conversation emphasizes understanding conditional statements in AHDL for effective counter design.
lespaul5895
Messages
7
Reaction score
0
I'm working on a project for my digital electronics class and part of it is designing a mod 8 counter using AHDL, I have the counter designed no problem but the only catch is the counter once it reaches the number 7 should stay there and not start over until an external source tells it to.

here's my code so far
SUBDESIGN mod8_counter
(
CLK, CLR :INPUT;
Y[2..0] :OUTPUT;
)

VARIABLE
count[2..0] :DFF;

BEGIN
count[].clk = clk;
IF !CLR THEN
count[] = count[] + 1;
END IF;
Y[] = count[];
END;
 
Engineering news on Phys.org
IF !CLR THEN
count[] = count[] + 1;
END IF;
Seems like that's the part you need to modifiy the IF on, eh?
 
I'm getting that my first if statement should be something to the effect of telling it that if y = 7 then it stays there else it will count up to 7 but I have no idea how to do that code, probably something easy but I'm still kinda new to this and I'm sure I'm just overlooking it.
 
You're on the right track. Just do some more reading about IF statements and other conditional statements.
 
SUBDESIGN mod8_counter
(
CLK, CLR :INPUT;
Y[2..0] :OUTPUT;
)

VARIABLE
count[2..0] :DFF;

BEGIN
count[].clk = clk;
IF !CLR THEN
IF count[] < 7 THEN
count[] = count[] + 1;
ELSE count[] = count[];
END IF;
END IF;
Y[] = count[];
END;

How's that look? I simulated and it seems to work ok?
 
Very basic question. Consider a 3-terminal device with terminals say A,B,C. Kirchhoff Current Law (KCL) and Kirchhoff Voltage Law (KVL) establish two relationships between the 3 currents entering the terminals and the 3 terminal's voltage pairs respectively. So we have 2 equations in 6 unknowns. To proceed further we need two more (independent) equations in order to solve the circuit the 3-terminal device is connected to (basically one treats such a device as an unbalanced two-port...
suppose you have two capacitors with a 0.1 Farad value and 12 VDC rating. label these as A and B. label the terminals of each as 1 and 2. you also have a voltmeter with a 40 volt linear range for DC. you also have a 9 volt DC power supply fed by mains. you charge each capacitor to 9 volts with terminal 1 being - (negative) and terminal 2 being + (positive). you connect the voltmeter to terminal A2 and to terminal B1. does it read any voltage? can - of one capacitor discharge + of the...
Thread 'Weird near-field phenomenon I get in my EM simulation'
I recently made a basic simulation of wire antennas and I am not sure if the near field in my simulation is modeled correctly. One of the things that worry me is the fact that sometimes I see in my simulation "movements" in the near field that seems to be faster than the speed of wave propagation I defined (the speed of light in the simulation). Specifically I see "nodes" of low amplitude in the E field that are quickly "emitted" from the antenna and then slow down as they approach the far...
Back
Top