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

Subversion Repositories wb_vga

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 tantos
--
2
--  Palette RAM.
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
--
10
--  wb_pal_ram
11
--
12
-------------------------------------------------------------------------------
13
 
14
library IEEE;
15
use IEEE.std_logic_1164.all;
16
 
17
library wb_tk;
18
use wb_tk.technology.all;
19
use wb_tk.all;
20
 
21
entity wb_pal_ram is
22
        generic (
23
                cpu_dat_width: positive := 8;
24
                cpu_adr_width: positive := 9;
25
                v_dat_width: positive := 16;
26
                v_adr_width: positive := 8
27
        );
28
        port (
29
-- Wishbone interface to CPU (write-only support)
30
        clk_i: in std_logic;
31
                rst_i: in std_logic := '0';
32
                adr_i: in std_logic_vector (cpu_adr_width-1 downto 0);
33
--              sel_i: in std_logic_vector ((cpu_dat_width/8)-1 downto 0) := (others => '1');
34
                dat_i: in std_logic_vector (cpu_dat_width-1 downto 0);
35
                dat_oi: in std_logic_vector (cpu_dat_width-1 downto 0) := (others => '-');
36
                dat_o: out std_logic_vector (cpu_dat_width-1 downto 0);
37
                cyc_i: in std_logic;
38
                ack_o: out std_logic;
39
                ack_oi: in std_logic := '-';
40
                err_o: out std_logic;
41
                err_oi: in std_logic := '-';
42
--              rty_o: out std_logic;
43
--              rty_oi: in std_logic := '-';
44
                we_i: in std_logic;
45
                stb_i: in std_logic;
46
-- Interface to the video output
47
        blank: in std_logic;
48
        v_dat_i: in std_logic_vector(v_adr_width-1 downto 0);
49
        v_dat_o: out std_logic_vector(v_dat_width-1 downto 0)
50
        );
51
end wb_pal_ram;
52
 
53
architecture wb_pal_ram of wb_pal_ram is
54
    component dpram
55
        generic (
56
                data_width : positive;
57
                addr_width : positive
58
        );
59
        port (
60
                clk : in std_logic;
61
 
62
                r_d_out : out std_logic_vector(data_width-1 downto 0);
63
                r_rd : in std_logic;
64
                r_clk_en : in std_logic;
65
                r_addr : in std_logic_vector(addr_width-1 downto 0);
66
 
67
                w_d_in : in std_logic_vector(data_width-1 downto 0);
68
                w_wr : in std_logic;
69
                w_clk_en : in std_logic;
70
                w_addr : in std_logic_vector(addr_width-1 downto 0)
71
        );
72
    end component;
73
 
74
        component wb_out_reg
75
        generic (
76
                width : positive := 8;
77
                bus_width: positive := 8;
78
                offset: integer := 0
79
        );
80
        port (
81
                clk_i: in std_logic;
82
                rst_i: in std_logic;
83
                rst_val: std_logic_vector(width-1 downto 0) := (others => '0');
84
 
85
        cyc_i: in std_logic := '1';
86
                stb_i: in std_logic;
87
        sel_i: in std_logic_vector ((bus_width/8)-1 downto 0) := (others => '1');
88
                we_i: in std_logic;
89
                ack_o: out std_logic;
90
                ack_oi: in std_logic := '-';
91
                adr_i: in std_logic_vector (size2bits((width+offset+bus_width-1)/bus_width)-1 downto 0) := (others => '0');
92
                dat_i: in std_logic_vector (bus_width-1 downto 0);
93
                dat_oi: in std_logic_vector (bus_width-1 downto 0) := (others => '-');
94
                dat_o: out std_logic_vector (bus_width-1 downto 0);
95
                q: out std_logic_vector (width-1 downto 0)
96
        );
97
        end component;
98
 
99
        signal mem_we: std_logic;
100
        signal mem_rd: std_logic;
101
        signal mem_d_in: std_logic_vector(v_dat_width-1 downto 0);
102
        signal ext_reg_stb: std_logic;
103
        signal mem_stb: std_logic;
104
    signal mem_d_out: std_logic_vector(v_dat_width-1 downto 0);
105
begin
106
    mem_stb_gen1: if (cpu_dat_width < v_dat_width) generate
107
        mem_stb <= '1' WHEN adr_i(cpu_adr_width-v_adr_width-1 downto 0)=(cpu_adr_width-v_adr_width-1 downto 0 =>'1') ELSE '0';
108
    end generate;
109
    mem_stb_gen2: if (cpu_dat_width >= v_dat_width) generate
110
        mem_stb <= '1';
111
    end generate;
112
    mem_we <= we_i and stb_i and cyc_i and mem_stb;
113
    mem_rd <= not blank;
114
    mem_d_in_gen1: if (cpu_dat_width < v_dat_width) generate
115
        mem_d_in(v_dat_width-1 downto v_dat_width-cpu_dat_width) <= dat_i;
116
    end generate;
117
    mem_d_in_gen2: if (cpu_dat_width >= v_dat_width) generate
118
        mem_d_in(v_dat_width-1 downto 0) <= dat_i(mem_d_in'RANGE);
119
    end generate;
120
    tech_ram: dpram
121
        generic map(
122
                data_width => v_dat_width,
123
                addr_width => v_adr_width
124
        )
125
        port map (
126
                clk => clk_i,
127
 
128
                r_d_out => mem_d_out,
129
                r_rd => mem_rd,
130
                r_clk_en => '1',
131
                r_addr => v_dat_i,
132
 
133
                w_d_in => mem_d_in,
134
                w_wr => mem_we,
135
                w_clk_en => '1',
136
                w_addr => adr_i(cpu_adr_width-1 downto cpu_adr_width-v_adr_width)
137
        );
138
    v_dat_o_gen: for i in v_dat_o'RANGE generate
139
        v_dat_o(i) <= mem_d_out(i) and not blank;
140
    end generate;
141
 
142
    ext_reg_stb <= we_i and stb_i and cyc_i and not mem_stb;
143
    ext_reg_gen: if (cpu_dat_width < v_dat_width) generate
144
        ext_reg: wb_out_reg
145
            generic map (
146
                        width => v_dat_width-cpu_dat_width,
147
                        bus_width => cpu_dat_width,
148
                        offset => 0
149
                )
150
                port map (
151
                        clk_i => clk_i,
152
                        rst_i => rst_i,
153
 
154
                cyc_i => cyc_i,
155
                        stb_i => ext_reg_stb,
156
                        we_i => we_i,
157
--                      ack_o
158
                        adr_i => adr_i(cpu_adr_width-v_adr_width-1 downto 0),
159
                        dat_i => dat_i,
160
                        q => mem_d_in(v_dat_width-cpu_dat_width-1 downto 0)
161
                );
162
    end generate;
163
 
164
    dat_o <= dat_oi;
165
    ack_o <= (     we_i  and (stb_i and cyc_i)) or (ack_oi and not (stb_i and cyc_i));
166
    err_o <= ((not we_i) and (stb_i and cyc_i)) or (err_oi and not (stb_i and cyc_i));
167
end wb_pal_ram;
168
 

powered by: WebSVN 2.1.0

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