EmbDev.net

Forum: FPGA, VHDL & Verilog counter with signal enable (active high) and synchronous reset signal (active high)


von Juan (Guest)


Attached files:

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;

von Homework_Service @ Nightshift (Guest)


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.

von Homework_Service @ Nightshift (Guest)


Rate this post
useful
not useful
Homework_Service @ Nightshift wrote:
> constant M: integer:=999999;

Too high. Choose Clock frequency <= 1/(1 ms/2**14) <= 16.38 MHz. And M 
<= 2**14-1.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.