• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Mixed-Signal Design
  3. Verilog A ADC design

Stats

  • Locked Locked
  • Replies 9
  • Subscribers 65
  • Views 29685
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Verilog A ADC design

siddafuzzy
siddafuzzy over 7 years ago

Hello,

I have Verilog-A code for Ideal ADC of 10 bit. Here is the code.

// FUNCTION: Analog to Digital Converter
// VERSION: $Revision: 2.12 $
// AUTHOR: Cadence Design Systems, Inc.
//
// GENERATED BY: Cadence Modelwriter 2.31
// ON: Fri Mar 07 09:37:38 EST 2008
//
// 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.
//
// PARAMETERS:
// slack = The smallest time interval considered negligible for
// cross event on clock [S]
// tconv = Delay from threshold crossing to output change [S]
// trise = Rise time for digital output signals [S]
// trise = Rise time for digital output signals [S]
// 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 10
module adc_8bit (vin, clk, data);
input vin, clk;
electrical vin, clk;
output [`NUM_ADC_BITS-1:0] data;
electrical [`NUM_ADC_BITS-1:0] data;
parameter real vmax = 0.750;
parameter real vmin = 0.250;
parameter real one = 1.8;
parameter real zero =0;
parameter real vth = 0;
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[i] = 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(data[i]) <+ transition ( vd[i] , tconv, trise, tfall );
end
end
endmodule
`undef NUM_ADC_BITS

The code is compiling perfectly and the ADC symbol is getting generated. Next i am giving an clock input to the ADC ( time period 1.25ns ) and a sine way input of 4G Hz. On doing the transient analysis of the output 10 bit data I am getting all zeros ( Perfectly flat line ). Please help.

Below is the figure of the correct output.

Thanks!

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 7 years ago

    Well, the first problem is that with an input signal of 4GHz and a clock frequency of 800MHz, your signal is undersampled (i.e. above Nyquist) and so you'd expect a DC output since the input signal is an exact multiple of the clock - each sample will end up at the same phase point in the sine wave. The graph image shows what looks more like a ramp rather than a sine wave - and that ramp is effectively half of a 10MHz triangle wave.

    However, I suspect if it's producing all zeros, you've not set the threshold for the clock properly. You didn't say what signal levels you've used or what parameters you set on the ADC. In order to make it easier to see, I just did this from a spectre netlist, but here's what I used to test it (the code above is in forum42.va):

    //

    parameters FREQ=40M CYCLES=1
    Vclk (clk 0) vsource type=pulse val0=0 val1=1.8 period=1.25n rise=1p fall=1p width=1.25n/2
    Vsin (sin 0) vsource type=sine freq=FREQ ampl=0.25 dc=0.5
    Iadc (sin clk d9 d8 d7 d6 d5 d4 d3 d2 d1 d0) adc_8bit vth=0.9

    ahdl_include "forum42.va"
    tran tran stop=1/FREQ*CYCLES

    The simulation was just run with "spectre forum42.scs" and then the results looked at in "viva". I could then easily change the FREQ - here it's 40MHz, but if you change it to 4G you'll see a flat output signal. The bus at the bottom was produced with ViVA's Measurement->Analog to Digital and then the resulting bus was converted back into analog using Measurement->Analog to Digital and is overlayed over the input sine wave:

    If you had a pulse source for the clock but the input threshold (vth on the ADC) was left at default, it's probably just not switching (I get all zeros), but even if I use a 4GHz sine wave and have a sensible vth I just get a (as expected) constant output from the ADC (not all zeros, but constant nevertheless).

    If you don't understand about Nyquist, then I suggest you speak to your supervisor/tutor (I'm assuming you're a University student).

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Asad Fakhri
    Asad Fakhri over 3 years ago in reply to Andrew Beckett

    Hello Sir! 

    I need a Verilog.A code for 12 Bit DAC, Which i use on final output for 12-bit pipeline ADC. Can you help me plz!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 3 years ago in reply to Asad Fakhri

    Dear Asad,

    I might suggest you make a copy of either of the two veriloga DACs in the ahdl library  shown in Figure 1 and modify the code to a 10 bit converter. Will this satisfy your need?

    Shawn

    Figure 1

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Asad Fakhri
    Asad Fakhri over 3 years ago in reply to ShawnLogan

    Dear Shawn!

    Thanks for your combination, and I will try for it must. 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 3 years ago in reply to Asad Fakhri

    Dear Asad,

    I hope it helps to solve your request!

    Good luck Asad!

    Shawn

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • ShawnLogan
    ShawnLogan over 3 years ago in reply to Asad Fakhri

    Dear Asad,

    I hope it helps to solve your request!

    Good luck Asad!

    Shawn

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information