Verilog-AMS学习笔记(01)

参考文献:

(1)HSPICE® User Guide:Simulation and Analysis-Chapter29 Using Verilog-A

(2)Verilog-AMS Language Reference ManualAnalog & Mixed-Signal Extensions to Verilog-HDL

PS.03.23 最近要用hspice仿真,需要4X4的扫描信号,本来看手册上说hspice只支持verilog-a,所以打算学一下来着,但是吧,万能的师姐告诉我可以改下脉冲的延时和占空比就可以得到这几个信号。我看了一天这个,半天都在找Verilog-a/AMS的资料,但是也用不到了。参考的文件里,第一个是hspice用户手册,装的软件里就有,第二本是语言参考手册,可以再谷歌学术的镜像站搜到,可以下载。这篇文章,嗯,写都写了。

案例文件分析:
Simple Resistor: resistor.sp

This example shows a very simple Verilog-A resistor model.

简单电阻模型:resistor.sp

 1 Title: Simple Verilog-A Resistor
 2 
 3 .hdl resistor.va
 4 .options post=1
 5 
 6 X1 1 0 resistor r=1       
 7 VS 1 0 1 
 8 
 9 .dc VS 0 10 1
10 
11 .end

.sp文件是先使用.hdl引入.va文件,然后设置控制语句,写网表,最后直流仿真输出。

简单电阻模型:resistor.va

// Simple resistor

`include "disciplines.vams"

module resistor(p,n);
    parameter R=1.0 from (0:inf);
    electrical p,n;
    analog I(p,n) <+ V(p,n)/R;
endmodule

首先`include声明是引入了标准定义包,根据Verilog-AMS手册定义:This annex contains the standard definition packages (disciplines.vams, constants.vams and driver_access.vams) for Verilog-AMS HDL.

module与endmodule定义一个大的模块,电阻的定义写在里面:包括参数R的定义(parameter),节点p,n的定义(electrical),还有模拟信号的输出语句analog)

Simple Voltage Source: sinev.sp

This example shows a simple voltage source and illustrates how the $bound_step() function may be used to control and maximum allowed time step in a transient simulation.

简单电压源模型:sinev.sp

Title: Simple Sinusoidal Source

.hdl sinev.va
.options post=1 notop 

X1 0 out sinev gain=3.0 freq=0.5      

.tran 0.01 10 

.end

.option notop:Suppresses topology checks to increase preprocessing speed. 提高处理速度。

这个文件用瞬态分析(.trans)得到这电压源的波形,步长0.01s,总10s。

简单电压源模型:sinev.va

// Simple sinusoidal source

`include "disciplines.vams"
`include "constants.vams"

module sinev(n1,n2);
    electrical n1,n2;
    parameter real gain = 1.0;
    parameter real freq = 1.0 from (0:inf);

    analog begin
        V(n2,n1) <+ gain * sin(2 * `M_PI * freq * $abstime);
    // Bound the maximum time step to insure the signal is
    // adequately represented:
        $bound_step(0.05/freq);
    end

endmodule

 与上一个例子相比多了一个声明constants.vams,这个是对基础物理与数学常数进行声明。

定义双精度浮点数(real)参数并赋值

直接用函数输出模拟电压信号(analog),注意节点顺序

$bound_step(0.05/freq) 约束最大时间步长,以确保信号被充分表示。

这个分类应该到此完结了。

有本书:https://www.ituring.com.cn/book/1681

关于verilog-a在ADS方面的应用:https://www.jianshu.com/p/0aab2f48b9cb

原文地址:https://www.cnblogs.com/kraken7/p/12522748.html