Synthesizable Verilog(设计编译器)中的浮点除法

Floating point division in Synthesizable Verilog (Design compiler)

我想在 Verilog 中编写一个执行除法的可综合模块,并且我想要一个浮点输出。我使用了这段代码,但我知道输入和输出都是错误的数据类型。在基本的 verilog 中,我知道类型 real 是不可综合的,因此我想问你如何修改我的代码才能在除法期间不丢失准确性。

module div_J_step1(J_step1, step1);
output [11:0] J_step1;
input [11:0] step1;
wire [11:0] J_step1;

localparam [11:0] J =2048;   

always @* begin
J_step1=J/step1;
end

endmodule

所以我的目标是获得带有一些小数的输出,这些小数将转到另一个块。我将使用 Synopsys Design Compiler 综合这个模块。非常感谢!

我这样解决了我的问题: 我只是左移 J,所以小数位左移,我可以将结果作为整数传送到以下块:

module div_J_step1(J_step1, step1);
output [16:0] J_step1;
input [11:0] step1;
wire [16:0] J_step1;

localparam [16:0] J =2048<<5;   

always @* begin
J_step1=J/step1;
end

endmodule

在接下来的代码块中,我会将结果右移>>5,所以我会得到正确的数字。我希望这个答案会有所帮助。再见!