aboutsummaryrefslogtreecommitdiff
path: root/alu.sv
diff options
context:
space:
mode:
authorkryptoish <krish_thakur7@icloud.com>2024-12-07 22:12:43 -0800
committerkryptoish <krish_thakur7@icloud.com>2024-12-07 22:12:43 -0800
commitf9d92b31e4bea3037c75f7c7a508c1be09811fd0 (patch)
tree5cd7160603f0841c0661e5c50fca5e3c28b96af4 /alu.sv
parentadded files (diff)
Final Working Version
Diffstat (limited to '')
-rw-r--r--alu.sv21
1 files changed, 0 insertions, 21 deletions
diff --git a/alu.sv b/alu.sv
deleted file mode 100644
index 4e17d8b..0000000
--- a/alu.sv
+++ /dev/null
@@ -1,21 +0,0 @@
- module ALU(Ain,Bin,ALUop,out,Z);
- input [15:0] Ain, Bin;
- input [1:0] ALUop;
- output reg [15:0] out;
- output reg [2:0] Z; //Z[0] = zero flag, Z[1] = neg flag, Z[2] = overflow flag
-
- always_comb begin
- case(ALUop)
- 2'b00 : out = Ain + Bin; //add Ain and Bin
- 2'b01 : out = Ain - Bin; //subtract Ain and Bin
- 2'b10 : out = Ain & Bin; //AND Ain and Bin
- 2'b11 : out = ~Bin; //Negate Bin
- endcase
-
- //make it better by putting it into the add and subtraction above
- Z[0] = out[15]; //negative
- Z[1] = (ALUop == 2'b00) ? ((Ain[15] == Bin[15]) && (out[15] != Ain[15])) :
- (ALUop == 2'b01) ? ((Ain[15] != Bin[15]) && (out[15] != Ain[15])) : 1'b0; //improvements could be made
- Z[2] = out == {16{1'b0}}; //zero
- end
- endmodule \ No newline at end of file