ADC VerilogA code from ModelWriter - 8 bit AC acting as 3 bi

Guest
Hi,

I am using an 8 bit VerilogA code generated from the Modelwriter in Cadence.

I am using an input pulse of 0-5V to the ADC, but when I observe the outputs, I am only getting a 3 bit conversion and not an 8 bit conversion (the output these bits 0,2,4 and 1,3 are the same while bits 5 and 6 are different).

The code is :

// FUNCTION: Analog to Digital Converter
// VERSION: $Revision: 2.13 $
// AUTHOR: Cadence Design Systems, Inc.
//
// GENERATED BY: Cadence Modelwriter 2.31
// ON: Mon Sep 30 20:19:13 EDT 2013
//
// Description: Ideal Analog to Digital Converter
// Generates an N bit ADC.
// - selectable logic output levels
// - model valid for negative values of vmin
// - adjustable conversion time, and rise/fall time
// This model is an example, provided "as is" without express or
// implied warranty and with no claim as to its suitability for
// any purpose.
//
// CCR 563324 changed voltage to electrical
//
// PARAMETERS:
// slack = The smallest time interval considered negligible for
// cross event on clock
// tconv = Delay from threshold crossing to output change
// trise = Rise time for digital output signals
// trise = Rise time for digital output signals
// vmax = ADC Full scale output voltage [V]
// vmin = ADC Zero scale output voltage [V]
// vone = The voltage of a logical 1 on digital outputs [V]
// vth = Threshold value of clock signal [V]
// vzero = The voltage of a logical 0 on digital outputs [V]
//

`include "discipline.h"
`include "constants.h"
`define NUM_ADC_BITS 8

module a2d_ideal (vin, clk, dout);
input vin, clk;
electrical vin, clk;

output [`NUM_ADC_BITS-1:0] dout;
electrical [`NUM_ADC_BITS-1:0] dout;

parameter real vmax = 5;
parameter real vmin = 0;
parameter real one = 5;
parameter real zero = 0;
parameter real vth = 2.5;
parameter real slack = 0.5p from (0:inf);
parameter real trise = 1.0p from (0:inf);
parameter real tfall = 1.0p from (0:inf);
parameter real tconv = 0.5p from [0:inf);
parameter integer traceflag = 1;

real sample, vref, lsb, voffset;
real vd[0:`NUM_ADC_BITS-1];
integer ii, binvalue;

analog begin
@(initial_step or initial_step("dc", "ac", "tran", "xf")) begin
vref = (vmax - vmin) / 2.0;
lsb = (vmax - vmin) / (1 << `NUM_ADC_BITS) ;
voffset = vmin;

if (traceflag)
$display("%M ADC range ( %g v ) / %d bits = lsb %g volts.\n",
vmax - vmin, `NUM_ADC_BITS, lsb );

generate i ( `NUM_ADC_BITS-1, 0) begin
vd = 0 ;
end
end

@(cross ( V(clk)-vth, 1, slack, clk.potential.abstol)) begin
binvalue = 0;
sample = V(vin) - voffset;
for ( ii = `NUM_ADC_BITS -1 ; ii>=0 ; ii = ii -1 ) begin
vd[ii] = 0;
if (sample > vref ) begin
vd[ii] = one;
sample = sample - vref;
binvalue = binvalue + ( 1 << ii );
end
else begin
vd[ii] = zero;
end
sample = sample * 2.0;
end
if (traceflag)
$strobe("%M at %g sec. digital out: %d vin: %g (d2a: %g)\n",
$abstime, binvalue, V(vin), (binvalue*lsb)+voffset);
end

generate i ( `NUM_ADC_BITS-1, 0) begin
V(dout) <+ transition ( vd , tconv, trise, tfall );
end
end
endmodule

`undef NUM_ADC_BITS



If I hook this up with a DAC from Modelwriter, then in the Vin vs Vout plot, instead of getting 2^8 levels, I see only 8 levels (hence the assumption that it's a three bit ADC).

It would be great if someone could help me out with this.

Thanks and regards
Deeksha
 

Welcome to EDABoard.com

Sponsor

Back
Top