mirror of
https://github.com/aolofsson/oh.git
synced 2025-01-30 02:32:53 +08:00
Adding asic_add block to abs circuit
This commit is contained in:
parent
e82fdb65a1
commit
edaa41dac7
@ -5,17 +5,31 @@
|
|||||||
//# License: MIT (see LICENSE file in OH! repository) #
|
//# License: MIT (see LICENSE file in OH! repository) #
|
||||||
//#############################################################################
|
//#############################################################################
|
||||||
|
|
||||||
module oh_abs #(parameter DW = 2) // data width
|
module oh_abs
|
||||||
|
#(parameter N = 32, // block width
|
||||||
|
parameter SYN = "TRUE", // synthesizable
|
||||||
|
parameter TYPE = "DEFAULT" // implementation type
|
||||||
|
)
|
||||||
(
|
(
|
||||||
input [DW-1:0] in, //input operand
|
input [N-1:0] in, // input operand
|
||||||
output [DW-1:0] out, //out = abs(in) (signed two's complement)
|
output [N-1:0] out, // out = abs(in) (signed two's complement)
|
||||||
output overflow // high for max negative #
|
output overflow // high for max negative #
|
||||||
);
|
);
|
||||||
|
|
||||||
assign out[DW-1:0] = in[DW-1] ? ~in[DW-1:0] + 1'b1 :
|
generate
|
||||||
in[DW-1:0];
|
if(SYN == "TRUE") begin
|
||||||
|
assign out[N-1:0] = in[N-1] ? ~in[N-1:0] + 1'b1 : in[N-1:0];
|
||||||
assign overflow = in[DW-1] & ~(|in[DW-2:0]);
|
assign overflow = in[N-1] & ~(|in[N-2:0]);
|
||||||
|
end
|
||||||
endmodule // oh_abs
|
else begin
|
||||||
|
asic_abs #(.TYPE(TYPE),
|
||||||
|
.N(N))
|
||||||
|
asic_abs(// Outputs
|
||||||
|
.out (out[N-1:0]),
|
||||||
|
.overflow (overflow),
|
||||||
|
// Inputs
|
||||||
|
.in (in[N-1:0]));
|
||||||
|
end
|
||||||
|
|
||||||
|
endgenerate
|
||||||
|
endmodule
|
||||||
|
Loading…
x
Reference in New Issue
Block a user