跪求大侠跟我解决一下这VERILOG语言上的逻辑错误?
- UID
- 811003
|
跪求大侠跟我解决一下这VERILOG语言上的逻辑错误?
module fir(clk,rst_n,fir_in,fir_out);
parameter IDATA_WIDTH=12;
parameter PDATA_WIDTH=13;
parameter FIR_TAP=8;
parameter FIR_TAPHALF=4;
parameter COEFF_WIDTH=12;
parameter OUT_WIDTH=27;
parameter cof1=12'd41;
parameter cof2=12'd132;
parameter cof3=12'd341;
parameter cof4=12'd510;
input clk,rst_n;
input [IDATA_WIDTH-1:0] fir_in;
output [OUT_WIDTH-1:0] fir_out;
reg [OUT_WIDTH-1:0] fir_out;
reg [IDATA_WIDTH-1:0] fir_in_reg;
reg [FIR_TAP-1:0] shift_buf; \\原程序为reg [PDATA_WIDTH-1:0]shift_buf][FIR_TAP-1:0]; 为何无法识别?
wire [PDATA_WIDTH-1:0] add07;
wire [PDATA_WIDTH-1:0] add16;
wire [PDATA_WIDTH-1:0] add25;
wire [PDATA_WIDTH-1:0] add34;
wire [PDATA_WIDTH+COEFF_WIDTH-1:0] mul1;
wire [PDATA_WIDTH+COEFF_WIDTH-1:0] mul2;
wire [PDATA_WIDTH+COEFF_WIDTH-1:0] mul3;
wire [PDATA_WIDTH+COEFF_WIDTH-1:0] mul4;
reg [2:0] count;
integer i,j;
[email=always@(posedge]always@(posedge[/email] clk or negedge rst_n)
begin
if(!rst_n)
fir_in_reg <= 12'b0000_0000_0000;
else
if(count[2]==1'b1)
fir_in_reg <= fir_in;
end
always @ (posedge clk or negedge rst_n) \\为何此处无法通过验证?
begin
if(!rst_n)
for(i=0;i<=FIR_TAP-1;i=i+1)
shift_buf<=13'b0000_0000_00000;
else
if(count[2]==1'b1)
begin
for(j=0;j<FIR_TAP-1;j=j+1)
shift_buf[j+1]<=shift_buf[j];
shift_buf[0]<={fir_in_reg[IDATA_WIDTH-1],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];
mult mult1(.a(cof1),.b(add07),.p(mul1),.clk(clk));
mult mult2(.a(cof2),.b(add16),.p(mul2),.clk(clk));
mult mult3(.a(cof3),.b(add25),.p(mul3),.clk(clk));
mult mult4(.a(cof4),.b(add34),.p(mul4),.clk(clk));
wire [25:0] add_mul12={mul1[24],mul1}+{mul2[24],mul2};
wire [25:0] add_mul34={mul3[24],mul3}+{mul4[24],mul4};
always @ (posedge clk or negedge rst_n)
begin
if(!rst_n)
fir_out<=27'b0;
else
fir_out<={add_mul12[25],add_mul12}+{add_mul34[25],add_mul34};
end
endmodule |
|
|
|
|
|
- UID
- 811003
|
MULT用12X13通用乘法器,相信大侠们都有留根,我就不现丑了,谢谢~~~~ |
|
|
|
|
|
- UID
- 807748
|
if(!rst_n)
for(i=0;i<=FIR_TAP-1;i=i+1)
shift_buf<=13'b0000_0000_00000;
??? |
|
|
|
|
|
- UID
- 807871
|
1:\\原程序为reg [PDATA_WIDTH-1:0]shift_buf][FIR_TAP-1:0]; 为何无法识别?
这里多了一个】吧?
2:
always @ (posedge clk or negedge rst_n) \\为何此处无法通过验证?
begin
if(!rst_n)
for(i=0;i<=FIR_TAP-1;i=i+1)
shift_buf<=13'b0000_0000_00000;
由于错误1,shift_buf无法识别,所以错误2。 |
|
|
|
|
|