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

Subversion Repositories raytrac

[/] [raytrac/] [branches/] [fp/] [memblock.vhd] - Blame information for rev 131

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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
                dpfifo_empty, normfifo_empty, dpfifo_full, normfifo_full : out std_logic;
42 131 jguarin200
                ext_rd,ext_wr,int_wr: in std_logic;
43 129 jguarin200
                ext_wr_add : in std_logic_vector(external_writeable_widthad+widthadmemblock-1 downto 0);
44
                ext_rd_add : in std_logic_vector(external_readable_widthad+widthadmemblock-1 downto 0);
45
                ext_d: in std_logic_vector(width-1 downto 0);
46
                int_d : in std_logic_vector(external_readable_blocks*width-1 downto 0);
47
                ext_q : out std_logic_vector(width-1 downto 0);
48
                int_q : out std_logic_vector(external_writeable_blocks*width-1 downto 0);
49 130 jguarin200
                int_wr_add : in std_logic_vector(widthadmemblock-1 downto 0);
50
                int_rd_add : in std_logic_vector(2*widthadmemblock-1 downto 0);
51 129 jguarin200
                dpfifo_d : in std_logic_vector(width*2-1 downto 0);
52
                normfifo_d : in std_logic_vector(width*3-1 downto 0);
53
                dpfifo_q : out std_logic_vector(width*2-1 downto 0);
54
                normfifo_q : out std_logic_vector(width*3-1 downto 0)
55 128 jguarin200
        );
56
end memblock;
57
 
58
architecture memblock_arch of memblock is
59
 
60 130 jguarin200
        type    vectorblock12 is array (11 downto 0) of std_logic_vector(width-1 downto 0);
61
        type    vectorblock08 is array (07 downto 0) of std_logic_vector(width-1 downto 0);
62
        type    vectorblock02 is array (01 downto 0) of std_logic_vector(widthadmemblock-1 downto 0);
63 129 jguarin200
 
64 128 jguarin200
        component scfifo
65
        generic (
66
                add_ram_output_register :string;
67
                intended_device_family  :string;
68
                lpm_hint                                :string;
69
                lpm_numwords                    :natural;
70
                lpm_showahead                   :string;
71
                lpm_type                                :string;
72
                lpm_width                               :natural;
73
                lpm_widthu                              :natural;
74
                overflow_checking               :string;
75
                underflow_checking              :string;
76
                use_eab                                 :string
77
        );
78
        port(
79
                rdreq   : in std_logic;
80 129 jguarin200
                aclr    : in std_logic;
81 128 jguarin200
                empty   : out std_logic;
82
                clock   : in std_logic;
83 130 jguarin200
                q               : out std_logic_vector(lpm_width-1 downto 0);
84 128 jguarin200
                wrreq   : in std_logic;
85 130 jguarin200
                data    : in std_logic_vector(lpm_width-1 downto 0);
86 128 jguarin200
                full    : out std_logic
87
        );
88
        end component;
89 129 jguarin200
 
90
        component altsyncram
91
        generic (
92
                address_aclr_b                  : string;
93
                address_reg_b                   : string;
94
                clock_enable_input_a    : string;
95
                clock_enable_input_b    : string;
96
                clock_enable_output_b   : string;
97
                intended_device_family  : string;
98
                lpm_type                                : string;
99
                numwords_a                              : natural;
100
                numwords_b                              : natural;
101
                operation_mode                  : string;
102
                outdata_aclr_b                  : string;
103
                outdata_reg_b                   : string;
104
                power_up_uninitialized  : string;
105
                ram_block_type                  : string;
106
                rdcontrol_reg_b                 : string;
107
                read_during_write_mode_mixed_ports      : string;
108
                widthad_a                               : natural;
109
                widthad_b                               : natural;
110
                width_a                                 : natural;
111
                width_b                                 : natural;
112
                width_byteena_a                 : natural
113
        );
114
        port (
115
                wren_a          : in std_logic;
116
                clock0          : in std_logic;
117
                address_a       : in std_logic_vector(widthad_a-1 downto 0);
118
                address_b       : in std_logic_vector(widthad_b-1 downto 0);
119
                rden_b          : in std_logic;
120
                q_b                     : out std_logic_vector(width-1 downto 0);
121
                data_a          : in std_logic_vector(width-1 downto 0)
122
 
123
        );
124
        end component;
125
        signal s0ext_wr_add_one_hot : std_logic_vector(external_writeable_blocks-1 downto 0);
126
        signal s0ext_wr_add                     : std_logic_vector(external_writeable_widthad+widthadmemblock-1 downto 0);
127 130 jguarin200
        signal s0ext_rd_add                     : std_logic_vector(external_readable_widthad-1 downto 0);
128 129 jguarin200
        signal s0int_rd_add                     : std_logic_vector(widthadmemblock-1 downto 0);
129
        signal s0int_wr_add                     : std_logic_vector(widthadmemblock-1 downto 0);
130
        signal s0ext_wr                         : std_logic;
131 130 jguarin200
        signal s0ext_d                          : std_logic_vector(width-1 downto 0);
132
 
133
        signal s1ext_rd_add                     : std_logic_vector(external_readable_widthad-1 downto 0);
134
        signal s1ext_q,sint_d           : vectorblock08;
135
        signal sint_rd_add                      : vectorblock02;
136
        signal s1int_q                          : vectorblock12;
137
 
138 128 jguarin200
begin
139
 
140
        dpfifo : scfifo
