1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-02-07 06:44:09 +08:00
oh/mathlib/hdl/oh_add.v

46 lines
1.4 KiB
Coq
Raw Normal View History

//#############################################################################
//# Function: Binary adder #
//#############################################################################
//# Author: Andreas Olofsson #
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
2015-12-17 13:50:59 -05:00
module oh_add
#(parameter N = 32, // block width
parameter SYN = "TRUE", // synthesizable
parameter TYPE = "DEFAULT" // implementation type
)
(//inputs
input [N-1:0] a, // first operand
input [N-1:0] b, // second operand
input [N-1:0] k, // carrry kill signal (active high)
input cin,// carry in
//outputs
output [N-1:0] sum,// sum
output [N-1:0] carry,// complete carry out vector
output cout// carry out from msb
);
2015-12-17 13:50:59 -05:00
generate
if(SYN == "TRUE") begin
assign {cout,sum[N-1:0]} = a[N-1:0] + b[N-1:0] + cin;
2021-08-02 17:37:36 -04:00
//TODO: FIX
assign carry = 'b0;
end
else begin
asic_add #(.TYPE(TYPE),
.N(N))
asic_add (// Outputs
.sum (sum[N-1:0]),
.carry (carry[N-1:0]),
.cout (cout),
// Inputs
.a (a[N-1:0]),
.b (b[N-1:0]),
.k (k[N-1:0]),
.cin (cin));
end
endgenerate
endmodule