Lab10 Veriloga Adc Tutorial
Lab10 Veriloga Adc Tutorial
Objectives:
• To create a sample 8-bit ADC in VerilogA for use with 8-bit CPU Project
• Familiarize student with Cadence VerilogA code generator known as the ModelWriter
• Simulate an 8-bit ADC using Spectre
Assumptions:
• Student has working knowledge of A/D converter
• Student understand verilog-A
Note:
• This tutorial was created using Cadence 5.41, but it has been tested and works properly
in Cadence 6.1. There are some basic menu differences, but if a student is familiar with
Cadence 6.1, this should be no problem for the student.
`include "discipline.h"
`include "constants.h"
`define NUM_ADC_BITS 8
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 );
`undef NUM_ADC_BITS
6. After the above code has been entered, save and close the editor window. Cadence will
syntax check the verilogA code that has been entered. Fix any errors that may have
occurred due to syntax. Note: Any time a change is made, cadence will automatically syntax
check the code.
7. You will be prompted to create a symbol for this device, answer yes and save the symbol.
SECTION II: The Cadence VerilogA code generator: ModelWriter
The code for the 8-bit ADC above was generated automatically by using the Cadence Model
Writer. This is a feature that can normally be accessed by creating a new cell using the
“ModelWriter” Tool as show here.
At the time of this tutorials authoring, GWU had the model writer installed (it is part of the base
cadence package) but did not have a license to support this feature. However, the student is
encouraged to look at the Model Writer Guide, under the ECE 128 references page.
The Model Writer can generate veriloga code for many common analog parts, and it is a good
idea for students to familiarize themselves with the parts is can create. The model writer’s main
menu show the choices:
For this example, an ADC was chosen from the above list, and all the user is required to do is set
the # of bits to use and various other threshold parameters, then cadence generates the verilogA
code automatically to fulfill the user’s requirements. This very powerful feature will be activated in
the near future at GWU.
SECTION III: Creating the ADC Test Bench
Creating the test bench shown below has 2 or 3 tricky steps, please read through this section
before simply implementing the schematic.
Bring up the “add pin” dialog box: type in the name: data<7:0>
Click on the schematic window to place the first pin, then click again to place the last 7 pins.
Be sure to give yourself a lot of room from the ADC to route wires
4. Creating the BUS wires
a. From the menu, choose: Add->Wire (WIDE)
b. From the output pin of the ADC, draw a wire extending to the right
BUT, do not connect it to output pin 7, make this wire VERY long (see step 6d as to
why this is necessary)
c. Now use the NARROW wire to connect from the bus to output pin data<7>
d. Repeat this NARROW wire procedure for each output pin, but make sure to connect
each narrow wire from the output pin, directly to the bus. DO NOT connect any
narrow wire to another narrow wire
5. Be sure to leave a lot of space on the bus for wire naming later on.
6. Naming the Bus and the wires
Note: This is a crucial step that must be done to properly separate out the bus
a. From the menu choose: Add-Wire Name, fill in the dialog box as follows:
b. Click first on wire #7, then click each NARROW wire until the bus tapped wires are all
named:
c. Lastly, name the bus itself. Choose Add->Wire Name from the menu:
d. Place the label on the WIDE bus wire (do NOT accidentally name the narrow wire, if
you do not have space to access your WIDE bus wire with the label, delete the bus
and start from step 5):
Be sure to
label clk
and vin
wires as
well
7. Save the schematic ONLY after the wiring and labeling are complete.
8. You MUST check the CIW window to ensure there are NO errors. If there are any errors
repeat the steps above as it is very difficult to debug. Simulation will not work with errors.
SECTION IV: Simulating the ADC
5. With using a ramp, the output of the ADC can be checked to see if it corresponds to the
correct input voltage. Pick a few points on vin and verify that the 8-bit ADC is accurate
(determine the 8-bit binary value at this point by viewing the data pins to see if they are high
or low). Verify that the output is changing on the rising edge of the clock. To change the
ADC so the output changes on the falling edge, go to the Library Manager window and select
the veriloga cell view of the adc_8bit. Find the following line of code:
6. Change the '1' to a '-1'. This argument determines whether or not the ADC will change on the
rising or falling edge of the clock. Save your file and then rerun the simulation from the
Cadence Analog Design Environment window. In the Waveform Window, verify that the
output is different from the previous simulation, with the output changing on the falling edge of
the clock. Also, verify that the digital output is consistent with the analog input.
7. HW:
a. For both cases, hand in a picture of your simulation write down the “8-bit binary”
equivalent code at 1V, 2.5V, 3V, 4.5, & 5V.
b. Also, find the fastest clock speed that this ADC can be run at (shrinking the clock
pulse, see if proper data output is still on the data line)
c. Could the speed of your ADC influence your CPU clock speed?
You will notice that the expansion to output pins is not necessary. But this painstaking procedure
was put into the lab to prepare the student for wiring the ADC up to the CPU final project. In
some cases it will be necessary to separate the data bus wires.
SECTION IV: References
This tutorial was adapted from the “Analog Tutorial 5: Verilog-A” from the electrical engineering
department of Brigham Young University. Originally found at the following URL:
http://www.ee.byu.edu/help/computing/software/cadence-help/tutA5.html