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

Subversion Repositories raytrac

[/] [raytrac/] [trunk/] [arithpack.vhd] - Blame information for rev 49

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

Line No. Rev Author Line
1 23 jguarin200
--! @file arithpack.vhd
2 43 jguarin200
--! @author Julian Andres Guarin Reyes
3
--! @brief Este package contiene la descripcion de los parametros y los puertos de las entidades: uf, opcoder, multiplicador, sumador, cla_logic_block y rca_logic_block.
4 16 jguarin200
-- RAYTRAC
5
-- Author Julian Andres Guarin
6
-- arithpack.vhd
7
-- This file is part of raytrac.
8
-- 
9
--     raytrac is free software: you can redistribute it and/or modify
10
--     it under the terms of the GNU General Public License as published by
11
--     the Free Software Foundation, either version 3 of the License, or
12
--     (at your option) any later version.
13
-- 
14
--     raytrac is distributed in the hope that it will be useful,
15
--     but WITHOUT ANY WARRANTY; without even the implied warranty of
16
--     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
--     GNU General Public License for more details.
18
-- 
19
--     You should have received a copy of the GNU General Public License
20
--     along with raytrac.  If not, see <http://www.gnu.org/licenses/>.library ieee;
21
 
22
 
23 23 jguarin200
--! Biblioteca de definicion de senales y tipos estandares, comportamiento de operadores aritmeticos y logicos. 
24 22 jguarin200
library ieee;
25 23 jguarin200
--! Paquete de definicion estandard de logica.
26 2 jguarin200
use ieee.std_logic_1164.all;
27
 
28 49 jguarin200
--use ieee.std_logic_unsigned.conv_integer;
29
 
30
 
31 43 jguarin200
--! Biblioteca de definicion de memorias de altera
32
library altera_mf;
33
--! Paquete para manejar memorias internas tipo M9K
34 47 jguarin200
use altera_mf.all;
35 8 jguarin200
 
36 47 jguarin200
--! Biblioteca de modulos parametrizados.
37
library lpm;
38
use lpm.all;
39 49 jguarin200
 
40
--! Package de entrada y salida de texto.
41
use std.textio.all;
42
 
43
 
44
 
45 43 jguarin200
--! Package con las definiciones de constantes y entidades, que conformaran el Rt Engine. Tambien con algunas descripciones para realizar test bench.
46 8 jguarin200
 
47 23 jguarin200
--! En general el package cuenta con entidades para instanciar, multiplicadores, sumadores/restadores y un decodificador de operaciones. 
48 2 jguarin200
package arithpack is
49 10 jguarin200
 
50 45 jguarin200
        --! TestBenchState
51
        type tbState is (abcd,axb,cxd,stop);
52
 
53 23 jguarin200
        --! Constante con el nivel l—gico de reset.
54 15 jguarin200
        constant rstMasterValue : std_logic := '1';
55 40 jguarin200
 
56 49 jguarin200
        --! Constante: periodo del reloj;
57
        constant tclk : time := 20 ns;
58
        constant tclk2: time := tclk/2;
59
        constant tclk4: time := tclk/4;
60
 
61
 
62 42 jguarin200
        --! Generacion de Clock y de Reset.
63
        component clock_gen
64 49 jguarin200
                generic (tclk : time := tclk);
65 42 jguarin200
                port    (clk,rst : out std_logic);
66
        end component;
67
 
68 44 jguarin200
        --! Ray Trac: Implementacion del Rt Engine
69
        component raytrac
70
        generic (
71
 
72
                registered : string := "NO" --! Este parametro, por defecto "YES", indica si se registran o cargan en registros los vectores A,B,C,D y los codigos de operacion opcode y addcode en vez de ser conectados directamente al circuito combinatorio. \n This parameter, by default "YES", indicates if vectors A,B,C,D and operation code inputs opcode are to be loaded into a register at the beginning of the pipe rather than just connecting them to the operations decoder (opcoder). 
73
        );
