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

Subversion Repositories wb_vga

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 tantos
--
2
--  Address generator and accelerator.
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
 
9
-- Standard library.
10
library IEEE;
11
use IEEE.std_logic_1164.all;
12
use IEEE.numeric_std.all;
13
 
14
library wb_tk;
15
use wb_tk.technology.all;
16
use wb_tk.all;
17
 
18
library wb_vga;
19
use wb_vga.all;
20
 
21
entity accel is
22
        generic (
23
                accel_size: positive := 9;
24
                video_addr_width: positive := 20;
25
                data_width: positive := 16
26
        );
27
        port (
28
                clk_i: in std_logic;
29
                rst_i: in std_logic := '0';
30
 
31
                -- Slave interface to the CPU side
32
                we_i: in std_logic;
33
                cyc_i: in std_logic;
34
                cur_stb_i: in std_logic;
35
                ext_stb_i: in std_logic;
36
                acc_stb_i: in std_logic;
37
                mem_stb_i: in std_logic;
38
 
39
        sel_i: in std_logic_vector ((data_width/8)-1 downto 0) := (others => '1');
40
                adr_i: in std_logic_vector(accel_size-1 downto 0);
41
                dat_i: in std_logic_vector(data_width-1 downto 0);
42
                dat_o: out std_logic_vector(data_width-1 downto 0);
43
                dat_oi: in std_logic_vector(data_width-1 downto 0);
44
 
45
                ack_o: out std_logic;
46
                ack_oi: in std_logic;
47
 
48
                -- Master interface to the video memory side.           
49
                v_we_o: out std_logic;
50
                v_cyc_o: out std_logic;
51 6 tantos
                v_stb_o: out std_logic;
52 4 tantos
 
53
                v_adr_o: out std_logic_vector (video_addr_width-1 downto 0);
54 6 tantos
        v_sel_o: out std_logic_vector ((data_width/8)-1 downto 0);
55
                v_dat_o: out std_logic_vector (data_width-1 downto 0);
56
                v_dat_i: in std_logic_vector (data_width-1 downto 0);
57 4 tantos
 
58
                v_ack_i: in std_logic
59
        );
60
end accel;
61
 
62
architecture accel of accel is
63
        component wb_io_reg
64
                generic (
65
                        width : positive := video_addr_width;
66
                        bus_width: positive := data_width;
67
                        offset: integer := 0
68
                );
69
                port (
70
                        clk_i: in std_logic;
71
                        rst_i: in std_logic;
72
                        rst_val: std_logic_vector(width-1 downto 0) := (others => '0');
73
 
74
                cyc_i: in std_logic := '1';
75
                        stb_i: in std_logic;
76
                sel_i: in std_logic_vector ((bus_width/8)-1 downto 0) := (others => '1');
77
                        we_i: in std_logic;
78
                        ack_o: out std_logic;
79
                        ack_oi: in std_logic := '-';
80
                        adr_i: in std_logic_vector (size2bits((width+offset+bus_width-1)/bus_width)-1 downto 0) := (others => '0');
81
                        dat_i: in std_logic_vector (bus_width-1 downto 0);
82
                        dat_oi: in std_logic_vector (bus_width-1 downto 0) := (others => '-');
83
                        dat_o: out std_logic_vector (bus_width-1 downto 0);
84
                        q: out std_logic_vector (width-1 downto 0);
85
                        ext_d: in std_logic_vector (width-1 downto 0) := (others => '-');
86
                        ext_we: in std_logic := '0'
87
                );
88
        end component;
89
 
90
        component wb_ram
91
                generic (
92
                        data_width: positive := 8;
93
                        addr_width: positive := 10
94
                );
95
                port (
96
                clk_i: in std_logic;
97
                        adr_i: in std_logic_vector (addr_width-1 downto 0);
98
                        dat_i: in std_logic_vector (data_width-1 downto 0);
99
                        dat_oi: in std_logic_vector (data_width-1 downto 0) := (others => '-');
100
                        dat_o: out std_logic_vector (data_width-1 downto 0);
101
                        cyc_i: in std_logic;
102
                        ack_o: out std_logic;
103
                        ack_oi: in std_logic := '-';
104
                        we_i: in std_logic;
105
                        stb_i: in std_logic
106
                );
107
        end component;
108
 
109
        signal cursor: std_logic_vector(video_addr_width-1 downto 0);
110
        signal accel_ram_d_out: std_logic_vector(video_addr_width-1 downto 0);
111
        signal accel_ram_dat_i: std_logic_vector(video_addr_width-1 downto 0);
112
        signal accel_ram_stb: std_logic;
113
        signal accel_ram_ack: std_logic;
114
        signal accel_ram_we: std_logic;
115
        signal accel_ram_clk: std_logic;
116
        signal next_cur: std_logic_vector(video_addr_width-1 downto 0);
117
        signal cur_update: std_logic := '0';
118
        signal mem_ack_o: std_logic := '1';
119
        signal mem_dat_o: std_logic_vector(data_width-1 downto 0);
120
        signal cur_ack_o: std_logic := '1';
121
        signal cur_dat_o: std_logic_vector(data_width-1 downto 0);
122
        signal ext_value: std_logic_vector(max(video_addr_width - data_width,1)-1 downto 0);
123
        signal ext_ext_we: std_logic;
124
begin
125
        accel_ram_stb <= acc_stb_i or mem_stb_i;
