

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Professor: Farmer; Class: Laboratory; Subject: Electrical & Computer Engring; University: George Washington University; Term: Unknown 1989;
Typology: Lab Reports
1 / 3
This page cannot be seen from the preview
Don't miss anything!


ECE 126 – VerilogA Tutorial: Creating Basic Analog Components: Inverter Created at GWU by Thomas Farmer Objectives:
include “constants.vams”include “disciplines.vams” module inv (vout, vin); electrical vout, vin; parameter real vlogic_high = 5; // 5V Vdd parameter real vlogic_low = 0; // 0V Vss parameter real vtrans = 2.5; // threshold voltage parameter real tdel=0.1n from [0:inf);// the bracket is not a typo parameter real trise=0.1n from (0:inf); parameter real tfall=0.1n from (0:inf); real vout_val; integer logic1; analog begin logic1 = V(vin) > vtrans; @ (cross(V(vin) – vtrans, 1)) logic1 = 1; @ (cross(V(vin) – vtrans, -1)) logic1 =0; vout_val=(!logic1)? vlogic_high: vlogic_low; V(vout) <+ transition (vout_val, tdel, trise, tfall); end endmoduleThis is a line by line breakdown of the meaning of the verilog-a code: We would like to have 2 arguments for our inverter: an input and an output. Let us call them "vin" and "vout". The arguments of the module can be indicated by placing them inside parenthesis next to "inverter2". module inv (vout, vin); We also need to define these pins as electrical ports. electrical vout, vin; We want the inverter to change as the input crosses a certain threshold. We will define this parameter as "vtrans". We also want to define delay, rise, and fall time characteristics of the inverter. These parameters will be called "tdel", "trise", and "tfall". To incorporate these factors of an inverter, we will use the transition filter for the output. The transition filter will be explained later in this tutorial. For now though, let us define these parameters using the "parameter real" statement. Also, each of these statements need to have a time period where their value holds true. In other words, following the definition, the statement "from (0:inf)" (from 0 to infinity) needs to be included in order to define the specific value from 0 to infinity seconds. parameter real vlogic_high = 5; parameter real vlogic_low=0; parameter real vtrans = 2.5; parameter real tdel=0.1n from [0:inf); parameter real trise=0.1n from (0:inf); parameter real tfall=0.1n from (0:inf); The last parameter we need to define is the output value that we want the output of the inverter to transition to using the parameters above. real vout_val; Now that we have defined everything, we need to set up the main equations (the meat of the code). This part of the code needs to lie within the analog block. Since we will need more than one line to write the main equations, a begin and end statement are needed. analog begin // Main equations here end analog begin logic1 = V(vin) > vtrans; @ (cross(V(vin) - vtrans, 1)) logic1 = 1; @ (cross(V(vin) - vtrans, -1)) logic1=0; vout_val= (!logic1)? vlogic_high: vlogic_low; end A function that we should use to define the transition of the inverter is the "cross" function. This function takes a minimum of two arguments. The first argument required is the threshold point of the input that indicates when the output should change, and the second is the edge where this threshold point is located. A '1' is indicated for a rising edge and a '-1' for a falling egde. A '0' indicates any crossing, rising or falling. In this case, we want to set up two cross statements; one for the rising of the input and one for the falling. When we detect a rising edge of the input, we want the output to fall to 0 volts. When we detect a falling edge of the input to 0 volts, we want the