Add unconditional jump expressions
This commit is contained in:
parent
d27dee2745
commit
3e8a72fa05
|
@ -14,7 +14,8 @@ entity Decoder is
|
|||
RegOp1 : out std_logic_vector(3 downto 0); -- Rj: first register to read
|
||||
RegOp2 : out std_logic_vector(3 downto 0); -- Rk: second register to read
|
||||
RegWrite : out std_logic_vector(3 downto 0); -- Ri: the register to write to
|
||||
BranchEnable : out std_logic
|
||||
BranchEnable : out std_logic;
|
||||
UncondJump : out std_logic
|
||||
);
|
||||
end Decoder;
|
||||
|
||||
|
@ -39,12 +40,13 @@ begin
|
|||
when others => AluOpcd <= "1111"; -- if unsure, do nothing
|
||||
end case;
|
||||
|
||||
-- BranchEnable
|
||||
case Instruction(3 downto 0) is
|
||||
when "0001" | "1001" | "0100" | "1100" | "0101" | "1101" =>
|
||||
BranchEnable <= '1';
|
||||
-- BranchEnable / unconditionaljumpop
|
||||
case Instruction(5 downto 0) is
|
||||
when "001110" | "101110" => BranchEnable <= '1';
|
||||
when "011110" | "111110" => UncondJump <= '1';
|
||||
when others => BranchEnable <= '0';
|
||||
end case;
|
||||
|
||||
end process Decode;
|
||||
|
||||
end Implementation;
|
||||
|
|
|
@ -12,6 +12,7 @@ entity Branch is
|
|||
AluResult : in std_logic_vector(15 downto 0);
|
||||
PC : in std_logic_vector(15 downto 0);
|
||||
PMNext : in std_logic_vector(15 downto 0);
|
||||
UncondJump : in std_logic;
|
||||
JumpSuggest : out std_logic;
|
||||
PCCalc : out std_logic_vector(15 downto 0)
|
||||
);
|
||||
|
@ -22,6 +23,6 @@ architecture Implementation of Branch is
|
|||
begin
|
||||
|
||||
PCCalc <= std_logic_vector(signed(PC) + signed(PMNext));
|
||||
JumpSuggest <= BranchEnable and AluResult(0);
|
||||
JumpSuggest <= (BranchEnable and AluResult(0)) or UncondJump;
|
||||
|
||||
end Implementation;
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
library IEEE;
|
||||
use IEEE.std_logic_1164.all;
|
||||
|
||||
-- TODO: Check I Type; Implement Load instructions
|
||||
-- TODO: Connect Register Data in
|
||||
-- TODO: Add RAM data and address input
|
||||
-- TODO: Connect I2C
|
||||
-- TODO: Add peripheral Memory block
|
||||
|
||||
entity Cpu16 is
|
||||
port (
|
||||
Clk : in std_logic;
|
||||
|
@ -51,6 +57,7 @@ architecture Implementation of Cpu16 is
|
|||
signal BranchEnable : std_logic := '0';
|
||||
signal JumpEnable : std_logic := '0';
|
||||
signal State : std_logic_vector(2 downto 0) := (others => '0');
|
||||
signal UnconditionalJumpOp : std_logic := '0';
|
||||
begin
|
||||
|
||||
-- Include Entities
|
||||
|
@ -105,7 +112,8 @@ begin
|
|||
RegOp1 => RegisterRegister1,
|
||||
RegOp2 => RegisterRegister2,
|
||||
RegWrite => RegisterRegisterW,
|
||||
BranchEnable => BranchEnable
|
||||
BranchEnable => BranchEnable,
|
||||
UncondJump => UnconditionalJumpOp
|
||||
);
|
||||
|
||||
ImmUseless : entity work.Immediate(Implementation)
|
||||
|
@ -141,6 +149,7 @@ begin
|
|||
AluResult => AluResult,
|
||||
PC => InstructionCounter,
|
||||
PMNext => NextInstruction,
|
||||
UncondJump => UnconditionalJumpOp,
|
||||
JumpSuggest => Jump,
|
||||
PCCalc => PcAddrCalc
|
||||
);
|
||||
|
@ -171,7 +180,6 @@ begin
|
|||
end case;
|
||||
end process AluSetInput;
|
||||
|
||||
|
||||
RGB <= Switches(7 downto 0);
|
||||
|
||||
end Implementation;
|
||||
|
|
Loading…
Reference in New Issue