diff options
author | Bobby Bingham <koorogi@koorogi.info> | 2017-01-08 21:58:16 -0600 |
---|---|---|
committer | Bobby Bingham <koorogi@koorogi.info> | 2017-01-08 23:18:31 -0600 |
commit | 17f5cbe781ae761d86d55fec7d46ba3172167894 (patch) | |
tree | b02d0dc075eb94a56cccd49a471e852a6799c266 /alu.v | |
parent | 47cfb7ba2df247310e2160e4e53d1843d4e4d1c8 (diff) |
Add carry input to ALU
Diffstat (limited to 'alu.v')
-rw-r--r-- | alu.v | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -2,6 +2,7 @@ module alu ( input [3:0] op, input [15:0] x, input [15:0] y, + input carry_in, output [15:0] result, output zero, output carry @@ -36,7 +37,7 @@ module alu ( assign issum = ~|(op[3:1]); - assign sum = x + (op[0] ? ~y + 1 : y); + assign sum = x + ({16{op[0]}} ^ y) + (op[0] ^ carry_in); assign prod = x * y; assign quot = x / y; assign anded = x & y; @@ -62,6 +63,6 @@ module alu ( shifted; assign zero = ~(|result); - assign carry = issum ? sum[16] : 1'b0; + assign carry = issum ? op[0] ^ sum[16] : 1'b0; endmodule |