summaryrefslogtreecommitdiff
path: root/ALU.v
diff options
context:
space:
mode:
authorMichael Abed <michaelabed@gmail.com>2012-02-17 12:10:31 -0500
committerMichael Abed <michaelabed@gmail.com>2012-02-17 12:10:31 -0500
commit59d89428d6160fb672c2b6a41339505cc69344d0 (patch)
treea774e809a31fc7eae7b0fd0777714c86ffedc9d6 /ALU.v
parent0bdf2f0b18f7e2986336f8afc67fe18b8b382e7a (diff)
downloadec311-lab2-master.tar.gz
ec311-lab2-master.tar.bz2
ec311-lab2-master.zip
finish itHEADmaster
Diffstat (limited to 'ALU.v')
-rwxr-xr-xALU.v8
1 files changed, 4 insertions, 4 deletions
diff --git a/ALU.v b/ALU.v
index 86c0372..af9b1a8 100755
--- a/ALU.v
+++ b/ALU.v
@@ -29,10 +29,10 @@ reg [3:0] o;
always @ ( * )
begin
case ( s )
- 2'd0 : o = a;
- 2'd1 : o = ~a+1;
- 2'd2 : o = a >> 1;
- 2'd3 : o = a % 3;
+ 2'b00 : o = a;
+ 2'b01 : o = (a != 4'b1000 ) ? (~a)+1 : 4'b0111;
+ 2'b10 : o = (a[3] != 1'b1 ) ? a >> 1 : ~(((~a)+4'b0001) >> 1)+4'b0001;
+ 2'b11 : o = (a[3] != 1'b1 ) ? a % 3 : ~(((~a)+4'b0001) % 3)+1;
endcase
end
endmodule