mirror of
https://github.com/supleed2/ELEC40006-P1-CW.git
synced 2024-11-10 02:05:48 +00:00
Updated ALU to include PSH and POP
This commit is contained in:
parent
7997617e00
commit
f6b3489884
8
alu.v
8
alu.v
|
@ -1,4 +1,4 @@
|
||||||
module alu (enable, Rs1, Rs2, Rd, opcode, mulresult, exec2, mul1, mul2, Rout, jump, carry);
|
module alu (enable, Rs1, Rs2, Rd, opcode, mulresult, exec2, stackout, mul1, mul2, Rout, jump, carry);
|
||||||
|
|
||||||
input enable; // active LOW, disables the ALU during load/store operations so that undefined behaviour does not occur
|
input enable; // active LOW, disables the ALU during load/store operations so that undefined behaviour does not occur
|
||||||
input signed [15:0] Rd; // input destination register
|
input signed [15:0] Rd; // input destination register
|
||||||
|
@ -7,6 +7,7 @@ input signed [15:0] Rs2; // input source register 2
|
||||||
input [5:0] opcode; // opcode is fed in from instruction using wires outside ALU
|
input [5:0] opcode; // opcode is fed in from instruction using wires outside ALU
|
||||||
input signed [31:0] mulresult; // 32-bit result from multiplier
|
input signed [31:0] mulresult; // 32-bit result from multiplier
|
||||||
input exec2; // Input from state machine to indicate when to take in result from multiplication
|
input exec2; // Input from state machine to indicate when to take in result from multiplication
|
||||||
|
input [15:0] stackout; // input from stack to be fed back to registers
|
||||||
|
|
||||||
output reg signed [15:0] mul1; // first number to be multiplied
|
output reg signed [15:0] mul1; // first number to be multiplied
|
||||||
output reg signed [15:0] mul2; // second number to be multiplied
|
output reg signed [15:0] mul2; // second number to be multiplied
|
||||||
|
@ -125,6 +126,11 @@ always @(*)
|
||||||
6'b100110: ;
|
6'b100110: ;
|
||||||
6'b100111: ;
|
6'b100111: ;
|
||||||
|
|
||||||
|
6'b101000: alusum = {1'b0, Rs1}; // PSH Push value to stack (Stack = Rs1)
|
||||||
|
6'b101001: alusum = {1'b0, stackout}; // POP Pop value from stack (Rd = Stack)
|
||||||
|
6'b101010: ;
|
||||||
|
6'b101011: ;
|
||||||
|
|
||||||
6'b111110: ; // NOP No Operation (Do Nothing for a cycle)
|
6'b111110: ; // NOP No Operation (Do Nothing for a cycle)
|
||||||
6'b111111: alusum = {1'b0, 16'h0000}; // STP Stop (Program Ends)
|
6'b111111: alusum = {1'b0, 16'h0000}; // STP Stop (Program Ends)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue