forked from AndrewMcClelland/RISC_Computer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcon_ff_logic.vhd
More file actions
56 lines (41 loc) · 1.46 KB
/
Copy pathcon_ff_logic.vhd
File metadata and controls
56 lines (41 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
library IEEE;
use ieee.std_logic_1164.all;
entity con_ff_logic is
port(IR_low_bits : in std_logic_vector(1 downto 0);
register_in : in std_logic_vector(31 downto 0);
Con_in, con_clk : in std_logic;
con_out : out std_logic
);
end con_ff_logic;
architecture behavioral of con_ff_logic is
component D_flipflop is
port(clk, d, enable : in std_logic;
q : out std_logic
);
end component D_flipflop;
signal or_output : std_logic;
begin
d_ff_con : D_flipflop port map(clk => con_clk, d => or_output, enable => Con_in, q => con_out);
process(IR_low_bits, register_in, con_in) is
variable out_decoder : std_logic_vector(3 downto 0);
variable and0, and1, and2, and3 : std_logic;
variable register_nor : std_logic;
begin
register_nor := register_in(0);
for bit_index in 1 to 31 loop
register_nor := register_nor nor register_in(bit_index);
end loop;
case IR_low_bits is
when "00" => out_decoder := b"0001"; -- brzr
when "01" => out_decoder := b"0010"; -- brnz
when "10" => out_decoder := b"0100"; -- brpl
when "11" => out_decoder := b"1000"; -- brmi
when others => out_decoder := b"0000";
end case;
and0 := out_decoder(0) and register_nor; -- = 0
and1 := out_decoder(1) and (not register_nor); -- != 0
and2 := out_decoder(2) and (not register_in(31)); -- >= 0
and3 := out_decoder(3) and register_in(31); -- < 0
or_output <= and0 or and1 or and2 or and3;
end process;
end architecture behavioral;