OpenCores
URL https://opencores.org/ocsvn/modbus/modbus/trunk

Subversion Repositories modbus

[/] [modbus/] [trunk/] [enlace/] [ctr_bcd.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 guanucolui
------------------------------------------------------------------
2
--  ctr_bcd.vhd -- 
3
-- BCD counter
4
------------------------------------------------------------------
5
-- Luis Jacobo Alvarez Ruiz de Ojeda
6
-- Dpto. Tecnologia Electronica
7
-- University of Vigo
8
-- 24, March, 2006 
9
------------------------------------------------------------------
10
library IEEE;
11
use IEEE.STD_LOGIC_1164.ALL;
12
use IEEE.STD_LOGIC_ARITH.ALL;
13
use IEEE.STD_LOGIC_UNSIGNED.ALL;
14
 
15
 
16
entity ctr_bcd is
17
    Port ( clk : in std_logic;
18
           reset : in std_logic;
19
                          sync_reset : in std_logic;
20
           gctr : in std_logic;
21
           qctr : out std_logic_vector(3 downto 0);
22
           ctr_eq_9 : out std_logic);
23
end ctr_bcd;
24
 
25
architecture Behavioral of ctr_bcd is
26
 
27
------------------------------------------------------------------
28
--  Signal Declarations and Constants
29
------------------------------------------------------------------
30
signal qctr_aux: std_logic_vector (3 downto 0);
31
 
32
begin
33
 
34
-- Outputs assignment
35
qctr <= qctr_aux;
36
 
37
process (clk, reset, gctr, qctr_aux)
38
begin
39
        if (reset ='1') then
40
                -- Counter initialization
41
                qctr_aux <= "0000";
42
        elsif (clk'event and clk='1') then
43
                if sync_reset = '1' then
44
                        qctr_aux <= "0000";
45
                elsif (gctr='1') then
46
                        if qctr_aux = 9 then
47
                                qctr_aux <= "0000";
48
                        else
49
                                -- Increment counter
50
                                qctr_aux <= qctr_aux + 1;
51
                        end if;
52
                end if;
53
        end if;
54
 
55
        if qctr_aux = 9 then
56
                -- Last state
57
                ctr_eq_9 <= '1';
58
        else ctr_eq_9 <='0';
59
        end if;
60
end process;
61
 
62
end Behavioral;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.