VHDL code for binary counter

In summary, the conversation discusses the creation of a 5-bit binary counter using VHDL code. The counter has a sync. load signal that can preset it to a specific initial state. The output of the counter is then connected to a binary decoder, which displays the state of the counter. The code for the counter is provided and the conversation also discusses how to connect the counter output to the decoder.
  • #1
tetooo_2006
1
0

Homework Statement



structure or behavior VHDL code of a 5-bits binary counter with a sync. load signal to preset the counter to a specific initial state. the output of the counter (Q0 to Q4) are connected to a binary decoder that shows the state of the counter.

Homework Equations


The Attempt at a Solution


I wrote the code of 5 bits counter
Code:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
ENTITY counter IS
PORT ( count : OUT unsigned (4 DOWNTO 0);
load : IN STD_LOGIC;
pre :IN unsigned (4 DOWNTO 0);
Clk : IN STD_LOGIC);
END counter;
ARCHITECTURE Behavioral OF counter IS
SIGNAL c : unsigned(4 DOWNTO 0) := "00000";

BEGIN
count <= c;
PROCESS(Clk)
BEGIN
IF( rising_edge(Clk) ) THEN
IF(load = '1') THEN
c <= pre;
ELSE
c <= c + 1;
END IF;
END IF;
END PROCESS;
END Behavioral;

I want to connect the output to a binary decoder that shows the state of the counter
how can i do that?
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
You can just define the decoder outputs and then assign each bit of c to an output. It doesn't have to be a process. Alternatively, you can just define c as an output (array) instead of a signal.
 

1. What is VHDL code for binary counter?

VHDL (VHSIC Hardware Description Language) is a programming language used for describing digital circuits and systems. A binary counter in VHDL is a circuit that counts in binary, incrementing by one for every clock cycle.

2. How do I write a binary counter in VHDL?

To write a binary counter in VHDL, you will need to first declare signals for the inputs and outputs, then use the "process" statement to define the behavior of the counter. You will also need to use the "rising_edge" function to detect when the clock signal changes from low to high, and use conditional statements to determine the counting sequence.

3. What is the purpose of a binary counter in VHDL?

A binary counter in VHDL is used for counting and generating sequential patterns in digital circuits. It is commonly used in applications such as frequency dividers, time delay circuits, and memory address generation.

4. How do I simulate VHDL code for a binary counter?

You can simulate VHDL code using a simulation tool such as ModelSim or Xilinx ISE. These tools allow you to create a testbench that provides input signals to the counter and displays the output signals. You can then run the simulation and observe the behavior of the counter.

5. Are there any limitations to using a binary counter in VHDL?

Yes, there are some limitations when using a binary counter in VHDL. One limitation is that it can only count up to a certain number based on the number of bits used. Another limitation is that the counting sequence is fixed and cannot be changed during operation. Additionally, the timing of the counter may be affected by propagation delays in the circuit.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
8K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
11K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Replies
10
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
6K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
Back
Top