| 1 |
22 |
jguarin200 |
--! @file raytrac.vhd
|
| 2 |
|
|
--! @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 |
50 |
jguarin200 |
--! Paquete estandar de texto
|
| 31 |
|
|
use std.textio.all;
|
| 32 |
|
|
|
| 33 |
52 |
jguarin200 |
--! Se usaran en esta descripcion los componentes del package arithpack.vhd.
|
| 34 |
2 |
jguarin200 |
use work.arithpack.all;
|
| 35 |
|
|
|
| 36 |
22 |
jguarin200 |
|
| 37 |
52 |
jguarin200 |
--! uf es la descripción del circuito que realiza la aritmética del Rt Engine.
|
| 38 |
22 |
jguarin200 |
|
| 39 |
52 |
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.
|
| 40 |
|
|
--! 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.
|
| 41 |
22 |
jguarin200 |
--! Esta entidad utiliza las señales de control clk y rst.}
|
| 42 |
|
|
--! \n\n
|
| 43 |
52 |
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 al mismo tiempo. 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.
|
| 44 |
22 |
jguarin200 |
|
| 45 |
27 |
jguarin200 |
entity uf is
|
| 46 |
|
|
generic (
|
| 47 |
32 |
jguarin200 |
use_std_logic_signed : string := "NO";
|
| 48 |
50 |
jguarin200 |
testbench_generation : string := "NO";
|
| 49 |
32 |
jguarin200 |
carry_logic : string := "CLA"
|
| 50 |
27 |
jguarin200 |
);
|
| 51 |
2 |
jguarin200 |
port (
|
| 52 |
22 |
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.
|
| 53 |
|
|
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.
|
| 54 |
52 |
jguarin200 |
cpx,cpy,cpz,dp0,dp1 : 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.
|
| 55 |
22 |
jguarin200 |
clk,rst : in std_logic --! Las entradas de control usuales.
|
| 56 |
2 |
jguarin200 |
);
|
| 57 |
|
|
end uf;
|
| 58 |
|
|
|
| 59 |
|
|
architecture uf_arch of uf is
|
| 60 |
|
|
|
| 61 |
8 |
jguarin200 |
-- Stage 0 signals
|
| 62 |
2 |
jguarin200 |
|
| 63 |
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.
|
| 64 |
|
|
signal stage0p0,stage0p1, stage0p2, stage0p3, stage0p4, stage0p5 : std_logic_vector(31 downto 0); --! Señales / buses, con los productos de los multiplicadores.
|
| 65 |
28 |
jguarin200 |
signal stageMopcode : std_logic; --! Señal de atraso del opcode. Revisar el diagrama de bloques para mayor claridad.
|
| 66 |
2 |
jguarin200 |
|
| 67 |
8 |
jguarin200 |
--Stage 1 signals
|
| 68 |
2 |
jguarin200 |
|
| 69 |
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.
|
| 70 |
|
|
signal stage1a0, stage1a1, stage1a2 : std_logic_vector (31 downto 0); --! Señales / buses, con los resultados de los sumadores.
|
| 71 |
28 |
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.
|
| 72 |
2 |
jguarin200 |
|
| 73 |
8 |
jguarin200 |
-- Some support signals
|
| 74 |
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.
|
| 75 |
|
|
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.
|
| 76 |
2 |
jguarin200 |
|
| 77 |
22 |
jguarin200 |
--Stage 2 signals
|
| 78 |
|
|
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.
|
| 79 |
8 |
jguarin200 |
|
| 80 |
|
|
|
| 81 |
|
|
|
| 82 |
2 |
jguarin200 |
begin
|
| 83 |
|
|
|
| 84 |
8 |
jguarin200 |
-- Multiplicator Instantiation (StAgE 0)
|
| 85 |
22 |
jguarin200 |
--! Multiplicador 0
|
| 86 |
50 |
jguarin200 |
m0 : lpm_mult
|
| 87 |
|
|
generic map (
|
| 88 |
|
|
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
|
| 89 |
|
|
lpm_pipeline => 2,
|
| 90 |
|
|
lpm_representation => "SIGNED",
|
| 91 |
|
|
lpm_type => "LPM_MULT",
|
| 92 |
|
|
lpm_widtha => 18,
|
| 93 |
|
|
lpm_widthb => 18,
|
| 94 |
|
|
lpm_widthp => 32
|
| 95 |
|
|
)
|
| 96 |
8 |
jguarin200 |
port map (
|
| 97 |
|
|
aclr => rst,
|
| 98 |
|
|
clock => clk,
|
| 99 |
15 |
jguarin200 |
dataa => stage0mf00,
|
| 100 |
|
|
datab => stage0mf01,
|
| 101 |
|
|
result => stage0p0
|
| 102 |
8 |
jguarin200 |
);
|
| 103 |
22 |
jguarin200 |
|
| 104 |
|
|
--! Multiplicador 1
|
| 105 |
50 |
jguarin200 |
m1 : lpm_mult
|
| 106 |
|
|
generic map (
|
| 107 |
|
|
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
|
| 108 |
|
|
lpm_pipeline => 2,
|
| 109 |
|
|
lpm_representation => "SIGNED",
|
| 110 |
|
|
lpm_type => "LPM_MULT",
|
| 111 |
|
|
lpm_widtha => 18,
|
| 112 |
|
|
lpm_widthb => 18,
|
| 113 |
|
|
lpm_widthp => 32
|
| 114 |
|
|
)
|
| 115 |
8 |
jguarin200 |
port map (
|
| 116 |
|
|
aclr => rst,
|
| 117 |
|
|
clock => clk,
|
| 118 |
15 |
jguarin200 |
dataa => stage0mf10,
|
| 119 |
|
|
datab => stage0mf11,
|
| 120 |
|
|
result => stage0p1
|
| 121 |
8 |
jguarin200 |
);
|
| 122 |
22 |
jguarin200 |
|
| 123 |
|
|
--! Multiplicador 2
|
| 124 |
50 |
jguarin200 |
m2 : lpm_mult
|
| 125 |
|
|
generic map (
|
| 126 |
|
|
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
|
| 127 |
|
|
lpm_pipeline => 2,
|
| 128 |
|
|
lpm_representation => "SIGNED",
|
| 129 |
|
|
lpm_type => "LPM_MULT",
|
| 130 |
|
|
lpm_widtha => 18,
|
| 131 |
|
|
lpm_widthb => 18,
|
| 132 |
|
|
lpm_widthp => 32
|
| 133 |
|
|
)
|
| 134 |
8 |
jguarin200 |
port map (
|
| 135 |
|
|
aclr => rst,
|
| 136 |
|
|
clock => clk,
|
| 137 |
15 |
jguarin200 |
dataa => stage0mf20,
|
| 138 |
|
|
datab => stage0mf21,
|
| 139 |
|
|
result => stage0p2
|
| 140 |
8 |
jguarin200 |
);
|
| 141 |
22 |
jguarin200 |
|
| 142 |
|
|
--! Multiplicador 3
|
| 143 |
50 |
jguarin200 |
m3 : lpm_mult
|
| 144 |
|
|
generic map (
|
| 145 |
|
|
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
|
| 146 |
|
|
lpm_pipeline => 2,
|
| 147 |
|
|
lpm_representation => "SIGNED",
|
| 148 |
|
|
lpm_type => "LPM_MULT",
|
| 149 |
|
|
lpm_widtha => 18,
|
| 150 |
|
|
lpm_widthb => 18,
|
| 151 |
|
|
lpm_widthp => 32
|
| 152 |
|
|
)
|
| 153 |
8 |
jguarin200 |
port map (
|
| 154 |
|
|
aclr => rst,
|
| 155 |
|
|
clock => clk,
|
| 156 |
15 |
jguarin200 |
dataa => stage0mf30,
|
| 157 |
|
|
datab => stage0mf31,
|
| 158 |
|
|
result => stage0p3
|
| 159 |
8 |
jguarin200 |
);
|
| 160 |
22 |
jguarin200 |
|
| 161 |
|
|
--! Multiplicador 4
|
| 162 |
50 |
jguarin200 |
m4 : lpm_mult
|
| 163 |
|
|
generic map (
|
| 164 |
|
|
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
|
| 165 |
|
|
lpm_pipeline => 2,
|
| 166 |
|
|
lpm_representation => "SIGNED",
|
| 167 |
|
|
lpm_type => "LPM_MULT",
|
| 168 |
|
|
lpm_widtha => 18,
|
| 169 |
|
|
lpm_widthb => 18,
|
| 170 |
|
|
lpm_widthp => 32
|
| 171 |
|
|
)
|
| 172 |
8 |
jguarin200 |
port map (
|
| 173 |
|
|
aclr => rst,
|
| 174 |
|
|
clock => clk,
|
| 175 |
15 |
jguarin200 |
dataa => stage0mf40,
|
| 176 |
|
|
datab => stage0mf41,
|
| 177 |
|
|
result => stage0p4
|
| 178 |
8 |
jguarin200 |
);
|
| 179 |
22 |
jguarin200 |
|
| 180 |
|
|
--! Multiplicador 5
|
| 181 |
50 |
jguarin200 |
m5 : lpm_mult
|
| 182 |
|
|
generic map (
|
| 183 |
|
|
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
|
| 184 |
|
|
lpm_pipeline => 2,
|
| 185 |
|
|
lpm_representation => "SIGNED",
|
| 186 |
|
|
lpm_type => "LPM_MULT",
|
| 187 |
|
|
lpm_widtha => 18,
|
| 188 |
|
|
lpm_widthb => 18,
|
| 189 |
|
|
lpm_widthp => 32
|
| 190 |
|
|
)
|
| 191 |
8 |
jguarin200 |
port map (
|
| 192 |
|
|
aclr => rst,
|
| 193 |
|
|
clock => clk,
|
| 194 |
15 |
jguarin200 |
dataa => stage0mf50,
|
| 195 |
|
|
datab => stage0mf51,
|
| 196 |
|
|
result => stage0p5
|
| 197 |
8 |
jguarin200 |
);
|
| 198 |
|
|
|
| 199 |
|
|
|
| 200 |
|
|
|
| 201 |
27 |
jguarin200 |
useIeee:
|
| 202 |
|
|
if use_std_logic_signed="YES" generate
|
| 203 |
|
|
-- Adder Instantiation (sTaGe 1)
|
| 204 |
|
|
stage1adderProc:
|
| 205 |
28 |
jguarin200 |
process (stage1p0,stage1p1,stage1p2,stage1p3,stage1p4,stage1p5,stageSRopcode)
|
| 206 |
27 |
jguarin200 |
begin
|
| 207 |
28 |
jguarin200 |
case (stageSRopcode) is
|
| 208 |
27 |
jguarin200 |
when '1' => -- Cross Product
|
| 209 |
|
|
stage1a0 <= stage1p0-stage1p1;
|
| 210 |
|
|
stage1a2 <= stage1p4-stage1p5;
|
| 211 |
|
|
when others => -- Dot Product
|
| 212 |
|
|
stage1a0 <= stage1p0+stage1p1;
|
| 213 |
|
|
stage1a2 <= stage1p4+stage1p5;
|
| 214 |
|
|
end case;
|
| 215 |
|
|
end process stage1adderProc;
|
| 216 |
|
|
stage1a1 <= stage1p2-stage1p3; -- This is always going to be a substraction
|
| 217 |
|
|
|
| 218 |
|
|
-- Adder Instantiation (Stage 2)
|
| 219 |
|
|
stage2a3 <= stage2a0+stage2p2;
|
| 220 |
|
|
stage2a4 <= stage2p3+stage2a2;
|
| 221 |
|
|
end generate useIeee;
|
| 222 |
|
|
dontUseIeee:
|
| 223 |
|
|
if use_std_logic_signed="NO" generate
|
| 224 |
|
|
--! Adder 0, 16 bit carry lookahead low adder.
|
| 225 |
|
|
a0low : adder
|
| 226 |
32 |
jguarin200 |
generic map (16,carry_logic,"YES") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
| 227 |
27 |
jguarin200 |
-- Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
|
| 228 |
28 |
jguarin200 |
port map (stage1p0(15 downto 0),stage1p1(15 downto 0),stageSRopcode,'0',stage1a0(15 downto 0),stage1_internalCarry(0));
|
| 229 |
27 |
jguarin200 |
--Adder 0, 16 bit carry lookahead high adder.
|
| 230 |
|
|
a0high : adder
|
| 231 |
32 |
jguarin200 |
generic map (16,carry_logic,"YES") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
| 232 |
27 |
jguarin200 |
-- Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
|
| 233 |
28 |
jguarin200 |
port map (stage1p0(31 downto 16),stage1p1(31 downto 16),stageSRopcode,stage1_internalCarry(0),stage1a0(31 downto 16),open);
|
| 234 |
27 |
jguarin200 |
--! Adder 1, 16 bit carry lookahead low adder.
|
| 235 |
|
|
a1low : adder
|
| 236 |
32 |
jguarin200 |
generic map (16,carry_logic,"YES") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
| 237 |
27 |
jguarin200 |
-- Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
|
| 238 |
|
|
port map (stage1p2(15 downto 0),stage1p3(15 downto 0),'1','0',stage1a1(15 downto 0),stage1_internalCarry(1));
|
| 239 |
|
|
--! Adder 1, 16 bit carry lookahead high adder.
|
| 240 |
|
|
a1high : adder
|
| 241 |
32 |
jguarin200 |
generic map (16,carry_logic,"YES") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
| 242 |
27 |
jguarin200 |
-- Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
|
| 243 |
|
|
port map (stage1p2(31 downto 16),stage1p3(31 downto 16),'1',stage1_internalCarry(1),stage1a1(31 downto 16),open);
|
| 244 |
|
|
--! Adder 2, 16 bit carry lookahead low adder.
|
| 245 |
|
|
a2low : adder
|
| 246 |
32 |
jguarin200 |
generic map (16,carry_logic,"YES") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
| 247 |
27 |
jguarin200 |
-- Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
|
| 248 |
28 |
jguarin200 |
port map (stage1p4(15 downto 0),stage1p5(15 downto 0),stageSRopcode,'0',stage1a2(15 downto 0),stage1_internalCarry(2));
|
| 249 |
27 |
jguarin200 |
--! Adder 2, 16 bit carry lookahead high adder.
|
| 250 |
|
|
a2high : adder
|
| 251 |
32 |
jguarin200 |
generic map (16,carry_logic,"YES") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
| 252 |
27 |
jguarin200 |
-- Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
|
| 253 |
28 |
jguarin200 |
port map (stage1p4(31 downto 16),stage1p5(31 downto 16),stageSRopcode,stage1_internalCarry(2),stage1a2(31 downto 16),open);
|
| 254 |
27 |
jguarin200 |
-- Adder Instantiation (Stage 2)
|
| 255 |
|
|
--! Adder 3, 16 bit carry lookahead low adder.
|
| 256 |
|
|
a3low : adder
|
| 257 |
32 |
jguarin200 |
generic map (16,carry_logic,"NO") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
| 258 |
27 |
jguarin200 |
-- Dont instantiate Xor gates stage in the adder.
|
| 259 |
|
|
port map (stage2a0(15 downto 0),stage2p2(15 downto 0),'0','0',stage2a3(15 downto 0),stage2_internalCarry(0));
|
| 260 |
|
|
--Adder 3, 16 bit carry lookahead high adder.
|
| 261 |
|
|
a3high : adder
|
| 262 |
32 |
jguarin200 |
generic map (16,carry_logic,"NO") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
| 263 |
27 |
jguarin200 |
-- Dont instantiate Xor gates stage in the adder.
|
| 264 |
|
|
port map (stage2a0(31 downto 16),stage2p2(31 downto 16),'0',stage2_internalCarry(0),stage2a3(31 downto 16),open);
|
| 265 |
|
|
--! Adder 4, 16 bit carry lookahead low adder.
|
| 266 |
|
|
a4low : adder
|
| 267 |
32 |
jguarin200 |
generic map (16,carry_logic,"NO") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
| 268 |
27 |
jguarin200 |
-- Dont instantiate Xor gates stage in the adder.
|
| 269 |
|
|
port map (stage2p3(15 downto 0),stage2a2(15 downto 0),'0','0',stage2a4(15 downto 0),stage2_internalCarry(1));
|
| 270 |
|
|
--! Adder 4, 16 bit carry lookahead high adder.
|
| 271 |
|
|
a4high : adder
|
| 272 |
32 |
jguarin200 |
generic map (16,carry_logic,"NO") -- Carry Look Ahead Logic (More Gates Used, But Less Time)
|
| 273 |
27 |
jguarin200 |
-- Dont instantiate Xor gates stage in the adder.
|
| 274 |
|
|
port map (stage2p3(31 downto 16),stage2a2(31 downto 16),'0',stage2_internalCarry(1),stage2a4(31 downto 16),open);
|
| 275 |
|
|
|
| 276 |
|
|
end generate dontUseIeee;
|
| 277 |
8 |
jguarin200 |
-- Incoming from opcoder.vhd signals into pipeline's stage 0.
|
| 278 |
15 |
jguarin200 |
stage0mf00 <= m0f0;
|
| 279 |
|
|
stage0mf01 <= m0f1;
|
| 280 |
|
|
stage0mf10 <= m1f0;
|
| 281 |
|
|
stage0mf11 <= m1f1;
|
| 282 |
|
|
stage0mf20 <= m2f0;
|
| 283 |
|
|
stage0mf21 <= m2f1;
|
| 284 |
|
|
stage0mf30 <= m3f0;
|
| 285 |
|
|
stage0mf31 <= m3f1;
|
| 286 |
|
|
stage0mf40 <= m4f0;
|
| 287 |
|
|
stage0mf41 <= m4f1;
|
| 288 |
|
|
stage0mf50 <= m5f0;
|
| 289 |
|
|
stage0mf51 <= m5f1;
|
| 290 |
8 |
jguarin200 |
|
| 291 |
|
|
-- 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.
|
| 292 |
|
|
-- so the simplistic path is taken: simply connect stage 0 to stage 1 lines. However this would not apply for the opcode signal
|
| 293 |
15 |
jguarin200 |
stage1p0 <= stage0p0;
|
| 294 |
|
|
stage1p1 <= stage0p1;
|
| 295 |
|
|
stage1p2 <= stage0p2;
|
| 296 |
|
|
stage1p3 <= stage0p3;
|
| 297 |
|
|
stage1p4 <= stage0p4;
|
| 298 |
|
|
stage1p5 <= stage0p5;
|
| 299 |
8 |
jguarin200 |
|
| 300 |
|
|
|
| 301 |
|
|
--Outcoming to the rest of the system (by the time i wrote this i dont know where this leads to... jeje)
|
| 302 |
15 |
jguarin200 |
cpx <= stage1a0;
|
| 303 |
|
|
cpy <= stage1a1;
|
| 304 |
|
|
cpz <= stage1a2;
|
| 305 |
|
|
dp0 <= stage2a3;
|
| 306 |
|
|
dp1 <= stage2a4;
|
| 307 |
8 |
jguarin200 |
|
| 308 |
|
|
-- Looking into the design the stage 1 to stage 2 are the sequences pipe stages that must be controlled in this particular HDL.
|
| 309 |
22 |
jguarin200 |
--! Este proceso describe la manera en que se organizan las etapas de pipe.
|
| 310 |
52 |
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.
|
| 311 |
22 |
jguarin200 |
|
| 312 |
|
|
uf_seq: process (clk,rst)
|
| 313 |
8 |
jguarin200 |
begin
|
| 314 |
|
|
|
| 315 |
|
|
if rst=rstMasterValue then
|
| 316 |
28 |
jguarin200 |
stageMopcode <= '0';
|
| 317 |
|
|
stageSRopcode <= '0';
|
| 318 |
3 |
jguarin200 |
|
| 319 |
15 |
jguarin200 |
stage2a2 <= (others => '0');
|
| 320 |
|
|
stage2p3 <= (others => '0');
|
| 321 |
|
|
stage2p2 <= (others => '0');
|
| 322 |
|
|
stage2a0 <= (others => '0');
|
| 323 |
8 |
jguarin200 |
|
| 324 |
|
|
elsif clk'event and clk = '1' then
|
| 325 |
|
|
|
| 326 |
15 |
jguarin200 |
stage2a2 <= stage1a2;
|
| 327 |
|
|
stage2p3 <= stage1p3;
|
| 328 |
|
|
stage2p2 <= stage1p2;
|
| 329 |
|
|
stage2a0 <= stage1a0;
|
| 330 |
3 |
jguarin200 |
|
| 331 |
8 |
jguarin200 |
-- Opcode control sequence
|
| 332 |
28 |
jguarin200 |
stageMopcode <= opcode;
|
| 333 |
|
|
stageSRopcode <= stageMopcode;
|
| 334 |
8 |
jguarin200 |
|
| 335 |
|
|
end if;
|
| 336 |
|
|
end process uf_seq;
|
| 337 |
15 |
jguarin200 |
|
| 338 |
50 |
jguarin200 |
--! Codigo generado para realizar test bench
|
| 339 |
|
|
tbgen:
|
| 340 |
|
|
if testbench_generation="YES" generate
|
| 341 |
|
|
tbproc0:
|
| 342 |
|
|
process
|
| 343 |
|
|
variable buff : line;
|
| 344 |
55 |
jguarin200 |
variable theend : time :=30835 ns;
|
| 345 |
52 |
jguarin200 |
file mbuff : text open write_mode is "TRACE_multiplier_content.csv";
|
| 346 |
50 |
jguarin200 |
begin
|
| 347 |
54 |
jguarin200 |
write(buff,string'("#UF multipliers test benching"));
|
| 348 |
50 |
jguarin200 |
writeline(mbuff, buff);
|
| 349 |
54 |
jguarin200 |
write(buff,string'("#{Time} {m0result} {m1result} {m2result} {m3result} {m4result} {m5result}"));
|
| 350 |
|
|
writeline(mbuff, buff);
|
| 351 |
50 |
jguarin200 |
wait for 5 ns;
|
| 352 |
|
|
wait until rst=not(rstMasterValue);
|
| 353 |
|
|
wait until clk='1';
|
| 354 |
|
|
wait for tclk2+tclk4; --! Garantizar la estabilidad de los datos que se van a observar en la salida.
|
| 355 |
|
|
displayRom:
|
| 356 |
|
|
loop
|
| 357 |
54 |
jguarin200 |
write (buff,string'("{"));
|
| 358 |
55 |
jguarin200 |
write (buff,now,unit =>ns);
|
| 359 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
| 360 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1p0(31 downto 0));
|
| 361 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
| 362 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1p1(31 downto 0));
|
| 363 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
| 364 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1p2(31 downto 0));
|
| 365 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
| 366 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1p1(31 downto 0));
|
| 367 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
| 368 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1p4(31 downto 0));
|
| 369 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
| 370 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1p5(31 downto 0));
|
| 371 |
54 |
jguarin200 |
write (buff,string'("}"));
|
| 372 |
50 |
jguarin200 |
writeline(mbuff,buff);
|
| 373 |
|
|
wait for tclk;
|
| 374 |
54 |
jguarin200 |
if now>=theend then
|
| 375 |
|
|
wait;
|
| 376 |
|
|
end if;
|
| 377 |
50 |
jguarin200 |
end loop displayRom;
|
| 378 |
|
|
end process tbproc0;
|
| 379 |
|
|
tbproc1:
|
| 380 |
|
|
process
|
| 381 |
|
|
variable buff : line;
|
| 382 |
55 |
jguarin200 |
variable theend : time :=30795 ns;
|
| 383 |
52 |
jguarin200 |
file fbuff : text open write_mode is "TRACE_decoded_factors_content.csv";
|
| 384 |
50 |
jguarin200 |
begin
|
| 385 |
|
|
|
| 386 |
54 |
jguarin200 |
write(buff,string'("#UF factors decoded test benching"));
|
| 387 |
50 |
jguarin200 |
writeline(fbuff, buff);
|
| 388 |
54 |
jguarin200 |
write(buff,string'("#{Time} {m0f0,m0f1}{m1f0,m1f1}{m2f0,m2f1}{m3f0,m3f1}{m4f0,m4f1}{m5f0,m5f1}"));
|
| 389 |
|
|
writeline(fbuff, buff);
|
| 390 |
50 |
jguarin200 |
wait for 5 ns;
|
| 391 |
|
|
wait until rst=not(rstMasterValue);
|
| 392 |
|
|
wait until clk='1';
|
| 393 |
|
|
wait for tclk2+tclk4; --! Garantizar la estabilidad de los datos que se van a observar en la salida.
|
| 394 |
|
|
displayRom:
|
| 395 |
|
|
loop
|
| 396 |
52 |
jguarin200 |
write (buff,string'(" { "));
|
| 397 |
54 |
jguarin200 |
write (buff,now,unit =>ns);
|
| 398 |
|
|
write (buff,string'(" } "));
|
| 399 |
|
|
write (buff,string'(" { "));
|
| 400 |
50 |
jguarin200 |
hexwrite_0 (buff,m0f0(17 downto 0));
|
| 401 |
52 |
jguarin200 |
write (buff,string'(","));
|
| 402 |
50 |
jguarin200 |
hexwrite_0 (buff,m0f1(17 downto 0));
|
| 403 |
52 |
jguarin200 |
write (buff,string'(" } { "));
|
| 404 |
50 |
jguarin200 |
hexwrite_0 (buff,m1f0(17 downto 0));
|
| 405 |
52 |
jguarin200 |
write (buff,string'(","));
|
| 406 |
50 |
jguarin200 |
hexwrite_0 (buff,m1f1(17 downto 0));
|
| 407 |
52 |
jguarin200 |
write (buff,string'(" } { "));
|
| 408 |
50 |
jguarin200 |
hexwrite_0 (buff,m2f0(17 downto 0));
|
| 409 |
52 |
jguarin200 |
write (buff,string'(","));
|
| 410 |
50 |
jguarin200 |
hexwrite_0 (buff,m2f1(17 downto 0));
|
| 411 |
52 |
jguarin200 |
write (buff,string'(" } { "));
|
| 412 |
50 |
jguarin200 |
hexwrite_0 (buff,m3f0(17 downto 0));
|
| 413 |
52 |
jguarin200 |
write (buff,string'(","));
|
| 414 |
50 |
jguarin200 |
hexwrite_0 (buff,m3f1(17 downto 0));
|
| 415 |
52 |
jguarin200 |
write (buff,string'(" } { "));
|
| 416 |
50 |
jguarin200 |
hexwrite_0 (buff,m4f0(17 downto 0));
|
| 417 |
52 |
jguarin200 |
write (buff,string'(","));
|
| 418 |
|
|
hexwrite_0 (buff,m4f1(17 downto 0));
|
| 419 |
|
|
write (buff,string'(" } { "));
|
| 420 |
50 |
jguarin200 |
hexwrite_0 (buff,m5f0(17 downto 0));
|
| 421 |
52 |
jguarin200 |
write (buff,string'(","));
|
| 422 |
50 |
jguarin200 |
hexwrite_0 (buff,m5f1(17 downto 0));
|
| 423 |
52 |
jguarin200 |
write (buff,string'(" }"));
|
| 424 |
50 |
jguarin200 |
writeline(fbuff,buff);
|
| 425 |
|
|
wait for tclk;
|
| 426 |
55 |
jguarin200 |
if now>=theend then
|
| 427 |
|
|
wait;
|
| 428 |
|
|
end if;
|
| 429 |
50 |
jguarin200 |
end loop displayRom;
|
| 430 |
|
|
end process tbproc1;
|
| 431 |
|
|
|
| 432 |
|
|
tbproc2:
|
| 433 |
|
|
process
|
| 434 |
|
|
variable buff : line;
|
| 435 |
55 |
jguarin200 |
variable theend : time :=30855 ns;
|
| 436 |
52 |
jguarin200 |
file rbuff : text open write_mode is "TRACE_results_content.csv";
|
| 437 |
50 |
jguarin200 |
begin
|
| 438 |
|
|
|
| 439 |
54 |
jguarin200 |
write(buff,string'("#UF results test benching"));
|
| 440 |
50 |
jguarin200 |
writeline(rbuff, buff);
|
| 441 |
54 |
jguarin200 |
write(buff,string'("#{Time} {CPX,CPY,CPZ}{DP0,DP1}"));
|
| 442 |
|
|
writeline(rbuff, buff);
|
| 443 |
|
|
|
| 444 |
50 |
jguarin200 |
wait for 5 ns;
|
| 445 |
|
|
wait until rst=not(rstMasterValue);
|
| 446 |
|
|
wait until clk='1';
|
| 447 |
|
|
wait for tclk2+tclk4; --! Garantizar la estabilidad de los datos que se van a observar en la salida.
|
| 448 |
|
|
displayRom:
|
| 449 |
|
|
loop
|
| 450 |
54 |
jguarin200 |
write (buff,string'(" { "));
|
| 451 |
50 |
jguarin200 |
write (buff,now,unit =>ns);
|
| 452 |
54 |
jguarin200 |
write (buff,string'(" }{ "));
|
| 453 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1a0(31 downto 0));
|
| 454 |
52 |
jguarin200 |
write (buff,string'(","));
|
| 455 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1a1(31 downto 0));
|
| 456 |
52 |
jguarin200 |
write (buff,string'(","));
|
| 457 |
50 |
jguarin200 |
hexwrite_0 (buff,stage1a2(31 downto 0));
|
| 458 |
54 |
jguarin200 |
write (buff,string'(" }{ "));
|
| 459 |
50 |
jguarin200 |
hexwrite_0 (buff,stage2a3(31 downto 0));
|
| 460 |
54 |
jguarin200 |
write (buff,string'("}{"));
|
| 461 |
50 |
jguarin200 |
hexwrite_0 (buff,stage2a4(31 downto 0));
|
| 462 |
52 |
jguarin200 |
write (buff,string'(" }"));
|
| 463 |
50 |
jguarin200 |
writeline(rbuff,buff);
|
| 464 |
|
|
wait for tclk;
|
| 465 |
55 |
jguarin200 |
if now>=theend then
|
| 466 |
|
|
wait;
|
| 467 |
|
|
end if;
|
| 468 |
50 |
jguarin200 |
end loop displayRom;
|
| 469 |
|
|
end process tbproc2;
|
| 470 |
|
|
|
| 471 |
|
|
end generate tbgen;
|
| 472 |
15 |
jguarin200 |
|
| 473 |
|
|
|
| 474 |
50 |
jguarin200 |
|
| 475 |
|
|
|
| 476 |
2 |
jguarin200 |
end uf_arch;
|