126
        accel_ram_we <= we_i and acc_stb_i;
127
        accel_ram_clk <= clk_i;
128 6 tantos
        accel_ram_dat_i(min2(video_addr_width-1
129
        ,data_width-1) downto 0) <=
130
            dat_i(min2(video_addr_width,data_width) - 1 downto 0);
131 4 tantos
        high_accel_dat_gen: if (video_addr_width > data_width) generate
132
                accel_ram_dat_i(video_addr_width-1 downto data_width) <= ext_value;
133
        end generate;
134
        accel_ram: wb_ram
135
                generic map (
136
                        data_width => video_addr_width,
137
                        addr_width => accel_size
138
                )
139
                port map (
140
                        clk_i => clk_i,
141
                        cyc_i => cyc_i,
142
                        stb_i => accel_ram_stb,
143
                        we_i => accel_ram_we,
144
                        adr_i => adr_i,
145
                        dat_i => accel_ram_dat_i,
146
                        dat_o => accel_ram_d_out,
147
                        ack_o => accel_ram_ack
148
                );
149
 
150 6 tantos
        v_stb_o <= mem_stb_i;
151 4 tantos
        v_cyc_o <= mem_stb_i and cyc_i;
152
        v_adr_o <= cursor;
153
        v_we_o <= we_i;
154
        v_dat_o <= dat_i;
155
 
156
        next_cur <= cursor + accel_ram_d_out;
157
 
158
        ext_ext_we <= acc_stb_i and not we_i;
159
        ext_reg_gen: if (video_addr_width > data_width) generate
160
                ext_reg: wb_io_reg
161
                        generic map (
162
                                width => video_addr_width - data_width,
163
                                bus_width => data_width,
164
                                offset => 0
165
                        )
166
                        port map (
167
                                clk_i => clk_i,
168
                                rst_i => rst_i,
169 6 tantos
                                rst_val => (video_addr_width - data_width-1 downto 0 => '0'),
170 4 tantos
 
171
                        cyc_i => cyc_i,
172
                                stb_i => ext_stb_i,
173
                        sel_i => sel_i,
174
                                we_i => we_i,
175
                                ack_o => ack_o,
176
                                ack_oi => cur_ack_o,
177
                                adr_i => adr_i(size2bits((video_addr_width-1)/data_width)-1 downto 0),
178
                                dat_i => dat_i,
179
                                dat_oi => cur_dat_o,
180
                                dat_o => dat_o,
181
                                q => ext_value,
182
                                ext_d => accel_ram_d_out(video_addr_width-1 downto data_width),
183
                                ext_we => ext_ext_we
184
                        );
185
        end generate;
186
        ext_gen: if (video_addr_width <= data_width) generate
187
                dat_o <= cur_dat_o;
188
                ack_o <= cur_ack_o;
189
                ext_value(0) <= '0';
190
        end generate;
191
 
192
        cur_reg: wb_io_reg
193 6 tantos
                generic map (
194
                        width => video_addr_width,
195
                        bus_width => data_width,
196
                        offset => 0
197
                )
198 4 tantos
                port map (
199
                        clk_i => clk_i,
200
                        rst_i => rst_i,
201 6 tantos
                        rst_val => (video_addr_width-1 downto 0 => '0'),
202 4 tantos
 
203
                cyc_i => cyc_i,
204
                        stb_i => cur_stb_i,
205
                sel_i => sel_i,
206
                        we_i => we_i,
207
                        ack_o => cur_ack_o,
208
                        ack_oi => mem_ack_o,
209
                        adr_i => adr_i(size2bits((video_addr_width+data_width-1)/data_width)-1 downto 0),
210
                        dat_i => dat_i,
211
                        dat_oi => mem_dat_o,
212
                        dat_o => cur_dat_o,
213
                        q => cursor,
214
                        ext_d => next_cur,
215
                        ext_we => cur_update
216
                );
217
 
218
        cur_update <= mem_stb_i and cyc_i and v_ack_i;
219
 
220 6 tantos
    v_sel_o <= sel_i;
221 4 tantos
        gen_dat_o: for i in dat_o'RANGE generate
222 6 tantos
        gen_dat_o1: if (i < video_addr_width) generate
223
                mem_dat_o(i) <= (
224
                        (cyc_i and ((accel_ram_d_out(i) and acc_stb_i) or (v_dat_i(i) and mem_stb_i))) or
225
                        (dat_oi(i) and ((not (acc_stb_i or mem_stb_i or cur_stb_i)) or (not cyc_i)))
226
                );
227
        end generate;
228
        gen_dat_o2: if (i >= video_addr_width) generate
229
                mem_dat_o(i) <= (
230
                        (cyc_i and (('0' and acc_stb_i) or (v_dat_i(i) and mem_stb_i))) or
231
                        (dat_oi(i) and ((not (acc_stb_i or mem_stb_i or cur_stb_i)) or (not cyc_i)))
232
                );
233
        end generate;
234 4 tantos
        end generate;
235
        mem_ack_o <= (
236
                (cyc_i and ((accel_ram_ack and acc_stb_i) or (v_ack_i and mem_stb_i))) or
237
                (ack_oi and ((not (acc_stb_i or mem_stb_i or cur_stb_i)) or (not cyc_i)))
238
        );
239
 
240
end accel;

powered by: WebSVN 2.1.0

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