hawerchuk
New Member
Offline
Posts: 1
|
I'm running an FIR filter (code below) in Spectre RF. When I use the filter on its own, everything runs fine. But when I cascade two copies of the filter in a row, I get hidden state errors.
Can anyone shed any light on this?
thanks
gd
// VerilogA for rx_fir4 `include "constants.h" `include "discipline.h"
module rx_fir4(i_in_node, i_out_node, q_in_node, q_out_node); input i_in_node,q_in_node; output i_out_node,q_out_node; voltage i_in_node,q_in_node,i_out_node,q_out_node; integer sample; integer count; real i_out,q_out; `define PI 3.1415926535897932384626433
//set symbol rate to 1MHz `define BAUD_RATE 1000000
`define TAP_LENGTH 80 `define OVERSAMPLE 16.0 `define IMPULSE_PULSE 2
parameter integer seed = 21; parameter real amplitude= 1 from [0:inf); parameter real rise_fall = 1 from (0:1];
real period; real out_val; real dummy;
real i_filter_states[0:`TAP_LENGTH]; real q_filter_states[0:`TAP_LENGTH]; real i_in; real q_in; real taps[1:`TAP_LENGTH]; real tapsi[1:`TAP_LENGTH]; real tapsq[1:`TAP_LENGTH]; integer use_seed; integer k; real angle; real phase_shift; real pio4; real pi3o4; real pi2; real tt;
analog begin @(initial_step("static") or initial_step("pss") or initial_step("pdisto")) begin
//initialize dummy dummy = -2;
pio4 = `PI/4; pi3o4 = 3*pio4; pi2 = `PI*2; sample = 0; period = 1.0/(`OVERSAMPLE*`BAUD_RATE); tt = rise_fall*period; use_seed = seed; for (k=0; k<=`TAP_LENGTH;k=k+1) begin i_filter_states[k] =0; q_filter_states[k] =0; end
//***********Set the tap coefficients. tapsi[1]=1; // I'm leaving out the rest of the taps to stay within my character limits
count = `OVERSAMPLE; angle = 0.0; end
@(timer(period/10, period)) begin
//*****generate the digital data**** if (count >= `OVERSAMPLE) begin
//**flag a sampling event and reset the counter** sample = 1; count = 0; end
i_in = V(i_in_node); q_in = V(q_in_node);
for (k=`TAP_LENGTH; k>=`IMPULSE_PULSE; k=k-1) begin i_filter_states[k] = i_filter_states[k-1]; q_filter_states[k] = q_filter_states[k-1]; end
if (sample== 1) begin sample = 0; end
i_filter_states[1] = i_in; q_filter_states[1] = q_in;
//***sum the filter taps i_out = 0; q_out = 0; for (k=1; k<=`TAP_LENGTH; k=k+1) begin i_out = i_out+tapsi[k]*i_filter_states[k]; q_out = q_out+tapsq[k]*q_filter_states[k]; end
//****increment the counter*** count = count + 1; end V(i_out_node) <+ transition(i_out,0,tt,tt); V(q_out_node) <+ transition(q_out,0,tt,tt); end endmodule
|