74
        port (
75
                A,B,C,D                 : in std_logic_vector(18*3-1 downto 0); --! Vectores de entrada A,B,C,D, cada uno de tamano fijo: 3 componentes x 18 bits. \n Input vectors A,B,C,D, each one of fixed size: 3 components x 18 bits. 
76
                opcode,addcode  : in std_logic;                                                 --! Opcode and addcode input bits, opcode selects what operation is going to perform one of the entities included in the design and addcode what operands are going to be involved in such. \n Opcode & addcode, opcode selecciona que operacion se va a llevar a cabo dentro de una de las entidades referenciadas dentro de la descripcion, mientras que addcode decide cuales van a ser los operandos que realizaran tal. 
77
                clk,rst,ena                     : in std_logic;                                                 --! Las senales de control usual. The usual control signals.
78
                CPX,CPY,CPZ,DP0,DP1 : out std_logic_vector(31 downto 0)  --! Salidas que representan los resultados del RayTrac: pueden ser dos resultados, de dos operaciones de producto punto, o un producto cruz. Por favor revisar el documento de especificacion del dispositivo para tener mas claridad.\n  Outputs representing the result of the RayTrac entity: can be the results of two parallel dot product operations or the result of a single cross product, in order to clarify refere to the entity specification documentation.
79
 
80
 
81
        );
82
        end component;
83 42 jguarin200
 
84 47 jguarin200
        --! componente memoria instanciado mediante la biblioteca de altera
85 43 jguarin200
        component altsyncram
86 40 jguarin200
        generic (
87 43 jguarin200
                address_aclr_a          : string;
88
                clock_enable_input_a            : string;
89
                clock_enable_output_a           : string;
90
                init_file               : string;
91
                intended_device_family          : string;
92
                lpm_hint                : string;
93
                lpm_type                : string;
94
                numwords_a              : natural;
95
                operation_mode          : string;
96
                outdata_aclr_a          : string;
97
                outdata_reg_a           : string;
98
                ram_block_type          : string;
99
                widthad_a               : natural;
100
                width_a         : natural;
101
                width_byteena_a         : natural
102 40 jguarin200
        );
103 43 jguarin200
        port (
104
                        clock0  : in std_logic ;
105
                        address_a       : in std_logic_vector (8 downto 0);
106
                        q_a     : out std_logic_vector (17 downto 0)
107
        );
108
        end component;  --! Entidad uf: sus siglas significan undidad funcional. La unidad funcional se encarga de realizar las diferentes operaciones vectoriales (producto cruz — producto punto). 
109
 
110 8 jguarin200
        component uf
111 27 jguarin200
        generic (
112 32 jguarin200
                        use_std_logic_signed    : string := "NO";
113
                        carry_logic     : string := "CLA"
114 27 jguarin200
        );
115 8 jguarin200
        port (
116
                opcode          : in std_logic;
117 12 jguarin200
                m0f0,m0f1,m1f0,m1f1,m2f0,m2f1,m3f0,m3f1,m4f0,m4f1,m5f0,m5f1 : in std_logic_vector(17 downto 0);
118 13 jguarin200
                cpx,cpy,cpz,dp0,dp1 : out std_logic_vector(31 downto 0);
119 40 jguarin200
                        clk,rst         : in std_logic
120 8 jguarin200
        );
121
        end component;
122
 
123 23 jguarin200
        --! Entidad opcoder: opcoder decodifica la operaci—n que se va a realizar. Para tal fin coloca en la entrada de uf (unidad funcional), cuales van a ser los operandos de los multiplicadores con los que uf cuenta y adem‡s escribe en el selector de operaci—n de uf, el tipo de operaci—n a realizar.
124 8 jguarin200
        component opcoder
125 25 jguarin200
        generic (
126
                width : integer := 18;
127
                structuralDescription : string:= "NO"
128 26 jguarin200
        );
129 8 jguarin200
        port (
130
                Ax,Bx,Cx,Dx,Ay,By,Cy,Dy,Az,Bz,Cz,Dz : in std_logic_vector (17 downto 0);
131 14 jguarin200
                m0f0,m0f1,m1f0,m1f1,m2f0,m2f1,m3f0,m3f1,m4f0,m4f1,m5f0,m5f1 : out std_logic_vector (17 downto 0);
132 8 jguarin200
                opcode,addcode : in std_logic
133
        );
134
        end component;
135 24 jguarin200
 
136
        --! Multiplexor estructural.
137 26 jguarin200
        component fastmux is
138 24 jguarin200
        generic (
139
                width : integer := 18
140 26 jguarin200
        );
