diff options
author | Michael Abed <michaelabed@gmail.com> | 2012-02-17 12:10:31 -0500 |
---|---|---|
committer | Michael Abed <michaelabed@gmail.com> | 2012-02-17 12:10:31 -0500 |
commit | 59d89428d6160fb672c2b6a41339505cc69344d0 (patch) | |
tree | a774e809a31fc7eae7b0fd0777714c86ffedc9d6 /ALU.v | |
parent | 0bdf2f0b18f7e2986336f8afc67fe18b8b382e7a (diff) | |
download | ec311-lab2-master.tar.gz ec311-lab2-master.tar.bz2 ec311-lab2-master.zip |
Diffstat (limited to 'ALU.v')
-rwxr-xr-x | ALU.v | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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
|