quartus的IP测试之LPM_DIVIDE
1、基本作用
一个用于除法的IP,可以输入除数、被除数,得到商、余值。
2、基本测试
`timescale 1ns/1ns module divide_tb; reg [7:0]denom; reg [7:0]numer; wire [7:0] quotient; wire [7:0] remain; initial begin $monitor($realtime,,"denom=%d,numer=%d,quotient=%d,remain=%d" ,denom,numer,quotient,remain); denom=1; numer=1; #1 denom=4; numer=2; #2 denom=6; numer=0; #2 denom=0; numer=1; #4 $stop; end divide_top U1_top( .denom(denom), .numer(numer), .quotient(quotient), .remain(remain) ); endmodule
module divide_top( input [7:0] denom, input [7:0] numer, output [7:0] quotient, output [7:0] remain ); myip_divide U1_demo( .denom(denom), .numer(numer), .quotient(quotient), .remain(remain) ); endmodule
# run -all # 0 denom= 1,numer= 1,quotient= 1,remain= 0 # 1 denom= 4,numer= 2,quotient= 0,remain= 2 # 3 denom= 6,numer= 0,quotient= 0,remain= 0 # 5 denom= 0,numer= 1,quotient= x,remain= x # ** Note: $stop : D:/Library/FPGA_altera/A8_LPM_DIVIDE/standard_module/divide_tb.v(23) # Time: 9 ns Iteration: 0 Instance: /divide_tb
3、使用小结
除数为0时输出均为x,其他的和正常的整数除法的功能是一致的。