Subject: LRM Issue, bad example in need of lots of corrections
From: Jonathan Sanders (jons@cadence.com)
Date: Tue May 14 2002 - 22:24:25 PDT
Subject: Re: AMS Driver Update functions?
Ron,
Unfortunately most of the issues you hit in example 8.10.6 are known and being cleaned up by the committee but we don't have a new rev yet.
You are correct on the following (plus a few others):
ground not declared, neither is rail (needs to be: electrical rail, a, gnd; several other cases in LRM
)
1`b instead of 1'b (typo)
branch statements are backwards (should be branch (nodeA,nodeB) branchname; only misuse in LRM)
analog port defined as inout (should be output)
i++ (should be i=i+1 although this will be supported in the future, only misuse in LRM)
variable i is not defined (should be integer i, num_ones, num_zeros; )
$driver_state(sig,index) is missing sig (should be $driver_state(d,i), only misuse in LRM )
endconnectmodule is wrong (should be endmodule, only misuse in LRM)
net_resolution is not supported by Cadence (we need to use assign d=out; instead, LRM will be changing this also to remove net_resolution)
need to initialize num_ones and num_zeros (could go away as we extend support for X/Z, add: initial begin num_ones=0; num_zeros=0; end)
Anyway I made all of the above changes (and a few cosmetic ones) and have validated that the module works although it may not be optimized. I ran it on a simple ring oscillator and it seemed to oscillate.
Jon
Here is the modified module:
`include "disciplines.vams"
`timescale 1ns/1ps
connectmodule c2e(d,a);
input d;
output a;
logic d;
electrical rail, a, gnd;
reg out;
ground gnd;
branch (rail,a) pull_up;
branch (a,gnd) pull_down;
branch (rail,gnd) power;
parameter real impedence0 = 120.0;
parameter real impedence1 = 100.0;
parameter real impedenceOff = 1e6;
parameter real vt_hi = 3.5;
parameter real vt_lo = 1.5;
parameter real supply = 5.0;
integer i, num_ones, num_zeros;
//net_resolution(d, out);
assign d=out; // Cadence method since we don't support net_resolution
initial begin
num_ones=0;
num_zeros=0;
end
always @(driver_update(d)) begin
num_ones = 0;
num_zeros = 0;
for ( i = 0; i < $driver_count(d); i=i+1 )
if ( $driver_state(d,i) == 1 )
num_ones = num_ones + 1;
else
num_zeros = num_zeros + 1;
end
always @(cross(V(a) - vt_hi, -1) or cross(V(a) - vt_lo, +1))
out = 1'bx;
always @(cross(V(a) - vt_hi, +1))
out = 1'b1;
always @(cross(V(a) - vt_lo, -1))
out = 1'b0;
analog begin
// Approximately one impedence1 resistor to rail per high output
// connected to the digital net
V(pull_up) <+ 1/((1/impedence1)*num_ones+(1/impedenceOff)) * I(pull_up);
// Approximately one impedence0 resistor to ground per low output
// connected to the digital net
V(pull_down) <+ 1/((1/impedence0)*num_zeros+(1/impedenceOff)) * I(pull_down);
V(power) <+ supply;
end
endmodule
This archive was generated by hypermail 2b28 : Tue May 14 2002 - 23:32:29 PDT