前言
使用dsp的方法一般有兩種:讓綜合器自己推斷、例化dsp原語。
有的時候為了偷懶或者有的計數器之類的需要跑高速,則可以讓計數器也使用dsp實現。
語法:(*use_dsp=「yes」*)
流程1.編寫**測試,乙個乘法器加乙個cnt計數器,直接在模組頭使用語法規則。
`timescale 1ns/1ps2.綜合適配看看結果:可以看到使用了2個dsp塊。(*use_dsp = "
yes"*)module
mul_test (
input
i_clk ,
input [17:0
] i_mul_a ,
input [17:0
] i_mul_b ,
output [35:0
] o_mul_result,
output [15:0
] o_cnt
);reg [15:0] r_cnt = '
d0;always @(posedge
i_clk)
begin
r_cnt
<= r_cnt + '
d1;end
assign o_cnt =r_cnt;
reg [17:0] r_mul_a_delay_0 = 18
'd0;
reg [17:0] r_mul_a_delay_1 = 18
'd0;
reg [17:0] r_mul_b_delay_0 = 18
'd0;
reg [17:0] r_mul_b_delay_1 = 18
'd0;
reg [35:0] r_mul_result_0 = 36
'd0;
reg [35:0] r_mul_result_1 = 36
'd0;
reg [35:0] r_mul_result_2 = 36
'd0;
reg [35:0] r_mul_result_3 = 36
'd0;
always @(posedge
i_clk)
begin
r_mul_a_delay_0
<=i_mul_a;
r_mul_a_delay_1
<=r_mul_a_delay_0;
r_mul_b_delay_0
<=i_mul_b;
r_mul_b_delay_1
<=r_mul_b_delay_0;
endalways @(posedge
i_clk)
begin
r_mul_result_0
<= r_mul_a_delay_1 *r_mul_b_delay_1;
endalways @(posedge
i_clk)
begin
r_mul_result_1
<=r_mul_result_0;
r_mul_result_2
<=r_mul_result_1;
r_mul_result_3
<=r_mul_result_2;
endassign o_mul_result =r_mul_result_3;
endmodule
//end the mul_test model
如果只是乘法使用dsp實現的話,在結果暫存器新增語法規則即可。
(*use_dsp = "yes"*)reg [35:0] r_mul_result_0 = 36'd0;
以上。
Verilog可綜合不可綜合語句
1 所有綜合工具都支援的結構 always,assign,begin,end,case,wire,tri,generate,aupply0,supply1,reg,integer,default,for,function,and,nand,or,nor,xor,xnor,buf,not,bufif0...
verilog 不可綜合語句
礎知識 verilog 不可綜合語句 1 所有綜合工具都支援的結構 always,assign,begin,end,case,wire,tri,aupply0,supply1,reg,integer,default,for,function,and,nand,or,nor,xor,xnor,buf,...
verilog中的可綜合與不可綜合語句
1 所有綜合工具都支援的結構 always,assign,begin,end,case,wire,tri,aupply0,supply1,reg,integer,default,for,function,and,nand,or,nor,xor,xnor,buf,not,bufif0,bufif1,n...