counter with signal enable (active high) and synchronous reset signal (active high)

Guest #6526988
Rate this post
• ▲ useful
▼ not useful
I'm trying to do the following task, but I need your help or some 
pointers:

Write a counter with signal enable (active high) and synchronous reset 
signal (active high) to a VHDL file (cont_clk.vhd).
The counter should generate an end of count (rco) output signal that 
turns high every 1 millisecond and which is active for one clock cycle 
(clk). It should also generate a count signal (q) of 14 bits.

Use the counter scheme (sequential circuit) described below.

The module should have the following entity declaration:

entity cont_clk is
 Port (enable: in STD_LOGIC;
 reset: in STD_LOGIC;
 clk: in STD_LOGIC;
 rco: out STD_LOGIC;
 q: out STD_LOGIC_VECTOR (13 down 0));
end cont_clk;
Attached files:
Guest #6527046
Rate this post
• ▲ useful
▼ not useful
1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.NUMERIC_STD.ALL;
4

5
entity cont_clk is Port(
6
  enable: in std_logic;
7
  reset: in std_logic;
8
  clk: in std_logic;
9
  rco: out std_logic;
10
  q: out std_logic_vector(13 downto 0));
11
end cont_clk;
12

13
architecture Behavioral of cont_clk is
14

15
constant M: integer:=999999;
16
signal Data: std_logic_vector(13 downto 0):=(others => '0');
17
signal rco_buffer: std_logic:='0';
18

19
begin
20

21
q <= Data;
22
rco_buffer <= '1' when to_integer(unsigned(Data)) = M else '0';
23
rco <= rco_buffer;
24

25
process begin
26
  wait until rising_edge(clk);
27
  if reset = '1' then
28
    Data <= (others => '0');
29
  else
30
    if enable = '1' then
31
      if rco_buffer = '0' then
32
        Data <= std_logic_vector(unsigned(Data) +1);
33
      else
34
        Data <= (others => '0');
35
      end if;
36
    end if;
37
  end if;
38
end process;
39

40
end Behavioral;

Juan wrote:
> The counter should generate an end of count (rco) output signal that
> turns high every 1 millisecond

Depends on:
Clock frequency.

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.