标签:round 方式 项目 idt 多次 https 代码 去掉 tar
https://mp.weixin.qq.com/s/-KUviTzO3Hdir_mI57L24g
module ABS #( parameter DATA_WIDTH = 8 ) ( input [DATA_WIDTH-1:0] din, output reg [DATA_WIDTH-1:0] dout ); localparam W = DATA_WIDTH; localparam MSB = DATA_WIDTH - 1; always @(*) begin if (din[MSB] == 1‘b1) begin // negative data if (din[W-2:0] == { (W-1){1‘b0} }) begin // Max dout = {1‘b0,{(W-1){1‘b1}}}; end else begin dout = {1‘b0,((~din[W-2:0])+1‘b1)}; end end else begin dout = din; end end endmodule
module ABS #( parameter DATA_WIDTH = 8 ) ( input [DATA_WIDTH-1:0] din, output reg [DATA_WIDTH-1:0] dout ); localparam W = DATA_WIDTH; localparam MSB = DATA_WIDTH - 1; wire din_sign = din[MSB]; wire [W-2:0] din_data = din[W-2:0]; wire [W-2:0] pad0 = { (W-1){1‘b0} }; wire [W-2:0] pad1 = { (W-1){1‘b1} }; always @(*) begin if (din_sign == 1‘b1) begin // negative data if (din_data == pad0) begin // Max dout = {1‘b0, pad1}; end else begin dout = {1‘b0,((~din_data)+1‘b1)}; end end else begin dout = din; end end endmodule
module ABS #( parameter DATA_WIDTH = 8 ) ( input [DATA_WIDTH-1:0] din, output reg [DATA_WIDTH-1:0] dout ); localparam W = DATA_WIDTH; localparam MSB = DATA_WIDTH - 1; wire din_sign = din[MSB]; wire [W-2:0] din_data = din[W-2:0]; wire [W-2:0] pad1 = { (W-1){1‘b1} }; always @(*) begin if (din_sign == 1‘b1) begin // negative data if (din_data == 0) begin // Max dout = {1‘b0, pad1}; end else begin dout = {1‘b0,((~din_data)+1‘b1)}; end end else begin dout = din; end end endmodule
module ABS #( parameter DATA_WIDTH = 8 ) ( input [DATA_WIDTH-1:0] din, output reg [DATA_WIDTH-1:0] dout ); localparam W = DATA_WIDTH; localparam MSB = DATA_WIDTH - 1; wire din_sign = din[MSB]; wire [W-2:0] din_data = din[W-2:0]; wire [W-2:0] pad1 = { (W-1){1‘b1} }; always @(*) begin if (din_sign == 1‘b1) begin // negative data if (din_data == 0) begin // Max dout = ~din; end else begin dout = {1‘b0,((~din_data)+1‘b1)}; end end else begin dout = din; end end endmodule
module ABS #( parameter DATA_WIDTH = 8 ) ( input [DATA_WIDTH-1:0] din, output reg [DATA_WIDTH-1:0] dout ); localparam W = DATA_WIDTH; localparam MSB = DATA_WIDTH - 1; wire din_sign = din[MSB]; wire [W-2:0] din_data = din[W-2:0]; always @(*) begin if (din_sign == 1‘b1) begin // negative data if (din_data == 0) begin // Max dout = ~din; end else begin dout = ~din + 1; end end else begin dout = din; end end endmodule
module ABS #( parameter DATA_WIDTH = 8 ) ( input [DATA_WIDTH-1:0] din, output reg [DATA_WIDTH-1:0] dout ); localparam W = DATA_WIDTH; wire din_sign = din[W-1]; wire [W-2:0] din_data = din[W-2:0]; always @(*) begin if (din_sign == 1‘b1) begin // negative data if (din_data == 0) begin // Max dout = ~din; end else begin dout = ~din + 1; end end else begin dout = din; end end endmodule
标签:round 方式 项目 idt 多次 https 代码 去掉 tar
原文地址:https://www.cnblogs.com/wjcdx/p/9813097.html