hmsheng
Full Member level 4
pi veriloga
I build a Verilog-A VCO model. The model can work well in Cadence spectre simulation. But its frequency can't be tuned in nanosim simulation.
Can you help me?
Following is the VCO Verilog_A model:
`include "discipline.h"
`include "constants.h"
`define PI 3.14159265358979323846264338327950288419716939937511
module VCO(vin, vout);
input vin;
output vout;
electrical vin, vout;
parameter real amp = 1;
parameter real center_freq = 1K;
parameter real vco_gain = 1K;
real wc; // center freq in rad/s
real phase_lin; // wc*time component of phase
real phase_nonlin; // the idt(k*f(t)) of phase
integer num_cycles; // number of cycles in linear phase component
real inst_freq; // instanteous frequency
analog begin
@ ( initial_step ) begin
wc = 2 * `PI * center_freq;
end
phase_lin = wc * $abstime;
num_cycles = phase_lin / (2*`PI);
phase_lin = phase_lin - num_cycles * 2 * `PI;
phase_nonlin = 2 * `PI * vco_gain * idt(V(vin),0);
V(vout) <+ amp * sin (phase_lin + phase_nonlin);
inst_freq = center_freq + vco_gain * V(vin);
bound_step (0.04 / inst_freq);
end
endmodule
I build a Verilog-A VCO model. The model can work well in Cadence spectre simulation. But its frequency can't be tuned in nanosim simulation.
Can you help me?
Following is the VCO Verilog_A model:
`include "discipline.h"
`include "constants.h"
`define PI 3.14159265358979323846264338327950288419716939937511
module VCO(vin, vout);
input vin;
output vout;
electrical vin, vout;
parameter real amp = 1;
parameter real center_freq = 1K;
parameter real vco_gain = 1K;
real wc; // center freq in rad/s
real phase_lin; // wc*time component of phase
real phase_nonlin; // the idt(k*f(t)) of phase
integer num_cycles; // number of cycles in linear phase component
real inst_freq; // instanteous frequency
analog begin
@ ( initial_step ) begin
wc = 2 * `PI * center_freq;
end
phase_lin = wc * $abstime;
num_cycles = phase_lin / (2*`PI);
phase_lin = phase_lin - num_cycles * 2 * `PI;
phase_nonlin = 2 * `PI * vco_gain * idt(V(vin),0);
V(vout) <+ amp * sin (phase_lin + phase_nonlin);
inst_freq = center_freq + vco_gain * V(vin);
bound_step (0.04 / inst_freq);
end
endmodule