Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
VAMS-LRM-2-3-1.pdf
Скачиваний:
43
Добавлен:
05.06.2015
Размер:
3.73 Mб
Скачать

Accellera

 

Version 2.3.1, June 1, 2009

VERILOG-AMS

capacitor #(.c(Csec)) C(n[i+1], gnd);

 

end

 

analog begin

 

V(n1, n[0]) <+ 0.0;

 

V(n2, n[N]) <+ 0.0;

 

end

 

endmodule

 

This module also implements an interconnect line constructed from RC sections, but the sections are now symmetric. Additionally, the capacitor is now implemented by an analog block.

module rcline2 (n1, n2); inout n1, n2; electrical [0:N] n; electrical n1, n2, gnd; ground gnd;

parameter integer N = 10 from (0:inf); parameter Cap = 1p, Res = 1k;

localparam Csec = Cap/N, Rsec = Res/(2*N);

genvar i;

for (i=0; i <N; i=i+1) begin : section electrical n_int;

resistor #(.r(Rsec)) R1(n[i], n_int); resistor #(.r(Rsec)) R2(n_int, n[i+1]); analog

I(n_int, gnd) <+ Csec * ddt(V(n_int));

end

analog begin

V(n1, n[0]) <+ 0.0; V(n2, n[N]) <+ 0.0;

end endmodule

In the above example the block inside the generate loop is a named block. For each block instance created by the generate loop, the generate block identifier for the loop is indexed by adding the "[genvar value]" to the end of the generate block identifier. These names can be used in hierarchical path names (see 6.7).

6.6.2 Conditional generate constructs

The conditional generate constructs, if-generate and case-generate, select at most one generate block from a set of alternative generate blocks based on constant expressions evaluated during elaboration. The selected generate block, if any, is instantiated into the model.

Generate blocks in conditional generate constructs can be named or unnamed, and they may consist of only one item, which need not be surrounded by begin-end keywords. Even if the begin-end keywords are absent, it is still a generate block, which, like all generate blocks, comprises a separate scope and a new level of hierarchy when it is instantiated.

Because at most one of the alternative generate blocks is instantiated, it is permissible for there to be more than one block with the same name within a single conditional generate construct. It is not permissible for any of the named generate blocks to have the same name as generate blocks in any other conditional or loop generate construct in the same scope, even if the blocks with the same name are not selected for instantia-

Copyright © 2009 Accellera Organization, Inc.

140

 

Accellera

Analog and Mixed-signal Extensions to Verilog HDL

Version 2.3.1, June 1, 2009

tion. It is not permissible for any of the named generate blocks to have the same name as any other declaration in the same scope, even if that block is not selected for instantiation.

If the generate block selected for instantiation is named, then this name declares a generate block instance and is the name for the scope it creates. Normal rules for hierarchical naming apply. If the generate block selected for instantiation is not named, it still creates a scope; but the declarations within it cannot be referenced using hierarchical names other than from within the hierarchy instantiated by the generate block itself.

If a generate block in a conditional generate construct consists of only one item that is itself a conditional generate construct and if that item is not surrounded by begin/end keywords, then this generate block is not treated as a separate scope. The generate construct within this block is said to be directly nested. The generate blocks of the directly nested construct are treated as if they belong to the outer construct. Therefore, they can have the same name as the generate blocks of the outer construct, and they cannot have the same name as any declaration in the scope enclosing the outer construct (including other generate blocks in other generate constructs in that scope). This allows complex conditional generate schemes to be expressed without creating unnecessary levels of generate block hierarchy.

The most common use of this would be to create an if-else-if generate scheme with any number of else-if clauses, all of which can have generate blocks with the same name because only one will be selected for instantiation. It is permissible to combine if-generate and case-generate constructs in the same complex generate scheme. Direct nesting applies only to conditional generate constructs nested in conditional generate constructs. It does not apply in any way to loop generate constructs.

The following module implements a non-linear resistor that internally uses the SPICE resistor primitive if the non-linear coefficients are not given or a short if the resistance value is 0.

module nlres (inout electrical a, inout electrical b); parameter real res = 1k from (0:inf);

parameter real coeff1 = 0.0;

generate

if ($param_given(coeff1) && coeff1 != 0.0) analog

V(a, b) <+ res * (1.0 + coeff1 * I(a, b)) * I(a, b); else if (res == 0.0)

analog

V(a, b) <+ 0.0;

else

resistor #(.r(res)) R1(a, b); endgenerate

endmodule

For compact modelling of semiconductor devices where the delay time of signals through the device needs to be taken into account (non-quasi-static models) introduction of extra nodes and branches can be controlled through a module parameter.

module nmosfet (d, g, s, b); inout electrical d, g, s, b;

parameter integer nqsMod = 0 from [0:1];

// "generate" and "endgenerate" keywords are not required. if (nqsMod) begin : nqs

electrical GP; electrical BP; electrical BI; electrical BS;

141

Copyright © 2009 Accellera Organization, Inc. All rights reserved.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]