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

Subversion Repositories ft245r_interface

[/] [ft245r_interface/] [branches/] [ft245r_avalon/] [ft245_avalon.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
--      clk_cycle_duration:
6
--              20      -       2.5ns (400MHz)
7
--              10      -       5ns     (200MHz)
8
--               5      -       10ns    (100MHz)
9
--               1 -    20ns    (50MHz)
10
 
11
 
12
entity ft245_avalon is
13
        generic(clk_cycle_duration : integer := 20);
14
        port
15
        (
16
                clk                             : in    std_logic;
17
                pwrite                  : in    std_logic;
18
                pread                           : in    std_logic;
19
                readdata                        : out   std_logic_vector(31 downto 0);
20
                writedata               : in    std_logic_vector(31 downto 0);
21
                resetn                  : in    std_logic;
22
                address                 : in    std_logic_vector(3 downto 0);
23
 
24
                -- FT245 interface
25
                ft_rxf                  : in    std_logic;
26
                ft_txe                  : in    std_logic;
27
                ft_rd                           : out   std_logic;
28
                ft_wr                           : out   std_logic;
29
                ft_data                 : inout std_logic_vector(7 downto 0);
30
                ft_reset                        : out   std_logic
31
        );
32
end ft245_avalon;
33
 
34
architecture action of ft245_avalon is
35
        component ft245_rcv
36
                generic(clock_cycle : integer);
37
                port
38
                (
39
                        clk, n_rxf, rd : in     std_logic;
40
                        data_in : in std_logic_vector(7 downto 0);
41
                        n_rd, ready : out std_logic;
42
                        data_out : out std_logic_vector(7 downto 0)
43
                );
44
        end component;
45
        signal rcv_data_in      :       std_logic_vector(7 downto 0);
46
        signal rcv_rd                   :       std_logic;
47
        signal rcv_ready                :       std_logic;
48
        signal rcv_data_out     :       std_logic_vector(7 downto 0);
49
        component ft245_snd
50
                generic(clock_cycle : integer);
51
                port
52
                (
53
                        clk, n_txe, wr : in std_logic;
54
                        data_in : in std_logic_vector(7 downto 0);
55
                        n_wr, ready : out std_logic;
56
                        data_out : out std_logic_vector(7 downto 0)
57
                );
58
        end component;
59
        signal snd_data_out     :       std_logic_vector(7 downto 0);
60
        signal snd_wr                   :       std_logic;
61
        signal snd_ready                :       std_logic;
62
        signal snd_data_in      :       std_logic_vector(7 downto 0);
63
        signal prev_pread               :       std_logic;
64
        signal prev_pwrite      :       std_logic;
65
        signal prev_address     :       std_logic_vector(3 downto 0);
66
begin
67
        RCV:ft245_rcv
68
        generic map(clock_cycle => clk_cycle_duration)
69
        port map
70
        (
71
                clk => clk,
72
                n_rxf => ft_rxf,
73
                rd => rcv_rd,
74
                data_in => rcv_data_in,
75
                n_rd => ft_rd,
76
                ready => rcv_ready,
77
                data_out => rcv_data_out
78
        );
79
 
80
        SND:ft245_snd
81
        generic map(clock_cycle => clk_cycle_duration)
82
        port map
83
        (
84
                clk => clk,
85
                n_txe => ft_txe,
86
                wr => snd_wr,
87
                data_in => snd_data_in,
88
                n_wr => ft_wr,
89
                ready => snd_ready,
90
                data_out => snd_data_out
91
        );
92
 
93
        ft_reset                                                <= resetn;
94
 
95
--      readdata(7 downto 0)            <=      rcv_data_out;
96
--      readdata(8)                                     <= rcv_ready;
97
--      readdata(9)                                     <= snd_ready;
98
 
99
        -- Changed the addressing within the component
100
        readdata(7 downto 0)             <= rcv_data_out when address = "0000" else
101
                                                                                "000000"&snd_ready&rcv_ready when address = "0001" else
102
                                                                                x"ff";
103
        readdata(31 downto 8)   <= x"000000";
104
 
105
        rcv_rd                                          <= '1' when (prev_pread = '0' and pread = '1' and rcv_ready = '1' and prev_address = "0000") else
106
                                                                                '0';
107
 
108
        snd_wr                                          <= '1' when (prev_pwrite = '0' and pwrite = '1' and snd_ready = '1') else
109
                                                                                '0';
110
 
111
        snd_data_in                                     <= writedata(7 downto 0);
112
 
113
        ft_data                                         <= snd_data_out when snd_ready = '0' else
114
                                                                        "ZZZZZZZZ";
115
        rcv_data_in                                     <= ft_data;
116
 
117
        TRACK_ADDRESS:process(clk, address)
118
        begin
119
                if(rising_edge(clk))then
120
                        prev_address            <= address;
121
                end if;
122
        end process;
123
 
124
        TOGGLE_RD:process(clk, pread)
125
        begin
126
                if(rising_edge(clk))then
127
                        prev_pread                      <= pread;
128
                end if;
129
        end process;
130
 
131
        TOGGLE_WR:process(clk, pwrite)
132
        begin
133
                if(rising_edge(clk))then
134
                        prev_pwrite                     <= pwrite;
135
                end if;
136
        end process;
137
 
138
 
139
end action;

powered by: WebSVN 2.1.0

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