Advertisement
Mikestriken

Branch_ALU

Apr 7th, 2023 (edited)
1,815
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.85 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.NUMERIC_STD.ALL;
  4.  
  5. entity branch_alu is
  6.     port (
  7.         current_instruction     : in  std_logic_vector(63 downto 0); -- Note: current instruction needs to be divided by 4 technically.
  8.         next_instruction_offset  : in std_logic_vector(63 downto 0);
  9.         next_instruction  : out std_logic_vector(63 downto 0)
  10.     );
  11. end entity branch_alu;
  12.  
  13. architecture dataflow of branch_alu is
  14.     signal next_instruction_offset_shifted : std_logic_vector(63 downto 0);
  15. begin
  16.     -- Shift next_instruction_offset to multiply it by 4
  17.     next_instruction_offset_shifted <= std_logic_vector(shift_left(signed(next_instruction_offset), 2));
  18.    
  19.     -- Add result together
  20.     next_instruction <= std_logic_vector(signed(next_instruction_offset_shifted) + signed(current_instruction));
  21. end architecture dataflow;
Tags: Branch_ALU
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement