• 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
  • siddafuzzy
    siddafuzzy over 7 years ago in reply to Andrew Beckett

    Thanks Andrew for your descriptive reply.

    To be very specific I am using this ADC in the front end for data acquisition in Compressive sampling. For my final year thesis ( I am an undergrad student in ECE stream)  I am working in this field. Can you please try to go through this thesis which I am trying to implement? In the conclusion section, it has mentioned that the clock input should of 800MHz and the system operates at 4Ghz. The output of the integrator is fed to the ADC (10 bit).

    After generating the symbol in Cadence I just tried to check the performance of the ADC by giving those inputs of 4Ghz sine wave with 0.25 vmax and 0.25 vmin ,zero DC value. The clk values was set at 1(high) and 0(low). I had used vpulse source for clock and vsin block for the sine wave. The parameters of the ADC was left unchanged and the same code was run. 

    Do I need to change anything in the code, any parameters of the ADC?

    Yes, maybe I have not adhered to the Nyquist criteria for the ADC.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to siddafuzzy

    Given that I'm not realistically going to study a 60-odd page thesis to answer a question on the forums (you have to do something for your degree!) I merely quickly scanned it. The system is a sub-Nyquist undersampling system - but it's using a PRBS source, not a sinusoidal input. A sinusoidal signal which is coperiodic with the clock is going to be sampled with the same value at each clock edge, so you're going to get a constant output. In your case though, the first problem is that you haven't set the parameters of the ADC. If you have the  signals as you've described, then you should (on the edit properties form for the ADC) enter (first pick the CDF filter to be veriloga so that it shows the parameters), then fill in the vmax, vmin (to control the maximum range of your input signal so that the ADC uses the full range), and vth to be the mid-point of your logic signals (so 0.5V here). I also set "one" to be 1 so that the digital outputs of the ADC have the same voltage range as your clock:

    That will at least make sure that the ADC is clocked (it won't be otherwise) and that the range of the signals that the ADC is converting matches your input signal. The next problem is that your input signal is co-periodic with the clock. To illustrate this, I've plotted the clock signal you describe together with the 4GHz sine wave, and put vertical markers at the 0.5V rising crossing points of the clock:

    As you can see, the sample points are identical so the ADC would convert the 3.14mV for each sample - it will be constant. Hardly surprising given they're co-periodic. Presumably (without reading the thesis), the input signal is not periodic (if it's a PRBS), and so you'd end up getting a varying output, which presumably is useful in this circuit.

    Just to explain what happens when you apply a frequency above Nyquist, I simulated with the same settings you did but with a 4.1GHz sine input. Here's what I get:

    Note that the frequency at the bottom (this is the re-constructed digital output of the ADC) has a sine wave at 100MHz - which is the "beat" frequency of the 4.1GHz input signal and the 800MHz clock. This is the aliasing effect you'd expect - but with a 4GHz input signal, you'll end up with a 0Hz (DC) "beat" frequency. I think in the situation in the thesis, the input signal is non-periodic, so you'd still get some output though.

    The picture on Page 40 of the thesis (which you posted above) is just (as I said) showing the result of a ramp over 50ns between vmin and vmax. It's not the result of a 4GHz sine wave input.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to siddafuzzy

    Given that I'm not realistically going to study a 60-odd page thesis to answer a question on the forums (you have to do something for your degree!) I merely quickly scanned it. The system is a sub-Nyquist undersampling system - but it's using a PRBS source, not a sinusoidal input. A sinusoidal signal which is coperiodic with the clock is going to be sampled with the same value at each clock edge, so you're going to get a constant output. In your case though, the first problem is that you haven't set the parameters of the ADC. If you have the  signals as you've described, then you should (on the edit properties form for the ADC) enter (first pick the CDF filter to be veriloga so that it shows the parameters), then fill in the vmax, vmin (to control the maximum range of your input signal so that the ADC uses the full range), and vth to be the mid-point of your logic signals (so 0.5V here). I also set "one" to be 1 so that the digital outputs of the ADC have the same voltage range as your clock:

    That will at least make sure that the ADC is clocked (it won't be otherwise) and that the range of the signals that the ADC is converting matches your input signal. The next problem is that your input signal is co-periodic with the clock. To illustrate this, I've plotted the clock signal you describe together with the 4GHz sine wave, and put vertical markers at the 0.5V rising crossing points of the clock:

    As you can see, the sample points are identical so the ADC would convert the 3.14mV for each sample - it will be constant. Hardly surprising given they're co-periodic. Presumably (without reading the thesis), the input signal is not periodic (if it's a PRBS), and so you'd end up getting a varying output, which presumably is useful in this circuit.

    Just to explain what happens when you apply a frequency above Nyquist, I simulated with the same settings you did but with a 4.1GHz sine input. Here's what I get:

    Note that the frequency at the bottom (this is the re-constructed digital output of the ADC) has a sine wave at 100MHz - which is the "beat" frequency of the 4.1GHz input signal and the 800MHz clock. This is the aliasing effect you'd expect - but with a 4GHz input signal, you'll end up with a 0Hz (DC) "beat" frequency. I think in the situation in the thesis, the input signal is non-periodic, so you'd still get some output though.

    The picture on Page 40 of the thesis (which you posted above) is just (as I said) showing the result of a ramp over 50ns between vmin and vmax. It's not the result of a 4GHz sine wave input.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • siddafuzzy
    siddafuzzy over 7 years ago in reply to Andrew Beckett

    Thanks, Sir. That solved the problem.

    Can you say how did you create the 10-bit bus for the 10-bit output? I am facing some difficulty in doing that.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to siddafuzzy

    I selected the 10 signals d0 to d9 and then did (in the ViVA graph) Measurements->Analog to Digital. I specified the mid-value for the threshold, and made sure that the "Make Bus" was checked. If the bits are in the wrong order (MSB->LSB) then you can fix this by clicking on the Signal/Expr Names column heading to reverse the sort. You can control the radix and give a name for the bus - and then it adds the bus to the output.

    Hopefully that's clear enough without me posting a picture of the form.

    Regards,

    Andrew.

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel

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