verilog中可综合的64位全加器

时间:2015-10-18 09:31:39

标签: verilog

我想设计一个可综合的64位全加器,所以我需要将模块实例化64次,这会使代码变得笨重。任何人都可以建议一种替代方法来最小化代码?

1 个答案:

答案 0 :(得分:0)

除非您尝试理解门级设计的结构,否则使用可合成RTL会更容易:

localparam WIDTH = 64;
reg [WIDTH-1:0] a;
reg [WIDTH-1:0] b;
reg [WIDTH-1:0] sum;
always @* begin
  sum = a + b;
end


// to make output sync, put through flip flop
reg [WIDTH-1:0] sum_flop;
always @(posedge clk) begin
  sum_flop <= sum;
end

这可以改写为以下代码,但会生成相同的硬件。

localparam WIDTH = 64;
reg [WIDTH-1:0] a;
reg [WIDTH-1:0] b;
reg [WIDTH-1:0] sum_flop;

always @(posedge clk) begin
  sum_flop <= a + b;
end