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

Subversion Repositories ft245r_interface

[/] [ft245r_interface/] [branches/] [ft245r_avalon/] [ft245_rcv.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 pradd
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
 
5
 
6
entity ft245_rcv is
7
        generic(clock_cycle : integer);
8
        port
9
        (
10
                clk                                     : in    std_logic;
11
                data_in                         : in    std_logic_vector(7 downto 0);
12
                n_rd                                    : out   std_logic := '1';
13
                n_rxf                                   : in    std_logic;
14
 
15
                -- system interface
16
                ready                                   : out   std_logic := '0';                                                -- goes high when there's a byte available for reading
17
                rd                                              : in    std_logic;                                                              -- invalidates current byte
18
                data_out                                : out   std_logic_vector(7 downto 0)
19
        );
20
end ft245_rcv;
21
 
22
 
23
architecture action of ft245_rcv is
24
        constant        t1      :       integer :=      integer(100.0 / (50.0 / real(clock_cycle)));
25
        constant t3     :       integer :=      integer(40.0 / (50.0 / real(clock_cycle)));
26
        constant        t5      :       integer :=      integer(25.0 / (50.0 / real(clock_cycle)));
27
        constant        t6      :       integer :=      integer(80.0 / (50.0 / real(clock_cycle)));
28
        constant        t2      :       integer :=      integer((50.0 + 80.0) / (50.0 / real(clock_cycle)));
29
 
30
        type state_t is
31
        (
32
                S_IDLE,
33
                S_RD_LOW,
34
                S_RD_HIGH,
35
                S_DELAY,
36
                S_END
37
        );
38
        signal state                    :       state_t :=      S_IDLE;
39
        signal n_state                  :       state_t := S_IDLE;
40
        signal delay                    :       integer :=      0;
41
        signal can_read         :       std_logic:= '1';
42
begin
43
 
44
        ready <= '1' when state = S_END else '0';
45
 
46
        process(clk, n_rxf, rd)
47
        begin
48
                if(rd = '1')then
49
                        state                                                   <= S_IDLE;
50
                elsif(rising_edge(clk))then
51
                        case state is
52
                                when S_IDLE =>
53
                                        if(n_rxf = '0')then
54
                                                n_rd                                    <= '0';
55
                                                n_state                         <= S_RD_LOW;
56
                                                state                                   <= S_DELAY;
57
                                                delay                                   <= t3;
58
                                        end if;
59
 
60
                                when S_RD_LOW =>
61
--                                      data_out                                        <= data_in;
62
                                        n_state                                 <= S_RD_HIGH;
63
                                        state                                           <= S_DELAY;
64
                                        delay                                   <= t1 - t3;
65
 
66
                                when S_RD_HIGH =>
67
                                        data_out                                        <= data_in;
68
                                        n_rd                                            <= '1';
69
                                        n_state                                 <= S_END;
70
                                        state                                           <= S_DELAY;
71
                                        delay                                           <=      t6;
72
 
73
                                when S_END =>
74
                                        if(rd = '1')then
75
                                                state                           <= S_IDLE;
76
                                        else
77
                                                state                                           <= S_END;
78
                                        end if;
79
 
80
                                when S_DELAY =>
81
                                        if(delay > 0)then
82
                                                delay                           <= delay - 1;
83
                                        else
84
                                                state                                   <= n_state;
85
                                        end if;
86
 
87
                                when others =>
88
                                        state                                   <= S_IDLE;
89
 
90
                        end case;
91
                end if;
92
        end process;
93
end action;

powered by: WebSVN 2.1.0

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