141 130 jguarin200
        generic map ("OFF","Cyclone III","RAM_BLOCK_TYPE=M9K",9,"OFF","SCFIFO",64,4,"OFF","OFF","ON")
142 129 jguarin200
        port    map (dpfifo_rd,dpfifo_flush,dpfifo_empty,clk,dpfifo_q,dpfifo_wr,dpfifo_d,dpfifo_full);
143 128 jguarin200
        normfifo : scfifo
144 130 jguarin200
        generic map ("OFF","Cyclone III","RAM_BLOCK_TYPE=M9K",26,"OFF","SCFIFO",96,5,"OFF","OFF","ON")
145 129 jguarin200
        port    map (normfifo_rd,normfifo_flush,normfifo_empty,clk,normfifo_q,normfifo_wr,normfifo_d,normfifo_full);
146 128 jguarin200
 
147 130 jguarin200
        sint_rd_add (0)<= int_rd_add(widthadmemblock-1 downto 0);
148
        sint_rd_add (1)<= int_rd_add(2*widthadmemblock-1 downto widthadmemblock);
149
 
150
        results_blocks:
151
        for i in 7 downto 0 generate
152
                sint_d(i) <= int_d((i+1)*width-1 downto i*width);
153
                resultsblock : altsyncram
154
                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)
155 131 jguarin200
                port    map (int_wr,clk,int_wr_add,ext_rd_add(widthadmemblock-1 downto 0),ext_rd,s1ext_q(i),sint_d(i));
156 130 jguarin200
        end generate results_blocks;
157
 
158
        operands_blocks:
159 129 jguarin200
        for i in 11 downto 0 generate
160 130 jguarin200
                int_q((i+1)*width-1 downto width*i) <= s1int_q(i);
161 129 jguarin200
                operandsblock : altsyncram
162 130 jguarin200
                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)
163 131 jguarin200
                port    map (s0ext_wr_add_one_hot(i),clk,s0ext_wr_add(widthadmemblock-1 downto 0),sint_rd_add((i/3) mod 2),'1',s1int_q(i),s0ext_d);
164 130 jguarin200
        end generate operands_blocks;
165 128 jguarin200
 
166 130 jguarin200
 
167
        operands_block_proc: process (clk)
168 129 jguarin200
        begin
169
                if clk'event and clk='1' then
170 130 jguarin200
                         --! Registro de entrada
171 129 jguarin200
                         s0ext_wr_add <= ext_wr_add;
172
                         s0ext_wr  <= ext_wr;
173 130 jguarin200
                         s0ext_d  <= ext_d;
174
                        --! Etapa 0: Decodificacion de las se&ntilde:ales de escritura.
175
                        case s0ext_wr_add(external_writeable_widthad+widthadmemblock-1 downto widthadmemblock) is
176
                                when x"0" => s0ext_wr_add_one_hot <= x"00"&"000"&s0ext_wr;
177
                                when x"1" => s0ext_wr_add_one_hot <= x"00"&"00"&s0ext_wr&'0';
178
                                when x"2" => s0ext_wr_add_one_hot <= x"00"&'0'&s0ext_wr&"00";
179
                                when x"3" => s0ext_wr_add_one_hot <= x"00"&s0ext_wr&"000";
180
                                when x"4" => s0ext_wr_add_one_hot <= x"0"&"000"&s0ext_wr&x"0";
181
                                when x"5" => s0ext_wr_add_one_hot <= x"0"&"00"&s0ext_wr&'0'&x"0";
182
                                when x"6" => s0ext_wr_add_one_hot <= x"0"&'0'&s0ext_wr&"00"&x"0";
183
                                when x"7" => s0ext_wr_add_one_hot <= x"0"&s0ext_wr&"000"&x"0";
184
                                when x"8" => s0ext_wr_add_one_hot <= "000"&s0ext_wr&x"00";
185
                                when x"9" => s0ext_wr_add_one_hot <= "00"&s0ext_wr&'0'&x"00";
186
                                when x"A" => s0ext_wr_add_one_hot <= '0'&s0ext_wr&"00"&x"00";
187
                                when others => s0ext_wr_add_one_hot <= s0ext_wr&"000"&x"00";
188 129 jguarin200
                        end case;
189
                end if;
190
        end process;
191 130 jguarin200
        results_block_proc: process(clk)
192
        begin
193
                if clk'event and clk='1' then
194
                        --!Registrar entrada
195
                        s0ext_rd_add <= ext_rd_add(external_readable_widthad+widthadmemblock-1 downto widthadmemblock);
196
                        --!Etapa 0: Leer memorias
197
                        s1ext_rd_add <= s0ext_rd_add;
198
                        --!Etapa 1: Seleccionar dato a leer;
199
                        case '0'&s1ext_rd_add is
200
                                when x"0" => ext_q <= s1ext_q(0);
201
                                when x"1" => ext_q <= s1ext_q(1);
202
                                when x"2" => ext_q <= s1ext_q(2);
203
                                when x"3" => ext_q <= s1ext_q(3);
204
                                when x"4" => ext_q <= s1ext_q(4);
205
                                when x"5" => ext_q <= s1ext_q(5);
206
                                when x"6" => ext_q <= s1ext_q(6);
207
                                when others => ext_q <= s1ext_q(7);
208
                        end case;
209
                end if;
210
        end process;
211 128 jguarin200
end memblock_arch;
212
 

powered by: WebSVN 2.1.0

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