VerilogA学习 - VCO demo 合集

  • Verilog-A与其他Verilog语言的不同
  • VCO的Verilog-A代码
  • Debug Tips

Verilog-A与其他Verilog语言的不同

  • Verilog-HDL :处理数字信号Digital signal
  • Verilog-A :处理模拟连续时间信号Analog continuous-time signal
  • Verilog-AMS :处理模拟离散时间信号Analog discrete-event signal +处理模拟连续时间信号Analog continuous-time signal +处理数字信号Digital signal

VCO的Verilog-A代码

代码片来源于The Designer’s Guide网站(https://designers-guide.org),主要包括了

  1. 输出为正弦波、不含jitter
  2. 输出为方波,不含jitter
  3. 输出为方波,jitter类型是 white accumulating jitter
  4. 差分正交VCO,输出为方波,jitter类型是 white accumulating jitter

jitter的加入主要用到的是$rdist_normal()函数来产生伪随机噪声,其函数说明如下:

Normal (Gaussian) Distribution
Use the $rdist_normal function to generate random real numbers (or the $dist_normal function to generate integer numbers) that are normally distributed. The $rdist_normal function is not supported in digital contexts.
$rdist_normal ( seed , mean , standard_deviation ) ;
$dist_normal ( seed , mean , standard_deviation ) ;
seed is a scalar integer variable used to initialize the sequence of generated numbers. seed must be a variable because the function updates the value of seed at each iteration. To ensure generation of a normal distribution, change the value of seed only when you initialize the sequence.
mean is an integer or real expression that specifies the value to be approached by the mean value of the generated numbers.
standard_deviation is an integer or real expression that determines the width of spread of the enerated values around mean. Using a larger standard_deviation spreads the generated values over a wider range. To generate a gaussian distribution, use a mean of 0 and a standard_deviation of 1.
For example, the following module returns a series of real numbers that together form a gaussian distribution.
module distcheck (pinout) ;
electrical pinout ;
integer seed ;
real rrandnum ;
analog begin
@ (initial_step) begin
seed = 23 ;
end
rrandnum = $rdist_normal( seed, 0, 1 ) ;
$display (“Random number is %g”, rrandnum ) ;
V(pinout) <+ rrandnum ;
end // of analog block
endmodule

关于如何对PLL中各个模块的jitter建模分析,The Designer’s Guide网站上有篇paper(点击即可直接跳转)讲得很清楚。

另外,该网站还有许多其他的VerilogA代码demo可以参考,安利一波~
具体代码如下,很好用~

// Voltage controlled oscillators
//
// Version 2, 2 April 2019
//
// Ken Kundert
//
// Downloaded from The Designer's Guide (www.designers-guide.org).
// Post any questions to www.designers-guide.org/Forum`include "disciplines.vams"
`include "constants.vams"//
// Voltage controlled oscillator
// output is sinusoidal with no jitter
//module vco0 (out, in);input in; voltage in;                           // input terminal
output out; voltage out;                        // output terminal
parameter real vmin=0;                          // input voltage that corresponds to minimum output frequency
parameter real vmax=vmin+1 from (vmin:inf);     // input voltage that corresponds to maximum output frequency
parameter real fmin=1 from (0:inf);             // minimum output frequency
parameter real fmax=2*fmin from (fmin:inf);     // maximum output frequency
parameter real va=1;                            // amplitude
real freq, phase;
integer n;analog begin// compute the freq from the input voltagefreq = (V(in) - vmin)*(fmax - fmin) / (vmax - vmin) + fmin;// bound the frequency (this is optional)if (freq > fmax) freq = fmax;if (freq < fmin) freq = fmin;// bound the time step to assure no cycles are skipped$bound_step(0.2/freq);// phase is the integral of the freq modulo 2 piphase = 2*`M_PI*idtmod(freq, 0.0, 1.0, -0.5);V(out) <+ va*sin(phase);
end
endmodule//
// Voltage controlled oscillator
// output is square wave with no jitter
//module vco1 (out, in);input in; voltage in;                           // input terminal
output out; voltage out;                        // output terminal
parameter real vmin=0;                          // input voltage that corresponds to minimum output frequency
parameter real vmax=vmin+1 from (vmin:inf);     // input voltage that corresponds to maximum output frequency
parameter real fmin=1 from (0:inf);             // minimum output frequency
parameter real fmax=2*fmin from (fmin:inf);     // maximum output frequency
parameter real vl=-1;                           // high output voltage
parameter real vh=1;                            // low output voltage
parameter real tt=0.01/fmax from (0:inf);       // output transition time
parameter real ttol=1u/fmax from (0:0.1/fmax);  // time tolerance
real freq, phase;
integer n;analog begin// compute the freq from the input voltagefreq = (V(in) - vmin)*(fmax - fmin) / (vmax - vmin) + fmin;// bound the frequency (this is optional)if (freq > fmax) freq = fmax;if (freq < fmin) freq = fmin;// bound the time step to assure no cycles are skipped$bound_step(0.6/freq);// phase is the integral of the freq modulo 2 piphase = 2*`M_PI*idtmod(freq, 0.0, 1.0, -0.5);// identify the point where switching occurs@(cross(phase + `M_PI/2, +1, ttol) or cross(phase - `M_PI/2, +1, ttol))n = (phase >= -`M_PI/2) && (phase < `M_PI/2);// generate the outputV(out) <+ transition(n ? vh : vl, 0, tt);
end
endmodule//
// Voltage controlled oscillator
// output is square wave with white accumulating jitter
//module vco2 (out, in);input in; voltage in;                           // input terminal
output out; voltage out;                        // output terminal
parameter real vmin=0;                          // input voltage that corresponds to minimum output frequency
parameter real vmax=vmin+1 from (vmin:inf);     // input voltage that corresponds to maximum output frequency
parameter real fmin=1 from (0:inf);             // minimum output frequency
parameter real fmax=2*fmin from (fmin:inf);     // maximum output frequency
parameter real vl=-1;                           // high output voltage
parameter real vh=1;                            // low output voltage
parameter real tt=0.01/fmax from (0:inf);       // output transition time
parameter real ttol=1u/fmax from (0:0.1/fmax);  // time tolerance
parameter real jitter=0 from [0:0.25/fmax);     // period jitter (produces white accumulating jitter)
real freq, phase, dT;
integer n, seed;analog begin@(initial_step) seed = -561;// compute the freq from the input voltagefreq = (V(in) - vmin)*(fmax - fmin) / (vmax - vmin) + fmin;// bound the frequency (this is optional)if (freq > fmax) freq = fmax;if (freq < fmin) freq = fmin;// add the phase noisefreq = freq/(1 + dT*freq);// bound the time step to assure no cycles are skipped$bound_step(0.6/freq);// phase is the integral of the freq modulo 2 piphase = 2*`M_PI*idtmod(freq, 0.0, 1.0, -0.5);// update jitter twice per period// `M_SQRT2=sqrt(K), K=2 jitter updates/period@(cross(phase + `M_PI/2, +1, ttol) or cross(phase - `M_PI/2, +1, ttol)) begindT = `M_SQRT2*jitter*$rdist_normal(seed,0, 1);n = (phase >= -`M_PI/2) && (phase < `M_PI/2);end// generate the outputV(out) <+ transition(n ? vh : vl, 0, tt);
end
endmodule//
// Differential quadrature voltage controlled oscillator
// output is square wave with white accumulating jitter
//module quadVco (PIout,NIout, PQout,NQout, Pin,Nin);input Pin, Nin; voltage Pin, Nin;               // input terminals
output PIout, NIout; voltage PIout, NIout;      // output terminals
output PQout, NQout; voltage PQout, NQout;      // output terminals
parameter real vmin=0;                          // input voltage that corresponds to minimum output frequency
parameter real vmax=vmin+1 from (vmin:inf);     // input voltage that corresponds to maximum output frequency
parameter real fmin=1 from (0:inf);             // minimum output frequency
parameter real fmax=2*fmin from (fmin:inf);     // maximum output frequency
parameter real vl=-1;                           // high output voltage
parameter real vh=1;                            // low output voltage
parameter real tt=0.01/fmax from (0:inf);       // output transition time
parameter real ttol=1u/fmax from (0:0.1/fmax);  // time tolerance
parameter real jitter=0 from [0:0.25/fmax);     // period jitter (produces white accumulating jitter)
real freq, phase, dT;
integer i, q, seed;analog begin@(initial_step) seed = 133;// compute the freq from the input voltagefreq = (V(Pin,Nin) - vmin) * (fmax - fmin) / (vmax - vmin) + fmin;// bound the frequency (this is optional)if (freq > fmax) freq = fmax;if (freq < fmin) freq = fmin;// add the phase noisefreq = freq/(1 + dT*freq);// bound the time step to assure no cycles are skipped$bound_step(0.6/freq);// phase is the integral of the freq modulo 2 piphase = 2*`M_PI*idtmod(freq, 0.0, 1.0, -0.5);// update jitter where phase crosses p/2// 2=sqrt(K), K=4 jitter updates per period@(cross(phase - 3*`M_PI/4, +1, ttol) or cross(phase - `M_PI/4, +1, ttol) orcross(phase + `M_PI/4, +1, ttol) or cross(phase + 3*`M_PI/4, +1, ttol)) begindT = 2*jitter*$rdist_normal(seed,0,1);i = (phase >= -3*`M_PI/4) && (phase < `M_PI/4);q = (phase >= -`M_PI/4) && (phase < 3*`M_PI/4);end// generate the I and Q outputsV(PIout) <+ transition(i ? vh : vl, 0, tt);V(NIout) <+ transition(i ? vl : vh, 0, tt);V(PQout) <+ transition(q ? vh : vl, 0, tt);V(NQout) <+ transition(q ? vl : vh, 0, tt);
end
endmodule

Debug Tips

Virtuoso在Verilog-A compile提示这块做的不是很人性化,需要你在菜单>View下面打开Parser Log File才能看到比较详细的提示。

VerilogA学习 - VCO demo 合集相关推荐

  1. [原] jQuery EasyUI 1.2.6源码、Demo合集、离线API

    下载地址: http://files.cnblogs.com/purediy/jquery-easyui-1.2.6.zip  兄弟版本: jQuery EasyUI 1.3.4 离线API.Demo ...

  2. goland 注释模板_有关新学期学习计划模板合集六篇

    有关新学期学习计划模板合集六篇 时间就如同白驹过隙般的流逝,我们又将迎来新一轮的学习,迎来新的喜悦.新的收获,现在这个时候,你会有怎样的计划呢?估计许多人是想得很多,但不会写,下面是小编为大家收集的新 ...

  3. 微信小程序免费视频+精品教程合集+demo合集(长期更新,推荐收藏)

    2019独角兽企业重金招聘Python工程师标准>>> 1:官方工具:https://mp.weixin.qq.com/debug/w ... tml?t=1476434678461 ...

  4. python源代码最多的学习网站_史上最全Python学习资料大合集分享

    Python有多火就不用说了,之前也零散地分享过一些Python学习开发资料. 本次将分享Python学习资料合集.合集哦,你品,你细品! 在分享之前,还是要啰嗦一下,不然文章字数太少,不太好看. P ...

  5. Github开源!适合初学者的机器学习和深度学习的资料合集

    最近逛 GitHub,发现了一个非常不错的 AI 资料,兼顾理论和实战,非常不错! 首先放上该资源的 GitHub 地址: https://github.com/ben1234560/AiLearni ...

  6. HTML+CSS学习demo合集

    HTML案例-招聘 <!DOCTYPE html> <html lang="en"> <head><meta charset=" ...

  7. 深度学习 CNN trick 合集

    来自 | 知乎   作者| sticky 链接 | https://zhuanlan.zhihu.com/p/137940586 编辑 | 深度学习这件小事公众号 本文仅作学术交流,如有侵权,请联系后 ...

  8. 【福利】微信小程序130个精选Demo合集

    小编最近在开发小程序,也读到了不少优秀的小程序源码,项目中有些需求可以直接从源码里粘贴复制过来,虽然这样做不利于自己独立编写代码,但比较是给公司做项目啊,秉着效率第一的原则,简直没有什么比ctrl+c ...

  9. 【福利】微信小程序精选Demo合集

    分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! 小编最近 ...

最新文章

  1. 如何使用python批量下载-使用 Python + Selenium 批量下载素材
  2. 替换字符串空格 - Java - StringBuffer
  3. MATLAB可视化实战系列(四十二)-图像特征提取-使用低秩 SVD 进行图像压缩实例
  4. 如果在系统里面无法格式化磁盘可以尝试以下方法
  5. 【笔记】opencv图像运算 图像加密
  6. python——面向对象篇之异常和反射
  7. layer和3D仿射变换
  8. 【VIJOS - P1037】搭建双塔(dp)
  9. 适用所有服务器的全站301重定向跳转教程
  10. django-cookie的认识和基本使用与值查看
  11. java中的让步_java基本教程之线程让步 java多线程教程
  12. ajax请求去获取base64_前端将图片转换为base64位,使用ajax传递到后台,但是图片经过base64转换成字符串后非常长,无法使用ajax...
  13. C#.NET验证码智能识别学习笔记---04C#.Net图片操作
  14. jquery $.fn $.fx $.extend
  15. php使用redis作为消息队列
  16. drupal7权限控制之-如何访问未发表的node
  17. system verilog语法
  18. 还在为满意的渐变色发愁吗?10+个网站帮你轻松实现
  19. php gethostbyname ipv6,支持IPV6方法
  20. 怎么把音乐中的伴奏提取出来?这几个方法值得尝试一番

热门文章

  1. 华为HCIE安全之常用的局域网攻击
  2. sed删除代码空行和删去行尾空白
  3. 程序员的数学【多元函数微分学】
  4. HTAP 应该是一种需求而不是一款产品
  5. mysql中my.cnf不生效解决
  6. 计算机组成原理---冯诺依曼体系结构及性能和功耗
  7. ESP32/ESP8266
  8. Module build failed: Error: ENOENT: no such file or directory, scandir node_modules\node-sass\vendor
  9. python 股票行情_Python结合钉钉实时自动监控股票行情,上班炒股再也不怕老板发现...
  10. Pandas返回时间戳的差,以秒为单位