完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
从书上找到的fir并行设计程序,对代码几点不太理解:1、移位寄存为什么还要把数据的高位也再次存进去?
2、在设置mult ip核的时候,在设置里面会有乘法是否设置 unsigned和signed,那在第一个问题的基础上,我是设置unsigned还是signed? 3、滤波器的设计,我要给他什么样子的输入,仿真看得出什么样子的结果? 部分代码如下 |
|
相关推荐
6个回答
|
|
module fir(
input clk, input rst_n, input [11:0] fir_in, // 12位输入 output reg [26:0] fir_out //27位输出 ); //------------------------------------------------ parameter cof1 = 12'd41; parameter cof2 = 12'd132; parameter cof3 = 12'd341; parameter cof4 = 12'd510; //------------------------------------------------ reg [11:0] fir_in_reg; reg [12:0] shift_buf [7:0];//定义8个13位寄存器 //------------------------------------------------ wire [12:0] add07; wire [12:0] add16; wire [12:0] add25; wire [12:0] add34;//对称性前后两个相加 wire [24:0] mul1; wire [24:0] mul2; wire [24:0] mul3; wire [24:0] mul4;//系数相乘(12位) //------------------------------------------------ integer i,j; always@(posedge clk or negedge rst_n) begin if(!rst_n) fir_in_reg <= 12'd0; else fir_in_reg <= fir_in; end always@(posedge clk or negedge rst_n) begin if(!rst_n) for(i=0;i <= 7;i=i+1) shift_buf[i] <= 13'd0; else begin for(j=0;j < 7;j=j+1) shift_buf[j+1] <= shift_buf[j]; shift_buf[0] <= {fir_in_reg[11],fir_in_reg}; end end //---------------------------------------------------- assign add07 = shift_buf[0] + shift_buf[7]; assign add16 = shift_buf[1] + shift_buf[6]; assign add25 = shift_buf[2] + shift_buf[5]; assign add34 = shift_buf[3] + shift_buf[4]; //---------------------------------------------------- mult1 mult_inst1( .dataa(cof1), .datab(add07), .result(mul1) ); mult1 mult_inst2( .dataa(cof2), .datab(add16), .result(mul2) ); mult1 mult_inst3( .dataa(cof3), .datab(add25), .result(mul3) ); mult1 mult_inst4( .dataa(cof4), .datab(add34), .result(mul4) ); //--------------------------------------------- wire [25:0] add_mul12 = {mul1[24],mul1}+{mul2[24],mul2}; wire [25:0] add_mul34 = {mul3[24],mul3}+{mul4[24],mul4};//26位 //--------------------------------------------- always@(posedge clk or negedge rst_n) begin if(!rst_n) fir_out <= 27'd0; else fir_out <= {add_mul12[25],add_mul12}+{add_mul34[25],add_mul34}; end endmodule |
|
|
|
module fir(
input clk, input rst_n, input [11:0] fir_in, // 12位输入 output reg [26:0] fir_out //27位输出 ); //------------------------------------------------ parameter cof1 = 12'd41; parameter cof2 = 12'd132; parameter cof3 = 12'd341; parameter cof4 = 12'd510; //------------------------------------------------ reg [11:0] fir_in_reg; reg [12:0] shift_buf [7:0];//定义8个13位寄存器 //------------------------------------------------ wire [12:0] add07; wire [12:0] add16; wire [12:0] add25; wire [12:0] add34;//对称性前后两个相加 wire [24:0] mul1; wire [24:0] mul2; wire [24:0] mul3; wire [24:0] mul4;//系数相乘(12位) //------------------------------------------------ integer i,j; always@(posedge clk or negedge rst_n) begin if(!rst_n) fir_in_reg <= 12'd0; else fir_in_reg <= fir_in; end always@(posedge clk or negedge rst_n) begin if(!rst_n) for(i=0;i <= 7;i=i+1) shift_buf[i] <= 13'd0; else begin for(j=0;j < 7;j=j+1) shift_buf[j+1] <= shift_buf[j]; shift_buf[0] <= {fir_in_reg[11],fir_in_reg}; end end //---------------------------------------------------- assign add07 = shift_buf[0] + shift_buf[7]; assign add16 = shift_buf[1] + shift_buf[6]; assign add25 = shift_buf[2] + shift_buf[5]; assign add34 = shift_buf[3] + shift_buf[4]; //---------------------------------------------------- mult1 mult_inst1( .dataa(cof1), .datab(add07), .result(mul1) ); mult1 mult_inst2( .dataa(cof2), .datab(add16), .result(mul2) ); mult1 mult_inst3( .dataa(cof3), .datab(add25), .result(mul3) ); mult1 mult_inst4( .dataa(cof4), .datab(add34), .result(mul4) ); //--------------------------------------------- wire [25:0] add_mul12 = {mul1[24],mul1}+{mul2[24],mul2}; wire [25:0] add_mul34 = {mul3[24],mul3}+{mul4[24],mul4};//26位 //--------------------------------------------- always@(posedge clk or negedge rst_n) begin if(!rst_n) fir_out <= 27'd0; else fir_out <= {add_mul12[25],add_mul12}+{add_mul34[25],add_mul34}; end endmodule |
|
|
|
module fir(
input clk, input rst_n, input [11:0] fir_in, // 12位输入 output reg [26:0] fir_out //27位输出 ); //------------------------------------------------ parameter cof1 = 12'd41; parameter cof2 = 12'd132; parameter cof3 = 12'd341; parameter cof4 = 12'd510; //------------------------------------------------ reg [11:0] fir_in_reg; reg [12:0] shift_buf [7:0];//定义8个13位寄存器 //------------------------------------------------ wire [12:0] add07; wire [12:0] add16; wire [12:0] add25; wire [12:0] add34;//对称性前后两个相加 wire [24:0] mul1; wire [24:0] mul2; wire [24:0] mul3; wire [24:0] mul4;//系数相乘(12位) //------------------------------------------------ integer i,j; always@(posedge clk or negedge rst_n) begin if(!rst_n) fir_in_reg <= 12'd0; else fir_in_reg <= fir_in; end always@(posedge clk or negedge rst_n) begin if(!rst_n) for(i=0;i <= 7;i=i+1) shift_buf[i] <= 13'd0; else begin for(j=0;j < 7;j=j+1) shift_buf[j+1] <= shift_buf[j]; shift_buf[0] <= {fir_in_reg[11],fir_in_reg}; end end //---------------------------------------------------- assign add07 = shift_buf[0] + shift_buf[7]; assign add16 = shift_buf[1] + shift_buf[6]; assign add25 = shift_buf[2] + shift_buf[5]; assign add34 = shift_buf[3] + shift_buf[4]; //---------------------------------------------------- mult1 mult_inst1( .dataa(cof1), .datab(add07), .result(mul1) ); mult1 mult_inst2( .dataa(cof2), .datab(add16), .result(mul2) ); mult1 mult_inst3( .dataa(cof3), .datab(add25), .result(mul3) ); mult1 mult_inst4( .dataa(cof4), .datab(add34), .result(mul4) ); //--------------------------------------------- wire [25:0] add_mul12 = {mul1[24],mul1}+{mul2[24],mul2}; wire [25:0] add_mul34 = {mul3[24],mul3}+{mul4[24],mul4};//26位 //--------------------------------------------- always@(posedge clk or negedge rst_n) begin if(!rst_n) fir_out <= 27'd0; else fir_out <= {add_mul12[25],add_mul12}+{add_mul34[25],add_mul34}; end endmodule |
|
|
|
回帖奖励 +2 分积分
部分代码呢?在哪儿
|
|
|
|
always@(posedge clk or negedge rst_n)
begin if(!rst_n) for(i=0;i <= 7;i=i+1) shift_buf[i] <= 13'd0; else begin for(j=0;j < 7;j=j+1) shift_buf[j+1] <= shift_buf[j]; shift_buf[0] <= {fir_in_reg[11],fir_in_reg}; end end //---------------------------------------------------- assign add07 = shift_buf[0] + shift_buf[7]; assign add16 = shift_buf[1] + shift_buf[6]; assign add25 = shift_buf[2] + shift_buf[5]; assign add34 = shift_buf[3] + shift_buf[4]; //---------------------------------------------------- mult1 mult_inst1( .dataa(cof1), .datab(add07), .result(mul1) ); |
|
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1413 浏览 1 评论
1208 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
1419 浏览 0 评论
913 浏览 0 评论
2223 浏览 0 评论
1425 浏览 34 评论
5610 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 03:45 , Processed in 1.108218 second(s), Total 84, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号