Skip to content

Commit

Permalink
feat: write back stage
Browse files Browse the repository at this point in the history
  • Loading branch information
FaresAtef1 committed Dec 4, 2023
1 parent 3b609be commit bff28ce
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions WriteBackStage.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
USE std.textio.ALL;
USE ieee.std_logic_textio.ALL;

ENTITY WriteBackStage IS
PORT (
Mem_Out, ALU_Res, Port_Out : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
IOR, Mem_2Reg : IN STD_LOGIC;
Write_Data : OUT STD_LOGIC_VECTOR (31 DOWNTO 0));
END WriteBackStage;

ARCHITECTURE ArchWriteBackStage OF WriteBackStage IS
BEGIN
PROCESS (Mem_Out, ALU_Res, Port_Out, IOR, Mem_2Reg)
BEGIN
IF (IOR = '1') THEN
Write_Data <= Port_Out;
ELSIF (Mem_2Reg = '1') THEN
Write_Data <= Mem_Out;
ELSE
Write_Data <= ALU_Res;
END IF;
END PROCESS;
END ArchWriteBackStage;

0 comments on commit bff28ce

Please sign in to comment.