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

Subversion Repositories wb_vga

[/] [wb_vga/] [trunk/] [wb_tk/] [wb_async_master.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 tantos
--
2
--  Wishbone bus toolkit.
3
--
4
--  (c) Copyright Andras Tantos <andras_tantos@yahoo.com> 2001/03/31
5
--  This code is distributed under the terms and conditions of the GNU General Public Lince.
6
--
7
--
8
-- ELEMENTS:
9
--   wb_async_master: async bus master to Wishbone bus bridge.
10
 
11
-------------------------------------------------------------------------------
12
--
13
--  wb_async_master
14
--
15
-------------------------------------------------------------------------------
16
 
17
library IEEE;
18
use IEEE.std_logic_1164.all;
19
 
20
library wb_tk;
21
use wb_tk.technology.all;
22
 
23
entity wb_async_master is
24
        generic (
25
                width: positive := 16;
26
                addr_width: positive := 20
27
        );
28
        port (
29
                clk_i: in std_logic;
30
                rst_i: in std_logic := '0';
31
 
32
                -- interface to wb slave devices
33
                s_adr_o: out std_logic_vector (addr_width-1 downto 0);
34
                s_sel_o: out std_logic_vector ((width/8)-1 downto 0);
35
                s_dat_i: in std_logic_vector (width-1 downto 0);
36
                s_dat_o: out std_logic_vector (width-1 downto 0);
37
                s_cyc_o: out std_logic;
38
                s_ack_i: in std_logic;
39
                s_err_i: in std_logic := '-';
40
                s_rty_i: in std_logic := '-';
41
                s_we_o: out std_logic;
42
                s_stb_o: out std_logic;
43
 
44
                -- interface to asyncron master device
45
                a_data: inout std_logic_vector (width-1 downto 0) := (others => 'Z');
46
                a_addr: in std_logic_vector (addr_width-1 downto 0) := (others => 'U');
47
                a_rdn: in std_logic := '1';
48
                a_wrn: in std_logic := '1';
49
                a_cen: in std_logic := '1';
50
                a_byen: in std_logic_vector ((width/8)-1 downto 0);
51
                a_waitn: out std_logic
52
        );
53
end wb_async_master;
54
 
55
architecture wb_async_master of wb_async_master is
56
        component d_ff
57
                port (  d  :  in STD_LOGIC;
58
                                clk:  in STD_LOGIC;
59
                        ena:  in STD_LOGIC := '1';
60
                        clr:  in STD_LOGIC := '0';
61
                        pre:  in STD_LOGIC := '0';
62
                                q  :  out STD_LOGIC
63
                );
64
        end component;
65
        signal wg_clk, wg_pre, wg_q: std_logic;
66
        signal i_cyc_o, i_stb_o, i_we_o: std_logic;
67
        signal i_waitn: std_logic;
68
begin
69
        ctrl: process is
70
        begin
71
                wait until clk_i'EVENT and clk_i = '1';
72
                if (rst_i = '1') then
73
                        i_cyc_o <= '0';
74
                        i_stb_o <= '0';
75
                        i_we_o <= '0';
76
                else
77
                        if (a_cen = '0') then
78
                                i_stb_o <= not (a_rdn and a_wrn);
79
                                i_we_o <= not a_wrn;
80
                                i_cyc_o <= '1';
81
                        else
82
                                i_cyc_o <= '0';
83
                                i_stb_o <= '0';
84
                                i_we_o <= '0';
85
                        end if;
86
                end if;
87
        end process;
88
        s_cyc_o <= i_cyc_o and not i_waitn;
89
        s_stb_o <= i_stb_o and not i_waitn;
90
        s_we_o <= i_we_o and not i_waitn;
91
 
92
        w_ff1: d_ff port map (
93
                d => s_ack_i,
94
                clk => clk_i,
95
                ena => '1',
96
                clr => rst_i,
97
                pre => '0',
98
                q => wg_q
99
        );
100
 
101
        wg_clk <= not a_cen;
102
        wg_pre <= wg_q or rst_i;
103
        w_ff2: d_ff port map (
104
                d => '0',
105
                clk => wg_clk,
106
                ena => '1',
107
                clr => '0',
108
                pre => wg_pre,
109
                q => i_waitn
110
        );
111
        a_waitn <= i_waitn;
112
 
113
        s_adr_o <= a_addr;
114
        negate: for i in s_sel_o'RANGE generate s_sel_o(i) <= not a_byen(i); end generate;
115
        s_dat_o <= a_data;
116
 
117
        a_data_out: process is
118
        begin
119
                wait on s_dat_i, a_rdn, a_cen;
120
                if (a_rdn = '0' and a_cen = '0') then
121
                        a_data <= s_dat_i;
122
                else
123
                        a_data <= (others => 'Z');
124
                end if;
125
        end process;
126
end wb_async_master;
127
 

powered by: WebSVN 2.1.0

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