oALUOut:outstd_logic_vector(N-1downto0));-- TODO: Hook this up to the output of the ALU. It is important for synthesis that you have this output that can effectively be impacted by all other components so they are not optimized away.
endMIPS_Processor;
architecturestructureofMIPS_Processoris
componentmemis
generic(ADDR_WIDTH:integer;
DATA_WIDTH:integer);
port(
clk:instd_logic;
addr:instd_logic_vector((ADDR_WIDTH-1)downto0);
data:instd_logic_vector((DATA_WIDTH-1)downto0);
we:instd_logic:='1';
q:outstd_logic_vector((DATA_WIDTH-1)downto0));
endcomponent;
componentif_id_regis
generic(N:integer:=96);
port(
iCLK:instd_logic;-- Clock
iRST:instd_logic;-- Reset
iWE:instd_logic;-- Write Enable
currentPC:instd_logic_vector(31downto0);-- Holds Current PC Address
signals_IMemAddr:std_logic_vector(N-1downto0);-- Do not assign this signal, assign to s_NextInstAddr instead
signals_NextInstAddr:std_logic_vector(N-1downto0);-- TODO: use this signal as your intended final instruction memory address input.
signals_Inst,s_Inst_de:std_logic_vector(N-1downto0);-- TODO: use this signal as the instruction signal
-- Required halt signal -- for simulation
signals_Halt,s_halt_temp,s_regWr_temp:std_logic;-- TODO: this signal indicates to the simulation that intended program execution has completed. (Opcode: 01 0100)
-- Required overflow signal -- for overflow exception detection
signals_Ovfl,s_ovfl_ex,s_ovfl_mem,s_extender:std_logic;-- TODO: this signal indicates an overflow exception would have been initiated
--Josh's added signals (feel free to change if you find redundancy or errors)
signals_zeroToFetch:std_logic;--zero signal output from alu that goes to fetch
signals_branch:std_logic;--branch output from control unit to fetch logic
signals_jump:std_logic;--jump output from control to fetch logic
signals_stall,s_flush,s_stall_r,s_flush_r:std_logic;-- stall the program, flush
-- TODO: You may add any additional signals or components your implementation
-- requires below this comment
-- MUX control Signals
signals_regDst:std_logic;-- MUX control signal for RegDst.
signals_alusrc:std_logic;-- MUX control signal for aluSRC.
--MUX Output Signals
signals_ALU2,s_temp:std_logic_vector(N-1downto0);-- MUX Output signal for ALUSRC that feeds to ALU port 2
--Instruction Splices
signals_inst_32b,s_inst_32b_exreg,s_inst_32b_zero,s_inst_32b_sign,s_rd1_ex,s_rd2_ex,s_rd2_mem,s_rd1_de,s_rd2_de:std_logic_vector(DATA_WIDTH-1downto0);-- sign extended form of 15-0 bits of inst.
signals_PCPlus4_passthrough,s_currentAddr,s_PCPlus4_passthrough_ex,s_PCPlus4_passthrough_mem:std_logic_vector(DATA_WIDTH-1downto0);-- passed through PCPlus4 for state reg
--Control signals
signals_ALUOP,s_shamt,s_rd_id_ex_out:std_logic_vector(4downto0);-- control signal
signals_jump_target,s_branch_target,s_vhdlSucks,s_PCSrc_next:std_logic_vector(DATA_WIDTH-1downto0);--self explanatory, except VHDL sucks is the legacy final target signal.
--mux set nextInstr to JR that loads $31 when opcode == JR
--OvFL detection
-- TODO: This is required to be your final input to your instruction memory. This provides a feasible method to externally load the memory module which means that the synthesis tool must assume it knows nothing about the values stored in the instruction memory. If this is not included, much, if not all of the design is optimized out because the synthesis tool will believe the memory to be all zeros.
withiInstLdselect
s_IMemAddr<=s_NextInstAddrwhen'0',
iInstAddrwhenothers;
IMem:mem
genericmap(ADDR_WIDTH=>ADDR_WIDTH,
DATA_WIDTH=>N)
portmap(clk=>iCLK,
addr=>s_IMemAddr(11downto2),
data=>iInstExt,
we=>iInstLd,
q=>s_Inst);
-- oALUOut <= s_oALUOut; -- connect signal to output port
--s_DMemData <= s_RegReadData2;
oALUOut<=s_DMemAddr;
s_25_21<=s_Inst_de(25downto21);
s_20_16<=s_Inst_de(20downto16);
s_25_0<=s_Inst_de(25downto0);
s_31_26<=s_Inst_de(31downto26);
s_5_0<=s_Inst_de(5downto0);
-- Instruction Memory
--s_control_id_ex <= s_Inst_de(11 downto 0)
pcreg:pc_reg
portmap(i_CLK=>iCLK,-- Clock input
i_RST=>iRST,-- Reset input
i_WE=>'1',-- Write enable input
i_D=>s_nextInst,-- Data value input
o_Q=>s_NextInstAddr);-- Data value output
fetch_hack:fetch
portmap(
iCLK=>iCLK,
iRST=>iRST,
i_A=>s_IMemAddr,
o_A=>s_PCSrc_next,--PC plus 4
i_B=>s_inst_32b_exreg(29downto0),
o_B=>s_temp
);
s_pc_src_reg<='1'WHEN(s_control_id_ex(7)='1')ELSE-- MUX to correct for branch not taken.
-- i_signExt => s_inst_32b, --sign extended 32 bit number after the sign extension from 16 to 32
-- i_mem => s_25_0, --gives 26 bit value from instructin memory
-- i_zero => s_zeroToFetch, --zero input from ALU
-- i_jump => s_jump, --jump input from control unit
-- i_branch => s_branch, --branch input value from control unit
-- i_enable => '1', --enable from register(PC) or not - (we can probably get rid of this and just input 1 into the enable for the PC register within fetch)
-- i_ALUOP => s_ALUOP,
-- i_jr => s_jr,
-- i_jrdat => s_RegReadData1,
-- o_plusFour => main_plusFour,
-- o_A => s_nextInst --output of the last mux that then inputs back into the PC register
-- );
-- reg_fetch_decode: mux32t1
--Jump: mux2t1_N
--generic map(N => 32)
-- port map(i_S => s_jump,
-- i_D0 => s_normalOrBranch,
-- i_D1 => s_finalJumpAddress,
-- o_O => s_inputPC);
-- TODO: Ensure that s_Halt is connected to an output control signal produced from decoding the Halt instruction (Opcode: 01 0100)
-- TODO: Ensure that s_Ovfl is connected to the overflow output of your ALU
-- TODO: Implement the rest of your processor below this comment!