1 |
128 |
jguarin200 |
--! @file memblock.vhd
|
2 |
|
|
--! @brief Bloque de memoria.
|
3 |
|
|
--! @author Julián Andrés Guarín Reyes
|
4 |
|
|
--------------------------------------------------------------
|
5 |
|
|
-- RAYTRAC
|
6 |
|
|
-- Author Julian Andres Guarin
|
7 |
|
|
-- memblock.vhd
|
8 |
|
|
-- This file is part of raytrac.
|
9 |
|
|
--
|
10 |
|
|
-- raytrac is free software: you can redistribute it and/or modify
|
11 |
|
|
-- it under the terms of the GNU General Public License as published by
|
12 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
13 |
|
|
-- (at your option) any later version.
|
14 |
|
|
--
|
15 |
|
|
-- raytrac is distributed in the hope that it will be useful,
|
16 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
|
|
-- GNU General Public License for more details.
|
19 |
|
|
--
|
20 |
|
|
-- You should have received a copy of the GNU General Public License
|
21 |
|
|
-- along with raytrac. If not, see <http://www.gnu.org/licenses/>.
|
22 |
|
|
|
23 |
|
|
library ieee;
|
24 |
|
|
use ieee.std_logic_1164.all;
|
25 |
129 |
jguarin200 |
|
26 |
128 |
jguarin200 |
entity memblock is
|
27 |
|
|
generic (
|
28 |
129 |
jguarin200 |
|
29 |
|
|
width : integer := 32;
|
30 |
|
|
blocksize : integer := 512;
|
31 |
|
|
widthadmemblock : integer :=9;
|
32 |
|
|
|
33 |
|
|
external_writeable_blocks : integer := 12;
|
34 |
|
|
external_readable_blocks : integer := 8;
|
35 |
|
|
external_readable_widthad : integer := 3;
|
36 |
|
|
external_writeable_widthad : integer := 4
|
37 |
128 |
jguarin200 |
);
|
38 |
|
|
port (
|
39 |
|
|
|
40 |
129 |
jguarin200 |
clk,dpfifo_flush,normfifo_flush,dpfifo_rd,normfifo_rd,dpfifo_wr,normfifo_wr : in std_logic;
|
41 |
|
|
ext_rd,ext_wr,int_wr,int_rd : in std_logic;
|
42 |
|
|
dpfifo_empty, normfifo_empty, dpfifo_full, normfifo_full : out std_logic;
|
43 |
128 |
jguarin200 |
|
44 |
129 |
jguarin200 |
ext_wr_add : in std_logic_vector(external_writeable_widthad+widthadmemblock-1 downto 0);
|
45 |
|
|
ext_rd_add : in std_logic_vector(external_readable_widthad+widthadmemblock-1 downto 0);
|
46 |
|
|
ext_d: in std_logic_vector(width-1 downto 0);
|
47 |
|
|
int_d : in std_logic_vector(external_readable_blocks*width-1 downto 0);
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
ext_q : out std_logic_vector(width-1 downto 0);
|
51 |
|
|
int_q : out std_logic_vector(external_writeable_blocks*width-1 downto 0);
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
int_rd_add, int_wr_add : in std_logic_vector(widthadmemblock-1 downto 0);
|
55 |
|
|
|
56 |
|
|
dpfifo_d : in std_logic_vector(width*2-1 downto 0);
|
57 |
|
|
normfifo_d : in std_logic_vector(width*3-1 downto 0);
|
58 |
|
|
dpfifo_q : out std_logic_vector(width*2-1 downto 0);
|
59 |
|
|
normfifo_q : out std_logic_vector(width*3-1 downto 0)
|
60 |
128 |
jguarin200 |
);
|
61 |
|
|
end memblock;
|
62 |
|
|
|
63 |
|
|
architecture memblock_arch of memblock is
|
64 |
|
|
|
65 |
129 |
jguarin200 |
|
66 |
128 |
jguarin200 |
component scfifo
|
67 |
|
|
generic (
|
68 |
|
|
add_ram_output_register :string;
|
69 |
|
|
intended_device_family :string;
|
70 |
|
|
lpm_hint :string;
|
71 |
|
|
lpm_numwords :natural;
|
72 |
|
|
lpm_showahead :string;
|
73 |
|
|
lpm_type :string;
|
74 |
|
|
lpm_width :natural;
|
75 |
|
|
lpm_widthu :natural;
|
76 |
|
|
overflow_checking :string;
|
77 |
|
|
underflow_checking :string;
|
78 |
|
|
use_eab :string
|
79 |
|
|
);
|
80 |
|
|
port(
|
81 |
|
|
rdreq : in std_logic;
|
82 |
129 |
jguarin200 |
aclr : in std_logic;
|
83 |
128 |
jguarin200 |
empty : out std_logic;
|
84 |
|
|
clock : in std_logic;
|
85 |
|
|
q : out std_logic_vector(width-1 downto 0);
|
86 |
|
|
wrreq : in std_logic;
|
87 |
|
|
data : in std_logic_vector(width-1 downto 0);
|
88 |
|
|
full : out std_logic
|
89 |
|
|
);
|
90 |
|
|
end component;
|
91 |
129 |
jguarin200 |
|
92 |
|
|
component altsyncram
|
93 |
|
|
generic (
|
94 |
|
|
address_aclr_b : string;
|
95 |
|
|
address_reg_b : string;
|
96 |
|
|
clock_enable_input_a : string;
|
97 |
|
|
clock_enable_input_b : string;
|
98 |
|
|
clock_enable_output_b : string;
|
99 |
|
|
intended_device_family : string;
|
100 |
|
|
lpm_type : string;
|
101 |
|
|
numwords_a : natural;
|
102 |
|
|
numwords_b : natural;
|
103 |
|
|
operation_mode : string;
|
104 |
|
|
outdata_aclr_b : string;
|
105 |
|
|
outdata_reg_b : string;
|
106 |
|
|
power_up_uninitialized : string;
|
107 |
|
|
ram_block_type : string;
|
108 |
|
|
rdcontrol_reg_b : string;
|
109 |
|
|
read_during_write_mode_mixed_ports : string;
|
110 |
|
|
widthad_a : natural;
|
111 |
|
|
widthad_b : natural;
|
112 |
|
|
width_a : natural;
|
113 |
|
|
width_b : natural;
|
114 |
|
|
width_byteena_a : natural
|
115 |
|
|
);
|
116 |
|
|
port (
|
117 |
|
|
wren_a : in std_logic;
|
118 |
|
|
clock0 : in std_logic;
|
119 |
|
|
address_a : in std_logic_vector(widthad_a-1 downto 0);
|
120 |
|
|
address_b : in std_logic_vector(widthad_b-1 downto 0);
|
121 |
|
|
rden_b : in std_logic;
|
122 |
|
|
q_b : out std_logic_vector(width-1 downto 0);
|
123 |
|
|
data_a : in std_logic_vector(width-1 downto 0)
|
124 |
|
|
|
125 |
|
|
);
|
126 |
|
|
end component;
|
127 |
|
|
signal s0ext_wr_add_one_hot : std_logic_vector(external_writeable_blocks-1 downto 0);
|
128 |
|
|
signal s0ext_rd_add_one_hot : std_logic_vector(external_readable_blocks-1 downto 0);
|
129 |
|
|
|
130 |
|
|
signal s0ext_wr_add : std_logic_vector(external_writeable_widthad+widthadmemblock-1 downto 0);
|
131 |
|
|
signal s0int_rd_add : std_logic_vector(widthadmemblock-1 downto 0);
|
132 |
|
|
signal s0int_wr_add : std_logic_vector(widthadmemblock-1 downto 0);
|
133 |
|
|
signal s0ext_wr : std_logic;
|
134 |
|
|
|
135 |
128 |
jguarin200 |
begin
|
136 |
|
|
|
137 |
|
|
dpfifo : scfifo
|
138 |
129 |
jguarin200 |
generic map ("OFF","Cyclone III","RAM_BLOCK_TYPE=M9K",9,"OFF","SCFIFO",width*2,4,"OFF","OFF","ON")
|
139 |
|
|
port map (dpfifo_rd,dpfifo_flush,dpfifo_empty,clk,dpfifo_q,dpfifo_wr,dpfifo_d,dpfifo_full);
|
140 |
128 |
jguarin200 |
normfifo : scfifo
|
141 |
129 |
jguarin200 |
generic map ("OFF","Cyclone III","RAM_BLOCK_TYPE=M9K",26,"OFF","SCFIFO",width*3,5,"OFF","OFF","ON")
|
142 |
|
|
port map (normfifo_rd,normfifo_flush,normfifo_empty,clk,normfifo_q,normfifo_wr,normfifo_d,normfifo_full);
|
143 |
128 |
jguarin200 |
|
144 |
129 |
jguarin200 |
mblocks:
|
145 |
|
|
for i in 11 downto 0 generate
|
146 |
|
|
operandsblock : altsyncram
|
147 |
|
|
generic map ("NONE","CLOCK0","BYPASS","BYPASS","BYPASS","Cyclone III","altsyncram",2**widthadmemblock,2**widthadmemblock,"DUAL_PORT","NONE","CLOCK0","FALSE","M9K","CLOCK0","OLD_DATA",widthadmemblock,widthadmemblock,width,width,1);
|
148 |
|
|
generic port(s0ext_wr_add_one_hot(i),clk,s0ext_wr_add(widthadmemblock-1 downto 0), s0int_rd_add, int_rd, , memblock_q);
|
149 |
|
|
end generate mblocks;
|
150 |
128 |
jguarin200 |
|
151 |
129 |
jguarin200 |
process (clk)
|
152 |
|
|
begin
|
153 |
|
|
if clk'event and clk='1' then
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
--! Registro
|
157 |
|
|
s0ext_wr_add <= ext_wr_add;
|
158 |
|
|
s0ext_wr <= ext_wr;
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
case s0ext_wr_add((external_writeable_widthad+widthadmemblock-1 downto widthadmemblock) is
|
162 |
|
|
when x"0" => s0ext_wr_add_one_hot <= '0'&x"00"&"000"&s0ext_wr;
|
163 |
|
|
when x"1" => s0ext_wr_add_one_hot <= '0'&x"00"&"00"&s0ext_wr&'0';
|
164 |
|
|
when x"2" => s0ext_wr_add_one_hot <= '0'&x"00"&'0'&s0ext_wr&"00";
|
165 |
|
|
when x"3" => s0ext_wr_add_one_hot <= '0'&x"00"&s0ext_wr&"000";
|
166 |
|
|
when x"4" => s0ext_wr_add_one_hot <= '0'&x"0"&"000"&s0ext_wr&x"0";
|
167 |
|
|
when x"5" => s0ext_wr_add_one_hot <= '0'&x"0"&"00"&s0ext_wr&'0'&x"0";
|
168 |
|
|
when x"6" => s0ext_wr_add_one_hot <= '0'&x"0"&'0'&s0ext_wr&"00"&x"0";
|
169 |
|
|
when x"7" => s0ext_wr_add_one_hot <= '0'&x"0"&s0ext_wr&"000"&x"0";
|
170 |
|
|
when x"8" => s0ext_wr_add_one_hot <= '0'&"000"&s0ext_wr&x"00";
|
171 |
|
|
when x"9" => s0ext_wr_add_one_hot <= '0'&"00"&s0ext_wr&'0'&x"00";
|
172 |
|
|
when x"A" => s0ext_wr_add_one_hot <= '0'&'0'&s0ext_wr&"00"&x"00";
|
173 |
|
|
when x"B" => s0ext_wr_add_one_hot <= '0'&s0ext_wr&"000"&x"00";
|
174 |
|
|
when others => s0ext_wr_add_one_hot <= s0ext_wr&x"000";
|
175 |
|
|
end case;
|
176 |
|
|
case ('0'&s0ext_rd_add) is
|
177 |
|
|
when x"0" => s0ext_rd_add_one_hot <= x"0"&"000"&ext_rd;
|
178 |
|
|
when x"1" => s0ext_rd_add_one_hot <= x"0"&"00"&ext_rd&'0';
|
179 |
|
|
when x"2" => s0ext_rd_add_one_hot <= x"0"&'0'&ext_rd&"00";
|
180 |
|
|
when x"3" => s0ext_rd_add_one_hot <= x"0"&ext_rd&"000";
|
181 |
|
|
when x"4" => s0ext_rd_add_one_hot <= "000"&ext_rd&x"0";
|
182 |
|
|
when x"5" => s0ext_rd_add_one_hot <= "00"&ext_rd&'0'&x"0";
|
183 |
|
|
when x"6" => s0ext_rd_add_one_hot <= '0'&ext_rd&"00"&x"0";
|
184 |
|
|
when others => s0ext_rd_add_one_hot <= ext_rd&"000"&x"0";
|
185 |
|
|
end case;
|
186 |
|
|
end if;
|
187 |
|
|
end process;
|
188 |
128 |
jguarin200 |
end memblock_arch;
|
189 |
|
|
|