|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本帖最后由 eecsseudl 于 2013-4-29 10:01 编辑
《精通verilogHDL语言编程》P472页一个三级CIC抽取滤波器的例子。。。
首先,我觉得这个例子有些不妥,我改正如下,然后可以综合。。。
其次,我不明白,P474页对VerilogHDL代码的验证,课本说,在MATLAB中输入一下程序,M=2;
N=3;
R=32;
x=100.ones(1,300);
q=quantizer([8:0],'fixed');
y=cicdecimate(M,N,R,x,q);
表示该程序输入一个幅值为100的阶跃信号,经过CIC抽取器后,输出波形y(m)(图没有列出,课本上有)。
请问它是怎么把Matlab和Modelsim进行联合仿真的啊?请明白人过来指点迷津。。。谢谢
这是本人修改后的CIC程序,可以综合,因为想在仿真时看到寄存器的值,把存储器改成了寄存器。。。
module cic3_decimator(reset,clk, x_in, y_out);
parameter STATE_HOLD = 1'b0, STATE_SAMPLE = 1'b1;
input reset;
input clk;
input [7:0] x_in; //the input bit 8
output [25:0] y_out; //the output bit 26
reg state; // state register
reg derived_clk; //get a clock
reg [4:0] counter;
reg [25:0] ComReg00,ComReg01,ComReg02,ComReg10,ComReg11,ComReg12,ComReg20,ComReg21,ComReg22,ComReg3;
reg [25:0] IntReg0,IntReg1,IntReg2;
reg [7:0] x;
wire [25:0] sxtx; //sign extended input
assign y_out = ComReg3;
assign sxtx = {{18{x_in[7]}},x_in};
[email=always@(negedge]always@(negedge[/email] clk or negedge reset)
begin
if(!reset)
counter<=5'b0000_0;
else
counter <= counter + 1;
end
always @(negedge clk or negedge reset)
begin
if(!reset)
state<=STATE_HOLD;
else
case(state)
STATE_HOLD: if(counter == 31)
state <= STATE_SAMPLE;
STATE_SAMPLE:
begin
ComReg00 <= IntReg2;
state <= STATE_HOLD;
end
default:
state <= STATE_HOLD;
endcase
end
[email=always@(negedge]always@(negedge[/email] clk or negedge reset)
begin
if(!reset)
derived_clk<=0;
else
begin
if((counter>8)&&(counter<16))
derived_clk <= 1;
else
derived_clk <= 0;
end
end
always @(posedge clk or negedge reset)
begin
if(!reset)
begin
IntReg0<=0;
IntReg1<=0;
IntReg2<=0;
end
else
begin
//x <= sxtx;
IntReg0 <= IntReg0 +sxtx;
IntReg1<= IntReg1 + IntReg0;
IntReg2<= IntReg2 + IntReg1;
end
end
always @(posedge derived_clk or negedge reset)
begin
if(!reset)
begin
ComReg00<=0;
ComReg01<=0;
ComReg02<=0;
ComReg10<=0;
ComReg11<=0;
ComReg12<=0;
ComReg20<=0;
ComReg21<=0;
ComReg22<=0;
ComReg3<=0;
end
else
begin
ComReg01<= ComReg00;
ComReg02<= ComReg01;
ComReg10<= ComReg00 - ComReg02;
ComReg11<= ComReg10;
ComReg12<= ComReg11;
ComReg20<= ComReg10 - ComReg12;
ComReg21<= ComReg20;
ComReg22<= ComReg21;
ComReg3 <= ComReg20 - ComReg22;
end
end
endmodule
这个程序是能够综合。。。
|
|