diff options
| author | kryptoish <krish_thakur7@icloud.com> | 2024-12-07 22:12:43 -0800 |
|---|---|---|
| committer | kryptoish <krish_thakur7@icloud.com> | 2024-12-07 22:12:43 -0800 |
| commit | f9d92b31e4bea3037c75f7c7a508c1be09811fd0 (patch) | |
| tree | 5cd7160603f0841c0661e5c50fca5e3c28b96af4 /src/alu.sv | |
| parent | added files (diff) | |
Final Working Version
Diffstat (limited to 'src/alu.sv')
| -rw-r--r-- | src/alu.sv | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/alu.sv b/src/alu.sv new file mode 100644 index 0000000..c6d00bd --- /dev/null +++ b/src/alu.sv @@ -0,0 +1,17 @@ +module ALU(Ain, Bin, op, out, status); + input [1:0] op; + input [15:0] Ain, Bin; + output [2:0] status; + output reg [15:0] out; + + assign status[2] = out[15]; + assign status[1] = (out[15] ^ Ain[15]) & ~(out[15] ^ Bin[15]); + assign status[0] = (out == 0); + + always_comb case (op) + 2'b00: out = Ain + Bin; + 2'b01: out = Ain - Bin; + 2'b10: out = Ain & Bin; + 2'b11: out = ~Bin; + endcase +endmodule: ALU |