diff options
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
|