141 24 jguarin200
        port (
142 26 jguarin200
                a,b:in std_logic_vector(width-1 downto 0);
143 24 jguarin200
                s:in std_logic;
144 26 jguarin200
                c: out std_logic_vector(width-1 downto 0)
145
        );
146
        end component;
147 23 jguarin200
        --! Esta entidad corresponde al multiplicador que se instanciar’a dentro de la unidad funcional. El multiplicador registra los operandos a la entrada y el respectivo producto de la multiplicaci—n a la salida. 
148 2 jguarin200
        component r_a18_b18_smul_c32_r
149 47 jguarin200
        generic (
150
                lpm_hint                : string := "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9";
151
                lpm_pipeline    : natural:= 2;
152
                lpm_representation : string:="SIGNED";
153
                lpm_type                : string:="LPM_MULT";
154
                lpm_widtha              : natural:=18;
155
                lpm_widthb              : natural:=18;
156
                lpm_widthp              : natural:=32
157
        );
158 2 jguarin200
        port (
159
                aclr,clock:in std_logic;
160
                dataa,datab:in std_logic_vector (17 downto 0);
161
                result: out std_logic_vector(31 downto 0)
162
        );
163
        end component;
164 23 jguarin200
 
165
        --! cla_logic_block corresponde a un bloque de l—gica Carry look Ahead. Se instancia y utiliza dentro de un sumador cualquiera, pues sirve para calcular los carry out de la operaci—n. 
166 2 jguarin200
        component cla_logic_block
167 27 jguarin200
        generic ( width: integer:=4);
168 2 jguarin200
        port (
169 27 jguarin200
                p,g:in std_logic_vector(width-1 downto 0);
170 2 jguarin200
                cin:in std_logic;
171 27 jguarin200
                c:out std_logic_vector(width downto 1)
172 2 jguarin200
        );
173
        end component;
174 23 jguarin200
 
175
        --! rca_logic_block corresponde a un bloque de l—gica Ripple Carry Adder. Se instancia y utiliza dentro de un sumador cualquiera, pues sirve para calcular los carry out de la operaci—n.
176 2 jguarin200
        component rca_logic_block
177 27 jguarin200
        generic ( width : integer := 4);
178 2 jguarin200
        port (
179 27 jguarin200
                p,g: in std_logic_vector(width-1 downto 0);
180 2 jguarin200
                cin: in std_logic;
181 27 jguarin200
                c: out std_logic_vector(width downto 1)
182 2 jguarin200
        );
183
        end component;
184 23 jguarin200
 
185
        --! Entidad sumador. Esta entidad tiene un proposito bien claro: sumar. Es altamente parametrizable. Hay 3 cosas que se pueden parametrizar: el ancho del sumador, el tipo de circuito que queremos realice la suma y si el sumador estar‡ en capacidad de realizar mediante un selector restas.
186 2 jguarin200
        component adder
187
        generic (
188 27 jguarin200
                width                                   : integer := 4;
189 14 jguarin200
                carry_logic                             : string := "CLA";
190
                substractor_selector    : string := "YES"
191 2 jguarin200
        );
192
        port (
193 27 jguarin200
                a,b             :       in std_logic_vector (width-1 downto 0);
194 2 jguarin200
                s,ci    :       in      std_logic;
195 27 jguarin200
                result  :       out std_logic_vector (width-1 downto 0);
196 2 jguarin200
                cout    :       out std_logic
197
        );
198
        end component;
199 49 jguarin200
 
200
 
201
        procedure hexwrite_0(l:inout line; h: in std_logic_vector);
202
 
203 2 jguarin200
end package;
204 49 jguarin200
 
205
package body arithpack is
206
        --! Funciones utilitarias, relacionadas sobre todo con el testbench
207
        constant hexchars : string (1 to 16) := "0123456789ABCDEF";
208
 
209
        procedure hexwrite_0(l:inout line;h:in std_logic_vector) is
210
                variable index_high,index_low,acc : integer;
211
        begin
212
                for i in (h'high)/4 downto 0 loop
213
                        index_low:=i*4;
214
                        if (index_low+3)>h'high then
215
                                index_high := h'high;
216
                        else
217
                                index_high := i*4+3;
218
                        end if;
219
                        write(l,hexchars(1+ieee.std_logic_unsigned.conv_integer(h(index_high downto index_low))));
220
                end loop;
221
        end procedure;
222
end package body arithpack;

powered by: WebSVN 2.1.0

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