寻:调用除法器的IP核的verilog例子
坚强起来
me2
使用ISE7.1i core generator生成
div div_test(.dividend(dividend),//a(a/b)
.divisor(divisor),//b
.quot(quot),//商
.remd(),//余数
.clk(clk),//时钟
.rfd(),//一般不用
.aclr(1'b0),//异步清零
.sclr(1'b0),//同步清零
.ce(1'b1));//使能
最简单的用法:
IPcore产生的除法器则需要一定量时钟周期运算才产生结果(依除法器位数而定)。最好用之前做个测试或是看看datasheet
sclr,aclr,不用管直接设为0.rfd不用管
要是使能信号ce设为1.所以最好数据都在始终下降沿输入乘法器,因为除法器若在时钟上升沿输入则会在结果前有一个数1023(除零危险)。如果要避免这种情况可以,在输入数据后让ce由低变高就行了.
ISE生成的IPcore占用资源太多,有空的话可以自己写一个.
QII环境下有没有除法器的IP CORE?
有的.
TOOLS->MEGA WIZARD->CREATE NEW MEGA FUNCTION-> 右邊 設定OUTPUT FILE ->左邊 選divIDE_LPM 或 ALTFP_div
然後設定參數, 就可以了
以下是 divIDE_LPM 範例 8BIT/8BIT 結果
// synopsys translate_off
`timescale 1 ps / 1 ps
// synopsys translate_on
module div (
denom,
numer,
quotient,
remain);
input [7:0] denom;
input [7:0] numer;
output [7:0] quotient;
output [7:0] remain;
wire [7:0] sub_wire0;
wire [7:0] sub_wire1;
wire [7:0] quotient = sub_wire0[7:0];
wire [7:0] remain = sub_wire1[7:0];
lpm_divide lpm_divide_component (
.denom (denom),
.numer (numer),
.quotient (sub_wire0),
.remain (sub_wire1),
.aclr (1'b0),
.clken (1'b1),
.clock (1'b0));
defparam
lpm_divide_component.lpm_drepresentation = "UNSIGNED",
lpm_divide_component.lpm_hint = "LPM_REMAINDERPOSITIVE=TRUE",
lpm_divide_component.lpm_nrepresentation = "UNSIGNED",
lpm_divide_component.lpm_type = "LPM_divIDE",
lpm_divide_component.lpm_widthd = 8,
lpm_divide_component.lpm_widthn = 8;
endmodule
