1 |
22 |
jguarin200 |
--! @file raytrac.vhd
|
2 |
67 |
jguarin200 |
--! @brief Descripción del sistema aritmetico usado por raytrac.
|
3 |
52 |
jguarin200 |
--! @author Juli´n Andrés Guarín Reyes.
|
4 |
8 |
jguarin200 |
-- RAYTRAC
|
5 |
|
|
-- Author Julian Andres Guarin
|
6 |
|
|
-- uf.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/>.
|
21 |
|
|
|
22 |
52 |
jguarin200 |
--! Libreria de definicion de senales y tipos estandares, comportamiento de operadores aritmeticos y logicos.
|
23 |
2 |
jguarin200 |
library ieee;
|
24 |
52 |
jguarin200 |
--! Paquete de definicion estandard de logica.
|
25 |
2 |
jguarin200 |
use ieee.std_logic_1164.all;
|
26 |
27 |
jguarin200 |
|
27 |
|
|
--! Paquete para el manejo de aritmŽtica con signo sobre el tipo std_logic_vector
|
28 |
|
|
use ieee.std_logic_signed.all;
|
29 |
|
|
|
30 |
78 |
jguarin200 |
--! Paquete para calculo de funciones reales.
|
31 |
|
|
use ieee.math_real.all;
|
32 |
|
|
|
33 |
50 |
jguarin200 |
--! Paquete estandar de texto
|
34 |
|
|
use std.textio.all;
|
35 |
|
|
|
36 |
52 |
jguarin200 |
--! Se usaran en esta descripcion los componentes del package arithpack.vhd.
|
37 |
2 |
jguarin200 |
use work.arithpack.all;
|
38 |
|
|
|
39 |
22 |
jguarin200 |
|
40 |
67 |
jguarin200 |
--! uf es la descripcióon del circuito que realiza la aritmética del Rt Engine.
|
41 |
22 |
jguarin200 |
|
42 |
67 |
jguarin200 |
--! La entrada opcode indica la operación que se está realizando, en los sumadores, es la misma señal que se encuentra en la entidad opcoder, que selecciona si se está realizando un producto punto o un producto cruz. Dentro de la arquitectura de uf, la señal opcode selecciona en la primera etapa de sumadores, si la operación a realizar será una resta o una suma.
|
43 |
|
|
--! Los resultados estar´n en distintas salidas dependiendo de la operación, lo cual es apenas natural: El producto cruz tiene por resultado un vector, mientras que el producto punto tiene por resultado un escalar.
|
44 |
|
|
--! Esta entidad utiliza las señales de control clk y rst.
|
45 |
22 |
jguarin200 |
--! \n\n
|
46 |
67 |
jguarin200 |
--! La característica fundamental de uf, es que puede realizar 2 operaciones de producto punto al mimso tiempo ó una operación de producto cruz. La otra característica importante es que el pipe de producto punto es mas largo que el pipe de producto cruz: el producto punto tomar´ 3 clocks para realizarse, mientras que el procto punto tomara 4 clocks para realizarse.
|
47 |
78 |
jguarin200 |
--! Es importante entender que las resultados de las operaciones, correspondientes a las salidas de esta entidad no est'an conectadas directamente a la salida del circuito combinatorio que ejecuta sus repectivas operaciones: en vez de ello, los resutados est'an conectados a la salida de un registro.
|
48 |
|
|
--! Este circuito es una ALU
|
49 |
27 |
jguarin200 |
entity uf is
|
50 |
|
|
generic (
|
51 |
78 |
jguarin200 |
square_root_width : integer := 16;
|
52 |
|
|
use_std_logic_signed : string := "NO";
|
53 |
|
|
testbench_generation : string := "NO";
|
54 |
|
|
carry_logic : string := "CLA"
|
55 |
27 |
jguarin200 |
);
|
56 |
2 |
jguarin200 |
port (
|
57 |
67 |
jguarin200 |
opcode : in std_logic; --! Entrada que dentro de la arquitectura funciona como selector de la operación que se lleva a cabo en la primera etapa de sumadores/restadores.
|
58 |
78 |
jguarin200 |
exp0,exp1 : in std_logic_vector(integer(ceil(log(real(square_root_width),2.0)))-1 downto 0); --! Junto con la mantissa este es el exponente del valor flotante, mejora muchisimo la precisi'on.
|
59 |
67 |
jguarin200 |
m0f0,m0f1,m1f0,m1f1,m2f0,m2f1,m3f0,m3f1,m4f0,m4f1,m5f0,m5f1 : in std_logic_vector(17 downto 0); --! Entradas que van conectadas a los multiplicadores en la primera etapa de la descripción.
|
60 |
77 |
jguarin200 |
cpx,cpy,cpz,dp0,dp1,kvx0,kvy0,kvz0,kvx1,kvy1,kvz1 : out std_logic_vector(31 downto 0); --! Salidas donde se registran los resultados de las operaciones aritméticas: cpx,cpy,cpz ser´n los componentes del vector que da por resultado el producto cruz entre los vectores AxB ó CxD. kvx0, kvy0, kvz0, kvx1, kvy1, kvz1 es el resultado de los multiplicadores
|
61 |
22 |
jguarin200 |
clk,rst : in std_logic --! Las entradas de control usuales.
|
62 |
2 |
jguarin200 |
);
|
63 |
|
|
end uf;
|
64 |
|
|
|
65 |
|
|
architecture uf_arch of uf is
|
66 |
|
|
|
67 |
8 |
jguarin200 |
-- Stage 0 signals
|
68 |
2 |
jguarin200 |
|
69 |
22 |
jguarin200 |
signal stage0mf00,stage0mf01,stage0mf10,stage0mf11,stage0mf20,stage0mf21,stage0mf30,stage0mf31,stage0mf40,stage0mf41,stage0mf50,stage0mf51 : std_logic_vector(17 downto 0); --! Señales que conectan los operandos seleccionados en opcode a las entradas de los multiplicadores.
|
70 |
78 |
jguarin200 |
signal stage0p0,stage0p1, stage0p2, stage0p3, stage0p4, stage0p5 : std_logic_vector(31 downto 0); --! Señales / buses, con los productos de los multiplicadores.
|
71 |
28 |
jguarin200 |
signal stageMopcode : std_logic; --! Señal de atraso del opcode. Revisar el diagrama de bloques para mayor claridad.
|
72 |
78 |
jguarin200 |
signal stage0exp0 : std_logic_vector(integer(ceil(log(real(square_root_width),2.0)))-1 downto 0);
|
73 |
|
|
signal stage0exp1 : std_logic_vector(integer(ceil(log(real(square_root_width),2.0)))-1 downto 0);
|
74 |
2 |
jguarin200 |
|
75 |
8 |
jguarin200 |
--Stage 1 signals
|
76 |
2 |
jguarin200 |
|
77 |
22 |
jguarin200 |
signal stage1p0, stage1p1, stage1p2, stage1p3, stage1p4, stage1p5 : std_logic_vector (31 downto 0); --! Señales provenientes de los productos de la etapa previa de multiplicadores.
|
78 |
|
|
signal stage1a0, stage1a1, stage1a2 : std_logic_vector (31 downto 0); --! Señales / buses, con los resultados de los sumadores.
|
79 |
67 |
jguarin200 |
signal stageSRopcode : std_logic; --! Señal proveniente del opcode que selecciona si los sumadores deben ejecutar una resta o una suma dependiendo de la operación que se ejecute en ese momento del pipe.
|
80 |
78 |
jguarin200 |
signal stage1exp0 : std_logic_vector(integer(ceil(log(real(square_root_width),2.0)))-1 downto 0);
|
81 |
|
|
signal stage1exp1 : std_logic_vector(integer(ceil(log(real(square_root_width),2.0)))-1 downto 0);
|
82 |
2 |
jguarin200 |
|
83 |
8 |
jguarin200 |
-- Some support signals
|
84 |
52 |
jguarin200 |
signal stage1_internalCarry : std_logic_vector(2 downto 0); --! Cada uno de los 3 sumadores de la etapa de sumadores est´ compuesto de una cascada de 2 sumadores Carry Look Ahead: aXhigh y aXlow. El carry out del componente low y el carry in del componente high, se conectar´ a través de las señales internal carry.
|
85 |
|
|
signal stage2_internalCarry : std_logic_vector(1 downto 0); --! Cada uno de los 2 sumadores de la última etapa de sumadores est´ compuesto de una cascada de 2 sumadores Carry Look AheadÑ: aXhigh y aXlow. El carry out del componente low y el carry in del componente high, se conectar´ a través de las señales internal carry.
|
86 |
2 |
jguarin200 |
|
87 |
22 |
jguarin200 |
--Stage 2 signals
|
88 |
|
|
signal stage2a0, stage2a2, stage2a3, stage2a4, stage2p2, stage2p3 : std_logic_vector (31 downto 0); --! Estas señales corresponden a los sumandos derivados de la primera etapa de multiplicadores (stage2p2, stage2p3) y a los sumandos derivados del resultado de las sumas en la primera etapa de sumadores.
|
89 |
8 |
jguarin200 |
|
90 |
|
|
|
91 |
|
|
|
92 |
2 |
jguarin200 |
begin
|
93 |
|
|
|
94 |
8 |
jguarin200 |
-- Multiplicator Instantiation (StAgE 0)
|
95 |
22 |
jguarin200 |
--! Multiplicador 0
|
96 |
50 |
jguarin200 |
m0 : lpm_mult
|
97 |
|
|
generic map (
|
98 |
|
|
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
|
99 |
|
|
lpm_pipeline => 2,
|
100 |
|
|
lpm_representation => "SIGNED",
|
101 |
|
|
lpm_type => "LPM_MULT",
|
102 |
|
|
lpm_widtha => 18,
|
103 |
|
|
lpm_widthb => 18,
|
104 |
|
|
lpm_widthp => 32
|
105 |
|
|
)
|
106 |
8 |
jguarin200 |
port map (
|
107 |
|
|
aclr => rst,
|
108 |
|
|
clock => clk,
|
109 |
15 |
jguarin200 |
dataa => stage0mf00,
|
110 |
|
|
datab => stage0mf01,
|
111 |
|
|
result => stage0p0
|
112 |
8 |
jguarin200 |
);
|
113 |
77 |
jguarin200 |
kvx0 <= stage0p0;
|
114 |
22 |
jguarin200 |
--! Multiplicador 1
|
115 |
50 |
jguarin200 |
m1 : lpm_mult
|
116 |
|
|
generic map (
|
117 |
|
|
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
|
118 |
|
|
lpm_pipeline => 2,
|
119 |
|
|
lpm_representation => "SIGNED",
|
120 |
|
|
lpm_type => "LPM_MULT",
|
121 |
|
|
lpm_widtha => 18,
|
122 |
|
|
lpm_widthb => 18,
|
123 |
|
|
lpm_widthp => 32
|
124 |
|
|
)
|
125 |
8 |
jguarin200 |
port map (
|
126 |
|
|
aclr => rst,
|
127 |
|
|
clock => clk,
|
128 |
15 |
jguarin200 |
dataa => stage0mf10,
|
129 |
|
|
datab => stage0mf11,
|
130 |
|
|
result => stage0p1
|
131 |
8 |
jguarin200 |
);
|
132 |
77 |
jguarin200 |
kvy0 <= stage0p1;
|
133 |
22 |
jguarin200 |
|
134 |
|
|
--! Multiplicador 2
|
135 |
50 |
jguarin200 |
m2 : lpm_mult
|
136 |
|
|
generic map (
|
137 |
|
|
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
|
138 |
|
|
lpm_pipeline => 2,
|
139 |
|
|
lpm_representation => "SIGNED",
|
140 |
|
|
lpm_type => "LPM_MULT",
|
141 |
|
|
lpm_widtha => 18,
|
142 |
|
|
lpm_widthb => 18,
|
143 |
|
|
lpm_widthp => 32
|
144 |
|
|
)
|
145 |
8 |
jguarin200 |
port map (
|
146 |
|
|
aclr => rst,
|
147 |
|
|
clock => clk,
|
148 |
15 |
jguarin200 |
dataa => stage0mf20,
|
149 |
|
|
datab => stage0mf21,
|
150 |
|
|
result => stage0p2
|
151 |
8 |
jguarin200 |
);
|
152 |
77 |
jguarin200 |
kvz0 <= stage0p2;
|
153 |
22 |
jguarin200 |
|
154 |
|
|
--! Multiplicador 3
|
155 |
50 |
jguarin200 |
m3 : lpm_mult
|
156 |
|
|
generic map (
|
157 |
|
|
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
|
158 |
|
|
lpm_pipeline => 2,
|
159 |
|
|
lpm_representation => "SIGNED",
|
160 |
|
|
lpm_type => "LPM_MULT",
|
161 |
|
|
lpm_widtha => 18,
|
162 |
|
|
lpm_widthb => 18,
|
163 |
|
|
lpm_widthp => 32
|
164 |
|
|
)
|
165 |
8 |
jguarin200 |
port map (
|
166 |
|
|
aclr => rst,
|
167 |
|
|
clock => clk,
|
168 |
15 |
jguarin200 |
dataa => stage0mf30,
|
169 |
|
|
datab => stage0mf31,
|
170 |
|
|
result => stage0p3
|
171 |
8 |
jguarin200 |
);
|
172 |
77 |
jguarin200 |
kvx1 <= stage0p3;
|
173 |
22 |
jguarin200 |
--! Multiplicador 4
|
174 |
50 |
jguarin200 |
m4 : lpm_mult
|
175 |
|
|
generic map (
|
176 |
|
|
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
|
177 |
|
|
lpm_pipeline => 2,
|
178 |
|
|
lpm_representation => "SIGNED",
|
179 |
|
|
lpm_type => "LPM_MULT",
|
180 |
|
|
lpm_widtha => 18,
|
181 |
|
|
lpm_widthb => 18,
|
182 |
|
|
lpm_widthp => 32
|
183 |
|
|
)
|
184 |
8 |
jguarin200 |
port map (
|
185 |
|
|
aclr => rst,
|
186 |
|
|
clock => clk,
|
187 |
15 |
jguarin200 |
dataa => stage0mf40,
|
188 |
|
|
datab => stage0mf41,
|
189 |
|
|
result => stage0p4
|
190 |
8 |
jguarin200 |
);
|
191 |
77 |
jguarin200 |
kvy1 <= stage0p4;
|
192 |
22 |
jguarin200 |
|
193 |
|
|
--! Multiplicador 5
|
194 |
50 |
jguarin200 |
m5 : lpm_mult
|
195 |
|
|
generic map (
|
196 |
|
|
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
|
197 |
|
|
lpm_pipeline => 2,
|
198 |
|
|
lpm_representation => "SIGNED",
|
199 |
|
|
lpm_type => "LPM_MULT",
|
200 |
|
|
lpm_widtha => 18,
|
201 |
|
|
lpm_widthb => 18,
|
202 |
|
|
lpm_widthp => 32
|
203 |
|
|
)
|
204 |
8 |
jguarin200 |
port map (
|
205 |
|
|
aclr => rst,
|
206 |
|
|
clock => clk,
|
207 |
15 |
jguarin200 |
dataa => stage0mf50,
|
208 |
|
|
datab => stage0mf51,
|
209 |
|
|
result => stage0p5
|
210 |
8 |
jguarin200 |
);
|
211 |
77 |
jguarin200 |
kvz1 <= stage0p5;
|
212 |
8 |
jguarin200 |
|
213 |
|
|
|
214 |
27 |
jguarin200 |
useIeee:
|
215 |
|
|
if use_std_logic_signed="YES" generate
|
216 |
|
|
-- Adder Instantiation (sTaGe 1)
|
217 |
|
|
stage1adderProc:
|
218 |
28 |
jguarin200 |
process (stage1p0,stage1p1,stage1p2,stage1p3,stage1p4,stage1p5,stageSRopcode)
|
219 |
27 |
jguarin200 |
begin
|
220 |
28 |
jguarin200 |
case (stageSRopcode) is
|
221 |
27 |
jguarin200 |
when '1' => -- Cross Product
|
222 |
|
|
stage1a0 <= stage1p0-stage1p1;
|
223 |
|
|
stage1a2 <= stage1p4-stage1p5;
|
224 |
|
|
when others => -- Dot Product
|
225 |
|
|
stage1a0 <= stage1p0+stage1p1;
|
226 |
|
|
stage1a2 <= stage1p4+stage1p5;
|
227 |
|
|
end case;
|
228 |
|
|
end process stage1adderProc;
|
229 |
|
|
stage1a1 <= stage1p2-stage1p3; -- This is always going to be a substraction
|
230 |
|
|
|
231 |
|
|
-- Adder Instantiation (Stage 2)
|
232 |
|
|
stage2a3 <= stage2a0+stage2p2;
|
233 |
|
|
stage2a4 <= stage2p3+stage2a2;
|
234 |
77 |
jguarin200 |
|
235 |
27 |
jguarin200 |
end generate useIeee;
|
236 |
78 |
jguarin200 |
|
237 |
8 |
jguarin200 |
-- Incoming from opcoder.vhd signals into pipeline's stage 0.
|
238 |
15 |
jguarin200 |
stage0mf00 <= m0f0;
|
239 |
|
|
stage0mf01 <= m0f1;
|
240 |
|
|
stage0mf10 <= m1f0;
|
241 |
|
|
stage0mf11 <= m1f1;
|
242 |
|
|
stage0mf20 <= m2f0;
|
243 |
|
|
stage0mf21 <= m2f1;
|
244 |
|
|
stage0mf30 <= m3f0;
|
245 |
|
|
stage0mf31 <= m3f1;
|
246 |
|
|
stage0mf40 <= m4f0;
|
247 |
|
|
stage0mf41 <= m4f1;
|
248 |
|
|
stage0mf50 <= m5f0;
|
249 |
|
|
stage0mf51 <= m5f1;
|
250 |
8 |
jguarin200 |
|
251 |
|
|
-- Signal sequencing: as the multipliers use registered output and registered input is not necessary to write the sequence of stage 0 signals to stage 1 signals.
|
252 |
|
|
-- so the simplistic path is taken: simply connect stage 0 to stage 1 lines. However this would not apply for the opcode signal
|
253 |
15 |
jguarin200 |
stage1p0 <= stage0p0;
|
254 |
|
|
stage1p1 <= stage0p1;
|
255 |
|
|
stage1p2 <= stage0p2;
|
256 |
|
|
stage1p3 <= stage0p3;
|
257 |
|
|
stage1p4 <= stage0p4;
|
258 |
|
|
stage1p5 <= stage0p5;
|
259 |
8 |
jguarin200 |
|
260 |
|
|
|
261 |
|
|
--Outcoming to the rest of the system (by the time i wrote this i dont know where this leads to... jeje)
|
262 |
78 |
jguarin200 |
--May 31 23:31:56 Guess What!, now I know!!!
|
263 |
|
|
|
264 |
15 |
jguarin200 |
cpx <= stage1a0;
|
265 |
|
|
cpy <= stage1a1;
|
266 |
|
|
cpz <= stage1a2;
|
267 |
78 |
jguarin200 |
|
268 |
|
|
|
269 |
15 |
jguarin200 |
dp0 <= stage2a3;
|
270 |
|
|
dp1 <= stage2a4;
|
271 |
8 |
jguarin200 |
|
272 |
|
|
-- Looking into the design the stage 1 to stage 2 are the sequences pipe stages that must be controlled in this particular HDL.
|
273 |
22 |
jguarin200 |
--! Este proceso describe la manera en que se organizan las etapas de pipe.
|
274 |
67 |
jguarin200 |
--! Todas las señales internas en las etapas de pipe, en el momento en que la entrada rst alcanza el nivel rstMasterValue, se colocan en '0'. Nótese que, salvo stageMopcode<=stageSRopcode, las señales que vienen desde la entrada hacia los multiplicadores en la etapa 0 y desde la salida de los multiplicadores desde la etapa0 hacia la etapa 1, no est´n siendo descritas en este proceso, la explicación de es simple: Los multiplicadores que se est´n instanciado tienen registros a la entrada y la salida, permitiendo así, registrar las entradas y registrar los productos o salidas de los multiplicadores, hacia la etapa 1 o etapa de sumadores/restadores.
|
275 |
22 |
jguarin200 |
|
276 |
|
|
uf_seq: process (clk,rst)
|
277 |
8 |
jguarin200 |
begin
|
278 |
|
|
|
279 |
|
|
if rst=rstMasterValue then
|
280 |
28 |
jguarin200 |
stageMopcode <= '0';
|
281 |
|
|
stageSRopcode <= '0';
|
282 |
3 |
jguarin200 |
|
283 |
15 |
jguarin200 |
stage2a2 <= (others => '0');
|
284 |
|
|
stage2p3 <= (others => '0');
|
285 |
|
|
stage2p2 <= (others => '0');
|
286 |
|
|
stage2a0 <= (others => '0');
|
287 |
8 |
jguarin200 |
|
288 |
|
|
elsif clk'event and clk = '1' then
|
289 |
|
|
|
290 |
15 |
jguarin200 |
stage2a2 <= stage1a2;
|
291 |
|
|
stage2p3 <= stage1p3;
|
292 |
|
|
stage2p2 <= stage1p2;
|
293 |
|
|
stage2a0 <= stage1a0;
|
294 |
3 |
jguarin200 |
|
295 |
8 |
jguarin200 |
-- Opcode control sequence
|
296 |
28 |
jguarin200 |
stageMopcode <= opcode;
|
297 |
|
|
stageSRopcode <= stageMopcode;
|
298 |
8 |
jguarin200 |
|
299 |
|
|
end if;
|
300 |
|
|
end process uf_seq;
|
301 |
15 |
jguarin200 |
|
302 |
50 |
jguarin200 |
--! Codigo generado para realizar test bench
|
303 |
|
|
tbgen:
|
304 |
|
|
if testbench_generation="YES" generate
|
305 |
|
|
tbproc0:
|
306 |
|
|
process
|
307 |
|
|
variable buff : line;
|
308 |
55 |
jguarin200 |
variable theend : time :=30835 ns;
|
309 |
52 |
jguarin200 |
file mbuff : text open write_mode is "TRACE_multiplier_content.csv";
|
310 |
50 |
jguarin200 |
begin
|
311 |
54 |
jguarin200 |
write(buff,string'("#UF multipliers test benching"));
|
312 |
50 |
jguarin200 |
writeline(mbuff, buff);
|
313 |
54 |
jguarin200 |
write(buff,string'("#{Time} {m0result} {m1result} {m2result} {m3result} {m4result} {m5result}"));
|
314 |
|
|
writeline(mbuff, buff);
|
315 |
50 |
jguarin200 |
wait for 5 ns;
|
316 |
|
|
wait until rst=not(rstMasterValue);
|
317 |
|
|
wait until clk='1';
|
318 |
|
|
wait for tclk2+tclk4; --! Garantizar la estabilidad de los datos que se van a observar en la salida.
|
319 |
|
|
displayRom:
|
320 |
|
|
loop
|
321 |
54 |
jguarin200 |
write (buff,string'("{"));
|
322 |
55 |
jguarin200 |
write (buff,now,unit =>ns);
|
323 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
324 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1p0(31 downto 0));
|
325 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
326 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1p1(31 downto 0));
|
327 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
328 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1p2(31 downto 0));
|
329 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
330 |
58 |
jguarin200 |
hexwrite_0 (buff,stage1p3(31 downto 0));
|
331 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
332 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1p4(31 downto 0));
|
333 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
334 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1p5(31 downto 0));
|
335 |
54 |
jguarin200 |
write (buff,string'("}"));
|
336 |
50 |
jguarin200 |
writeline(mbuff,buff);
|
337 |
|
|
wait for tclk;
|
338 |
56 |
jguarin200 |
if now>theend then
|
339 |
54 |
jguarin200 |
wait;
|
340 |
|
|
end if;
|
341 |
50 |
jguarin200 |
end loop displayRom;
|
342 |
|
|
end process tbproc0;
|
343 |
|
|
tbproc1:
|
344 |
|
|
process
|
345 |
|
|
variable buff : line;
|
346 |
55 |
jguarin200 |
variable theend : time :=30795 ns;
|
347 |
52 |
jguarin200 |
file fbuff : text open write_mode is "TRACE_decoded_factors_content.csv";
|
348 |
50 |
jguarin200 |
begin
|
349 |
|
|
|
350 |
54 |
jguarin200 |
write(buff,string'("#UF factors decoded test benching"));
|
351 |
50 |
jguarin200 |
writeline(fbuff, buff);
|
352 |
54 |
jguarin200 |
write(buff,string'("#{Time} {m0f0,m0f1}{m1f0,m1f1}{m2f0,m2f1}{m3f0,m3f1}{m4f0,m4f1}{m5f0,m5f1}"));
|
353 |
|
|
writeline(fbuff, buff);
|
354 |
50 |
jguarin200 |
wait for 5 ns;
|
355 |
|
|
wait until rst=not(rstMasterValue);
|
356 |
|
|
wait until clk='1';
|
357 |
|
|
wait for tclk2+tclk4; --! Garantizar la estabilidad de los datos que se van a observar en la salida.
|
358 |
|
|
displayRom:
|
359 |
|
|
loop
|
360 |
52 |
jguarin200 |
write (buff,string'(" { "));
|
361 |
54 |
jguarin200 |
write (buff,now,unit =>ns);
|
362 |
|
|
write (buff,string'(" } "));
|
363 |
|
|
write (buff,string'(" { "));
|
364 |
50 |
jguarin200 |
hexwrite_0 (buff,m0f0(17 downto 0));
|
365 |
52 |
jguarin200 |
write (buff,string'(","));
|
366 |
50 |
jguarin200 |
hexwrite_0 (buff,m0f1(17 downto 0));
|
367 |
52 |
jguarin200 |
write (buff,string'(" } { "));
|
368 |
50 |
jguarin200 |
hexwrite_0 (buff,m1f0(17 downto 0));
|
369 |
52 |
jguarin200 |
write (buff,string'(","));
|
370 |
50 |
jguarin200 |
hexwrite_0 (buff,m1f1(17 downto 0));
|
371 |
52 |
jguarin200 |
write (buff,string'(" } { "));
|
372 |
50 |
jguarin200 |
hexwrite_0 (buff,m2f0(17 downto 0));
|
373 |
52 |
jguarin200 |
write (buff,string'(","));
|
374 |
50 |
jguarin200 |
hexwrite_0 (buff,m2f1(17 downto 0));
|
375 |
52 |
jguarin200 |
write (buff,string'(" } { "));
|
376 |
50 |
jguarin200 |
hexwrite_0 (buff,m3f0(17 downto 0));
|
377 |
52 |
jguarin200 |
write (buff,string'(","));
|
378 |
50 |
jguarin200 |
hexwrite_0 (buff,m3f1(17 downto 0));
|
379 |
52 |
jguarin200 |
write (buff,string'(" } { "));
|
380 |
50 |
jguarin200 |
hexwrite_0 (buff,m4f0(17 downto 0));
|
381 |
52 |
jguarin200 |
write (buff,string'(","));
|
382 |
|
|
hexwrite_0 (buff,m4f1(17 downto 0));
|
383 |
|
|
write (buff,string'(" } { "));
|
384 |
50 |
jguarin200 |
hexwrite_0 (buff,m5f0(17 downto 0));
|
385 |
52 |
jguarin200 |
write (buff,string'(","));
|
386 |
50 |
jguarin200 |
hexwrite_0 (buff,m5f1(17 downto 0));
|
387 |
52 |
jguarin200 |
write (buff,string'(" }"));
|
388 |
50 |
jguarin200 |
writeline(fbuff,buff);
|
389 |
|
|
wait for tclk;
|
390 |
56 |
jguarin200 |
if now>theend then
|
391 |
55 |
jguarin200 |
wait;
|
392 |
|
|
end if;
|
393 |
50 |
jguarin200 |
end loop displayRom;
|
394 |
|
|
end process tbproc1;
|
395 |
|
|
|
396 |
77 |
jguarin200 |
tbproc2:
|
397 |
50 |
jguarin200 |
process
|
398 |
|
|
variable buff : line;
|
399 |
55 |
jguarin200 |
variable theend : time :=30855 ns;
|
400 |
52 |
jguarin200 |
file rbuff : text open write_mode is "TRACE_results_content.csv";
|
401 |
50 |
jguarin200 |
begin
|
402 |
|
|
|
403 |
54 |
jguarin200 |
write(buff,string'("#UF results test benching"));
|
404 |
50 |
jguarin200 |
writeline(rbuff, buff);
|
405 |
54 |
jguarin200 |
write(buff,string'("#{Time} {CPX,CPY,CPZ}{DP0,DP1}"));
|
406 |
|
|
writeline(rbuff, buff);
|
407 |
|
|
|
408 |
50 |
jguarin200 |
wait for 5 ns;
|
409 |
|
|
wait until rst=not(rstMasterValue);
|
410 |
|
|
wait until clk='1';
|
411 |
|
|
wait for tclk2+tclk4; --! Garantizar la estabilidad de los datos que se van a observar en la salida.
|
412 |
|
|
displayRom:
|
413 |
|
|
loop
|
414 |
54 |
jguarin200 |
write (buff,string'(" { "));
|
415 |
50 |
jguarin200 |
write (buff,now,unit =>ns);
|
416 |
54 |
jguarin200 |
write (buff,string'(" }{ "));
|
417 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1a0(31 downto 0));
|
418 |
52 |
jguarin200 |
write (buff,string'(","));
|
419 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1a1(31 downto 0));
|
420 |
52 |
jguarin200 |
write (buff,string'(","));
|
421 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1a2(31 downto 0));
|
422 |
54 |
jguarin200 |
write (buff,string'(" }{ "));
|
423 |
50 |
jguarin200 |
hexwrite_0 (buff,stage2a3(31 downto 0));
|
424 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
425 |
50 |
jguarin200 |
hexwrite_0 (buff,stage2a4(31 downto 0));
|
426 |
52 |
jguarin200 |
write (buff,string'(" }"));
|
427 |
50 |
jguarin200 |
writeline(rbuff,buff);
|
428 |
|
|
wait for tclk;
|
429 |
56 |
jguarin200 |
if now>theend then
|
430 |
55 |
jguarin200 |
wait;
|
431 |
77 |
jguarin200 |
end if;
|
432 |
50 |
jguarin200 |
end loop displayRom;
|
433 |
|
|
end process tbproc2;
|
434 |
|
|
|
435 |
|
|
end generate tbgen;
|
436 |
78 |
jguarin200 |
dontUseIeee:
|
437 |
|
|
if use_std_logic_signed="NO" generate
|
438 |
|
|
--! Adder 0, 16 bit carry lookahead low adder.
|
439 |
|
|
a0low : adder
|
440 |
|
|
generic map (16,carry_logic,"YES") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
441 |
|
|
-- Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
|
442 |
|
|
port map (stage1p0(15 downto 0),stage1p1(15 downto 0),stageSRopcode,'0',stage1a0(15 downto 0),stage1_internalCarry(0));
|
443 |
|
|
--Adder 0, 16 bit carry lookahead high adder.
|
444 |
|
|
a0high : adder
|
445 |
|
|
generic map (16,carry_logic,"YES") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
446 |
|
|
-- Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
|
447 |
|
|
port map (stage1p0(31 downto 16),stage1p1(31 downto 16),stageSRopcode,stage1_internalCarry(0),stage1a0(31 downto 16),open);
|
448 |
|
|
--! Adder 1, 16 bit carry lookahead low adder.
|
449 |
|
|
a1low : adder
|
450 |
|
|
generic map (16,carry_logic,"YES") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
451 |
|
|
-- Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
|
452 |
|
|
port map (stage1p2(15 downto 0),stage1p3(15 downto 0),'1','0',stage1a1(15 downto 0),stage1_internalCarry(1));
|
453 |
|
|
--! Adder 1, 16 bit carry lookahead high adder.
|
454 |
|
|
a1high : adder
|
455 |
|
|
generic map (16,carry_logic,"YES") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
456 |
|
|
-- Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
|
457 |
|
|
port map (stage1p2(31 downto 16),stage1p3(31 downto 16),'1',stage1_internalCarry(1),stage1a1(31 downto 16),open);
|
458 |
|
|
--! Adder 2, 16 bit carry lookahead low adder.
|
459 |
|
|
a2low : adder
|
460 |
|
|
generic map (16,carry_logic,"YES") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
461 |
|
|
-- Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
|
462 |
|
|
port map (stage1p4(15 downto 0),stage1p5(15 downto 0),stageSRopcode,'0',stage1a2(15 downto 0),stage1_internalCarry(2));
|
463 |
|
|
--! Adder 2, 16 bit carry lookahead high adder.
|
464 |
|
|
a2high : adder
|
465 |
|
|
generic map (16,carry_logic,"YES") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
466 |
|
|
-- Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
|
467 |
|
|
port map (stage1p4(31 downto 16),stage1p5(31 downto 16),stageSRopcode,stage1_internalCarry(2),stage1a2(31 downto 16),open);
|
468 |
|
|
-- Adder Instantiation (Stage 2)
|
469 |
|
|
--! Adder 3, 16 bit carry lookahead low adder.
|
470 |
|
|
a3low : adder
|
471 |
|
|
generic map (16,carry_logic,"NO") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
472 |
|
|
-- Dont instantiate Xor gates stage in the adder.
|
473 |
|
|
port map (stage2a0(15 downto 0),stage2p2(15 downto 0),'0','0',stage2a3(15 downto 0),stage2_internalCarry(0));
|
474 |
|
|
--Adder 3, 16 bit carry lookahead high adder.
|
475 |
|
|
a3high : adder
|
476 |
|
|
generic map (16,carry_logic,"NO") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
477 |
|
|
-- Dont instantiate Xor gates stage in the adder.
|
478 |
|
|
port map (stage2a0(31 downto 16),stage2p2(31 downto 16),'0',stage2_internalCarry(0),stage2a3(31 downto 16),open);
|
479 |
|
|
--! Adder 4, 16 bit carry lookahead low adder.
|
480 |
|
|
a4low : adder
|
481 |
|
|
generic map (16,carry_logic,"NO") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
482 |
|
|
-- Dont instantiate Xor gates stage in the adder.
|
483 |
|
|
port map (stage2p3(15 downto 0),stage2a2(15 downto 0),'0','0',stage2a4(15 downto 0),stage2_internalCarry(1));
|
484 |
|
|
--! Adder 4, 16 bit carry lookahead high adder.
|
485 |
|
|
a4high : adder
|
486 |
|
|
generic map (16,carry_logic,"NO") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
487 |
|
|
-- Dont instantiate Xor gates stage in the adder.
|
488 |
|
|
port map (stage2p3(31 downto 16),stage2a2(31 downto 16),'0',stage2_internalCarry(1),stage2a4(31 downto 16),open);
|
489 |
|
|
|
490 |
|
|
end generate dontUseIeee;
|
491 |
15 |
jguarin200 |
|
492 |
|
|
|
493 |
50 |
jguarin200 |
|
494 |
2 |
jguarin200 |
end uf_arch;
|