# Mod 8 Counter AHDL Design w/ External Source

• lespaul5895
In summary, the conversation discusses the design of a mod 8 counter using AHDL for a digital electronics project. The counter is designed to stay at the number 7 until an external source triggers it to continue counting. The speaker shares their current code and indicates that the IF statement needs to be modified to achieve the desired functionality. They mention being new to this and ask for further guidance, to which the expert suggests learning more about IF statements and other conditional statements. The final code shared by the speaker includes a nested IF statement that checks if the counter value is less than 7 before incrementing it, otherwise it remains at its current value. The speaker simulates the code and confirms that it works as intended.
lespaul5895
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;

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?

## 1. What is a "Mod 8 Counter AHDL Design"?

A "Mod 8 Counter AHDL Design" refers to a type of digital circuit design that uses a finite state machine to count up to 8 states. It is commonly used in digital electronics for applications such as frequency division, event counting, and timing signals.

## 2. What does "AHDL" stand for in this context?

"AHDL" stands for "Altera Hardware Description Language." It is a specialized language used for writing code for programmable logic devices, such as field-programmable gate arrays (FPGAs). It allows for the efficient design and implementation of digital circuits.

## 3. What is the purpose of an "External Source" in a Mod 8 Counter AHDL Design?

An external source in a Mod 8 Counter AHDL Design refers to an input signal that is used to control the counting sequence of the circuit. This allows for more flexibility in the design and the ability to synchronize the counter with other external systems.

## 4. How does a Mod 8 Counter AHDL Design work?

A Mod 8 Counter AHDL Design uses a finite state machine to sequentially count through 8 states. Each state represents a specific output value, which is controlled by the external source input. As the external source changes, the counter advances to the next state, allowing for a count of up to 8.

## 5. What are some common applications of a Mod 8 Counter AHDL Design?

A Mod 8 Counter AHDL Design has many practical applications in digital electronics, including frequency division for clock signals, event counting for sensors and detectors, and timing signals for controlling the operation of other circuits. It is also commonly used in communication systems, digital signal processing, and control systems.

• Electrical Engineering
Replies
10
Views
3K
• Electrical Engineering
Replies
6
Views
5K
• Electrical Engineering
Replies
1
Views
8K
• High Energy, Nuclear, Particle Physics
Replies
3
Views
688
• Electrical Engineering
Replies
2
Views
27K
• Electrical Engineering
Replies
2
Views
2K
• Engineering and Comp Sci Homework Help
Replies
5
Views
3K
• Engineering and Comp Sci Homework Help
Replies
4
Views
1K
• Engineering and Comp Sci Homework Help
Replies
1
Views
11K
• Engineering and Comp Sci Homework Help
Replies
6
Views
10K