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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [processor/] [VHDL/] [scarts_core/] [dram.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 jlechner
-----------------------------------------------------------------------
2
-- This file is part of SCARTS.
3
-- 
4
-- SCARTS is free software: you can redistribute it and/or modify
5
-- it under the terms of the GNU General Public License as published by
6
-- the Free Software Foundation, either version 3 of the License, or
7
-- (at your option) any later version.
8
-- 
9
-- SCARTS is distributed in the hope that it will be useful,
10
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-- GNU General Public License for more details.
13
-- 
14
-- You should have received a copy of the GNU General Public License
15
-- along with SCARTS.  If not, see <http://www.gnu.org/licenses/>.
16
-----------------------------------------------------------------------
17
 
18
 
19
library ieee;
20
use ieee.std_logic_1164.all;
21
use ieee.numeric_std.all;
22
 
23
use work.scarts_core_pkg.all;
24
use work.scarts_pkg.all;
25
 
26
entity scarts_dram is
27
  generic (
28
    CONF : scarts_conf_type);
29
  port (
30
    clk     : in  std_ulogic;
31
    hold    : in  std_ulogic;
32
    dramsel : in  std_ulogic;
33
 
34
    write_en  : in  std_ulogic;
35
    byte_en   : in  std_logic_vector(3 downto 0);
36
    data_in   : in  std_logic_vector(31 downto 0);
37
    addr      : in  std_logic_vector(CONF.data_ram_size-1 downto 2);
38
 
39
    data_out  : out std_logic_vector(31 downto 0));
40
end scarts_dram;
41
 
42
 
43
architecture behaviour of scarts_dram is
44
 
45
  constant WORD_W : natural := CONF.word_size;
46
 
47
  subtype WORD is std_logic_vector(WORD_W-1 downto 0);
48
 
49
  signal ram0i_wdata   : std_logic_vector(7 downto 0);
50
  signal ram0i_waddr   : std_logic_vector((CONF.data_ram_size-3) downto 0);
51
  signal ram0i_wen     : std_ulogic;
52
  signal ram0i_raddr   : std_logic_vector((CONF.data_ram_size-3) downto 0);
53
 
54
  signal ram1i_wdata   : std_logic_vector(7 downto 0);
55
  signal ram1i_waddr   : std_logic_vector((CONF.data_ram_size-3) downto 0);
56
  signal ram1i_wen     : std_ulogic;
57
  signal ram1i_raddr   : std_logic_vector((CONF.data_ram_size-3) downto 0);
58
 
59
  signal ram2i_wdata   : std_logic_vector(7 downto 0);
60
  signal ram2i_waddr   : std_logic_vector((CONF.data_ram_size-3) downto 0);
61
  signal ram2i_wen     : std_ulogic;
62
  signal ram2i_raddr   : std_logic_vector((CONF.data_ram_size-3) downto 0);
63
 
64
  signal ram3i_wdata   : std_logic_vector(7 downto 0);
65
  signal ram3i_waddr   : std_logic_vector((CONF.data_ram_size-3) downto 0);
66
  signal ram3i_wen     : std_ulogic;
67
  signal ram3i_raddr   : std_logic_vector((CONF.data_ram_size-3) downto 0);
68
 
69
  signal ram0o_rdata    : std_logic_vector(7 downto 0);
70
  signal ram1o_rdata    : std_logic_vector(7 downto 0);
71
  signal ram2o_rdata    : std_logic_vector(7 downto 0);
72
  signal ram3o_rdata    : std_logic_vector(7 downto 0);
73
 
74
  signal enable : std_ulogic;
75
 
76
begin
77
 
78
 
79
  comb : process(dramsel, byte_en, write_en, addr, data_in,
80
                 ram0o_rdata, ram1o_rdata, ram2o_rdata, ram3o_rdata)
81
  begin
82
 
83
    ram0i_wdata <= (others => '0');
84
    ram1i_wdata <= (others => '0');
85
    ram2i_wdata <= (others => '0');
86
    ram3i_wdata <= (others => '0');
87
    ram0i_raddr <= (others => '0');
88
    ram1i_raddr <= (others => '0');
89
    ram2i_raddr <= (others => '0');
90
    ram3i_raddr <= (others => '0');
91
    ram0i_waddr <= (others => '0');
92
    ram1i_waddr <= (others => '0');
93
    ram2i_waddr <= (others => '0');
94
    ram3i_waddr <= (others => '0');
95
 
96
    if (dramsel = '1') then
97
      ram0i_wen <= byte_en(0) and write_en;
98
      ram1i_wen <= byte_en(1) and write_en;
99
      ram2i_wen <= byte_en(2) and write_en;
100
      ram3i_wen <= byte_en(3) and write_en;
101
    else
102
      ram0i_wen <= not MEM_WR;
103
      ram1i_wen <= not MEM_WR;
104
      ram2i_wen <= not MEM_WR;
105
      ram3i_wen <= not MEM_WR;
106
    end if;
107
 
108
    ram0i_raddr(CONF.data_ram_size-3 downto 0) <= addr(CONF.data_ram_size-1 downto 2);
109
    ram1i_raddr(CONF.data_ram_size-3 downto 0) <= addr(CONF.data_ram_size-1 downto 2);
110
    ram2i_raddr(CONF.data_ram_size-3 downto 0) <= addr(CONF.data_ram_size-1 downto 2);
111
    ram3i_raddr(CONF.data_ram_size-3 downto 0) <= addr(CONF.data_ram_size-1 downto 2);
112
    ram0i_waddr(CONF.data_ram_size-3 downto 0) <= addr(CONF.data_ram_size-1 downto 2);
113
    ram1i_waddr(CONF.data_ram_size-3 downto 0) <= addr(CONF.data_ram_size-1 downto 2);
114
    ram2i_waddr(CONF.data_ram_size-3 downto 0) <= addr(CONF.data_ram_size-1 downto 2);
115
    ram3i_waddr(CONF.data_ram_size-3 downto 0) <= addr(CONF.data_ram_size-1 downto 2);
116
 
117
    ram0i_wdata <= data_in( 7 downto  0);
118
    ram1i_wdata <= data_in(15 downto  8);
119
    ram2i_wdata <= data_in(23 downto 16);
120
    ram3i_wdata <= data_in(31 downto 24);
121
 
122
    data_out( 7 downto  0) <= ram0o_rdata;
123
    data_out(15 downto  8) <= ram1o_rdata;
124
    data_out(23 downto 16) <= ram2o_rdata;
125
    data_out(31 downto 24) <= ram3o_rdata;
126
 
127
  end process;
128
 
129
  enable <= not hold;
130
 
131
  ram0 : scarts_byteram
132
    generic map (CONF => CONF)
133
    port map (wclk   => clk,
134
              rclk   => clk,
135
              enable => enable,
136
              wdata  => ram0i_wdata,
137
              waddr  => ram0i_waddr,
138
              wen    => ram0i_wen,
139
              raddr  => ram0i_raddr,
140
              rdata  => ram0o_rdata);
141
 
142
  ram1 : scarts_byteram
143
    generic map (CONF => CONF)
144
    port map (wclk   => clk,
145
              rclk   => clk,
146
              enable => enable,
147
              wdata  => ram1i_wdata,
148
              waddr  => ram1i_waddr,
149
              wen    => ram1i_wen,
150
              raddr  => ram1i_raddr,
151
              rdata  => ram1o_rdata);
152
 
153
  ram2 : scarts_byteram
154
    generic map (CONF => CONF)
155
    port map (wclk   => clk,
156
              rclk   => clk,
157
              enable => enable,
158
              wdata  => ram2i_wdata,
159
              waddr  => ram2i_waddr,
160
              wen    => ram2i_wen,
161
              raddr  => ram2i_raddr,
162
              rdata  => ram2o_rdata);
163
 
164
  ram3 : scarts_byteram
165
    generic map (CONF => CONF)
166
    port map (wclk   => clk,
167
              rclk   => clk,
168
              enable => enable,
169
              wdata  => ram3i_wdata,
170
              waddr  => ram3i_waddr,
171
              wen    => ram3i_wen,
172
              raddr  => ram3i_raddr,
173
              rdata  => ram3o_rdata);
174
 
175
--  xilinx_gen : if (TECH_C = XILINX) generate
176
--    data_ram_inst: xilinx_data_ram
177
--      port map (
178
--        clk     => clk,
179
--        enable  => enable,
180
--        ram0i    => ram0i,
181
--        ram0o    => ram0o,
182
--        ram1i    => ram1i,
183
--        ram1o    => ram1o,
184
--        ram2i    => ram2i,
185
--        ram2o    => ram2o,
186
--        ram3i    => ram3i,
187
--        ram3o    => ram3o
188
--      );
189
--  end generate;
190
 
191
--  altera_gen : if (TECH_C = ALTERA) generate
192
--    ram0 : scarts_byteram
193
--    port map (clk, clk, enable, ram0i, ram0o);
194
 
195
--    ram1 : scarts_byteram
196
--    port map (clk, clk, enable, ram1i, ram1o);
197
 
198
--    ram2 : scarts_byteram
199
--    port map (clk, clk, enable, ram2i, ram2o);
200
 
201
--    ram3 : scarts_byteram
202
--    port map (clk, clk, enable, ram3i, ram3o);
203
--  end generate;
204
 
205
 
206
 
207
end behaviour;

powered by: WebSVN 2.1.0

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