Verilog-AMS数据类型---wreal

                       Verilog-AMS数据类型 --- wreal

 

       WREAL 是Verilog-AMS支持的一种新的数值模型。WREAL的特殊之处在于它使用有限的浮点数值的点来模拟一条电路工作曲线。而SPICE和Verilog-A的计算结果是一条理论上可以无限精度,包含无限点的的曲线。从某种程度上,WREAL的实现方式类似于Fast-Spice的查表点工作模式,其目的是进一步简化仿真,从而支持更大规模的模拟系统仿真。

       使用WREAL的最大好处是速度快。使用WREAL变量的模型在计算的时候无需使用SPICE迭代运算。它使用的是比较简单的,直接推导的函数来模仿模拟电路真正的工作情况。

       相比SPICE和Verilog-A的模型必须使用SPICE仿真器的迭代运算,WREAL仿真器使用离散事件触发,就像数字仿真器那样。这给WREAL的计算上带来极大的速度优势。但同时,离散的计算模式使得WREA模型在含有反馈的电路中无法给出准确的结果。在普通电路中它也需要牺牲输出的精度。所以,WREAL并不适用于需要精确度量的模拟电路的模型中。

       WREAL的一个问题是,它需要对真正的模拟电路的行为有一个非常好的预测。因为,WREAL的所有计算都是前向的,我们想要用这些前向计算来模拟SPICE仿真器迭代结算的结果,就需要对实际电路工作情况有个很好的了解。然而,模型通常在设计阶段的前期实现,而此时通常不会有很好的对真实电路的预测。如果WREAL模型无法很好的体现SPICE仿真器对真实电路的仿真结果,那模型的意义就不大了。亦或需要在设计后期随着真实电路的开发修改模型,这样就会牺牲一些研发的时间。

       有一些相关的研究正在进行中,比如利用简单的电路生成WREAL模型,这样可以作为未来新项目系统的起始WREAL模型。也有一些研究包括迭代WREAL和真实电路仿真,这样可以自动修改WREAL模型等等。但不管怎么,对于WREAL在大规模需要精度的验证中的使用,还是需要一定考虑。

 

一、端口(Port)

       Port(端口),也被称为引脚或端子,被用来连接模块到其他模块。因此,端口就是电线。简单连接的端口声明是连接声明,其中关键字wire被以下方向说明符之一替换:input、output或inout。例如:

module inv (out, in);
   output out;
   input in;

   assign out = ~in;
endmodule

module mux (out, in0, in1, sel);
   output [7:0] out;
   input [7:0] in0, in1;
   input sel;

   assign out = sel ? in1 : in0;
endmodule

 

       对于其他类型的连接,或者寄存器(寄存器只能作为输出声明),声明的前面简单地加上方向说明符:

module counter (out, clk);
   output reg [3:0] out;

   initial out = 0;

   always @(posedge ckl) out = out + 1;
endmodule

 

       默认情况下,多位端口的内容被解释为无符号数(值被解释为正二进制数)。可以明确指定数字是被解释为有符号数还是无符号数,如下所示:

input unsigned [3:0] gain;
input signed [6:0] offset;

在这种情况下,增益是无符号的,而偏移量是有符号的,这意味着它被解释为有符号的双补数。因此,如果增益= 4'bF,则其值解释为15,如果offset = 7'b7FF,则其值解释为-1。

 

       If it is necessary to apply a discipline to a port, the port declaration should be repeated with direction specifier replaced by the discipline. For example:

module buffer (out, in);
   output out;
   input in;
   electrical out, in;

   analog V(out) <+ V(in);
endmodule

 

       Verilog还支持连续信号总线和wreal(必须声明为总线而不是数组):

module mux (out, in, sel);
   output out;
   input [1:0] in;
   input sel;
   electrical out;
   electrical [1:0] in;

   analog begin
      @(sel);   
      V(out) <+ transition(sel === 0, 0, 100n)*V(in[0]);
      V(out) <+ transition(sel === 1, 0, 100n)*V(in[1]);
   end
endmodule

module mux (out, in, sel);
   output wreal out;
   input wreal [1:0] in;
   input sel;

   assign out = sel ? in[1] : in[0];
endmodule

       

       Note:The Cadence simulator does not seem to follow the standard when it comes to declaring buses of wreals. With the Cadence simulator you should declare buses of wreals as arrays rather than as buses:

module mux (out, in, sel);
   output wreal out;
   input wreal in[1:0];
   input sel;

   assign out = sel ? in[1] : in[0];
endmodule

 

 

 

你可能感兴趣的:(数模混合电路设计与仿真)