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

Subversion Repositories modbus

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 guanucolui
--------------------------------------------------------------------------------
2
-- Company: University of Vigo
3
-- Engineer: L. Jacobo Alvarez Ruiz de Ojeda
4
--
5
-- Create Date:    11:21:57 10/18/06
6
-- Design Name:    
7
-- Module Name:    ctr_receiver_clock - Behavioral
8
-- Project Name:   
9
-- Target Device:  
10
-- Tool versions:  
11
-- Description: It counts the cycles of the receive clock and indicates the reception of 2, 4, 6 and 8 receive clock cycles
12
-- This counter starts at state 0, counts until state 8, then goes to state 1 and keep on counting, until it is reset to the initial state 0.
13
-- This is necessary to count the receive clock cycles correctly, starting with the first receive clock cycle later than
14
--  the first RXD falling edge (which corresponds to the start bit)
15
--
16
-- Dependencies:
17
-- 
18
-- Revision:
19
-- Revision 0.01 - File Created
20
-- Additional Comments:
21
-- 
22
--------------------------------------------------------------------------------
23
library IEEE;
24
use IEEE.STD_LOGIC_1164.ALL;
25
use IEEE.STD_LOGIC_ARITH.ALL;
26
use IEEE.STD_LOGIC_UNSIGNED.ALL;
27
 
28
---- Uncomment the following library declaration if instantiating
29
---- any Xilinx primitives in this code.
30
--library UNISIM;
31
--use UNISIM.VComponents.all;
32
 
33
entity ctr_receiver_clock is
34
    Port ( clk : in std_logic;
35
           reset : in std_logic;
36
           sync_reset : in std_logic;
37
           ctr_eq_2 : out std_logic;
38
           ctr_eq_4 : out std_logic;
39
           ctr_eq_6 : out std_logic;
40
           ctr_eq_8 : out std_logic;
41
           gctr : in std_logic;
42
           qctr : out std_logic_vector(3 downto 0));
43
end ctr_receiver_clock;
44
 
45
architecture Behavioral of ctr_receiver_clock is
46
 
47
signal qctr_aux: std_logic_vector (3 downto 0);
48
 
49
begin
50
 
51
-- Outputs assignment
52
qctr <= qctr_aux;
53
 
54
process (clk, reset, gctr, qctr_aux)
55
begin
56
        if (reset ='1') then
57
                -- Counter initialization
58
                qctr_aux <= "0000";
59
        elsif (clk'event and clk='1') then
60
                if sync_reset = '1' then
61
                        qctr_aux <= "0000";
62
                elsif (gctr='1') then
63
                        if qctr_aux = 8 then
64
                                qctr_aux <= "0001";
65
                        else
66
                                -- Increment counter
67
                                qctr_aux <= qctr_aux + 1;
68
                        end if;
69
                end if;
70
        end if;
71
 
72
        if qctr_aux = 2 then
73
                -- 2 cycles of receive clock.
74
                ctr_eq_2 <= '1';
75
        else ctr_eq_2 <='0';
76
        end if;
77
 
78
        if qctr_aux = 4  then
79
                -- 4 cycles of receive clock
80
                ctr_eq_4 <= '1';
81
        else ctr_eq_4 <='0';
82
        end if;
83
 
84
        if qctr_aux = 6 then
85
                -- 6 cycles of receive clock
86
                ctr_eq_6 <= '1';
87
        else ctr_eq_6 <='0';
88
        end if;
89
 
90
        if qctr_aux = 8 then
91
                -- 8 cycles of receive clock. Last state
92
                ctr_eq_8 <= '1';
93
        else ctr_eq_8 <='0';
94
        end if;
95
end process;
96
 
97
 
98
end Behavioral;

powered by: WebSVN 2.1.0

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