summaryrefslogtreecommitdiff
path: root/ALU.v
diff options
context:
space:
mode:
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