1 |
2 |
borin |
-------------------------------------------------------------------------------------------------------------------
|
2 |
|
|
library ieee;
|
3 |
|
|
use ieee.std_logic_1164.all;
|
4 |
|
|
use ieee.numeric_std.all;
|
5 |
|
|
use work.riscompatible_package.all;
|
6 |
|
|
-------------------------------------------------------------------------------------------------------------------
|
7 |
|
|
entity Ula is
|
8 |
|
|
port
|
9 |
|
|
(
|
10 |
|
|
Cy_I : in std_logic;
|
11 |
|
|
Source1_I : in TRiscoWord;
|
12 |
|
|
Source2_I : in TRiscoWord;
|
13 |
|
|
Function_I : in std_logic_vector(4 downto 0);
|
14 |
|
|
Output_O : out TRiscoWord;
|
15 |
|
|
Cy_O : out std_logic;
|
16 |
|
|
Ov_O : out std_logic;
|
17 |
|
|
Zr_O : out std_logic;
|
18 |
|
|
Ng_O : out std_logic
|
19 |
|
|
);
|
20 |
|
|
end Ula;
|
21 |
|
|
-------------------------------------------------------------------------------------------------------------------
|
22 |
|
|
architecture behavioral of ula is
|
23 |
|
|
signal UlaTemp_W : std_logic_vector(32 downto 0);
|
24 |
|
|
signal Carry_W : TRiscoWord;
|
25 |
|
|
begin
|
26 |
|
|
Carry_W(0) <= Cy_I;
|
27 |
|
|
Carry_W(TRiscoWord'high downto 1) <= (others => '0');
|
28 |
|
|
with Function_I select
|
29 |
|
|
-- Fig. 5.8 of [1]
|
30 |
|
|
-- Carry -> bit 32
|
31 |
|
|
UlaTemp_W <=
|
32 |
|
|
('0'&Source1_I) and ('0'&Source2_I) when C_AND,
|
33 |
|
|
('0'&Source1_I) or ('0'&Source2_I) when C_OR,
|
34 |
|
|
('0'&Source1_I) xor ('0'&Source2_I) when C_XOR,
|
35 |
|
|
|
36 |
|
|
std_logic_vector(unsigned('0'¬(Source1_I)) + unsigned('0'&Source2_I) + unsigned(not(Carry_W))) when C_SUBRC,
|
37 |
|
|
std_logic_vector(unsigned('0'¬(Source1_I)) + unsigned('0'&Source2_I) + unsigned(Carry_W) ) when C_SUBRCNOT,
|
38 |
|
|
std_logic_vector(unsigned('0'¬(Source1_I)) + unsigned('0'&Source2_I) + 1 ) when C_SUBR,
|
39 |
|
|
std_logic_vector(unsigned('0'¬(Source1_I)) + unsigned('0'&Source2_I) + 0 ) when C_SUBRNC,
|
40 |
|
|
|
41 |
|
|
std_logic_vector(unsigned('0'&Source1_I) + unsigned('0'¬(Source2_I)) + unsigned(not(Carry_W))) when C_SUBC,
|
42 |
|
|
std_logic_vector(unsigned('0'&Source1_I) + unsigned('0'¬(Source2_I)) + unsigned(Carry_W) ) when C_SUBCNOT,
|
43 |
|
|
std_logic_vector(unsigned('0'&Source1_I) + unsigned('0'¬(Source2_I)) + 1 ) when C_SUB,
|
44 |
|
|
std_logic_vector(unsigned('0'&Source1_I) + unsigned('0'¬(Source2_I)) + 0 ) when C_SUBNC,
|
45 |
|
|
|
46 |
|
|
std_logic_vector(unsigned('0'&Source1_I) + unsigned('0'&Source2_I) + unsigned(not(Carry_W))) when C_ADDCNOT,
|
47 |
|
|
std_logic_vector(unsigned('0'&Source1_I) + unsigned('0'&Source2_I) + unsigned(Carry_W) ) when C_ADDC,
|
48 |
|
|
std_logic_vector(unsigned('0'&Source1_I) + unsigned('0'&Source2_I) + 1 ) when C_ADD1,
|
49 |
|
|
std_logic_vector(unsigned('0'&Source1_I) + unsigned('0'&Source2_I) + 0 ) when C_ADD,
|
50 |
|
|
|
51 |
|
|
(others => '0') when others;
|
52 |
|
|
Output_O <= UlaTemp_W(Output_O'range);
|
53 |
|
|
Cy_O <= UlaTemp_W(32);
|
54 |
|
|
Ov_O <= UlaTemp_W(32);
|
55 |
|
|
Zr_O <= IsZero_F(UlaTemp_W);
|
56 |
|
|
Ng_O <= UlaTemp_W(31);
|
57 |
|
|
end behavioral;
|
58 |
|
|
-------------------------------------------------------------------------------------------------------------------
|