Mod 8 Counter AHDL Design w/ External Source

  • Thread starter Thread starter lespaul5895
  • Start date Start date
Click For 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?
 
I am trying to understand how transferring electric from the powerplant to my house is more effective using high voltage. The suggested explanation that the current is equal to the power supply divided by the voltage, and hence higher voltage leads to lower current and as a result to a lower power loss on the conductives is very confusing me. I know that the current is determined by the voltage and the resistance, and not by a power capability - which defines a limit to the allowable...

Similar threads

Replies
10
Views
4K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 1 ·
Replies
1
Views
8K
  • · Replies 1 ·
Replies
1
Views
28K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 1 ·
Replies
1
Views
11K
  • · Replies 2 ·
Replies
2
Views
3K