* Simulation of RC delay, R=1000 Ohms, C=1pF * Note: first line **must be** a comment, woe to him/her who does otherwise * Note: SPICE is case inDEpendeNT * Note: order of spice commands is mostly irrelevant * Suffix (after scale factor) has no effect, use for readability (1p = 1pF) * Note: meg=E6, m=E-3, others are as you would expect (e.g. u=E-6) * Good short summary of spice at: * http://www.seas.upenn.edu/~jan/spice/spice.overview.html * You can find the hspice manual (2000 pages) on Unix systems by giving * the command: "which hspice" (after adding package with: pkgadd hspice) * Mouse around the directory path returned to find the doc directory which * contains the manual (typically in .ps and .pdf format). Manuals for * both hspice and awaves (waveform viewer) are available. * Manual is about 2000 pages, is primarily a ref manual, not tutorial * CoE464 Lecture Notes Page has links to HSPICE manuals * To use hspice: * Available on PCs in Urbauer 116, in consultants room, and CEC * "Simulate" runs the simulation on the specified .sp file * and produces a log file, and if successful, output files with * the simulation results which can be viewed with Avanwaves * "Avanwaves" starts a graphical waveform viewer * click on one of the lines in the results browser to select results * from that simulation, these are identified by the initial comment, * or the comment on the alter statement * Double Click on a node name to display its waveform * The plot can be printed by Tools -> print * Simulation can be re-run with new parameters, and the new values plotted * with Panels -> update, this will update the presently plotted values * * Procedure: * Draw schematic, all significant components and parameters must be included * Results are only as valid as the simulation parameters and components. * If lead inductance on an IC is important to results, but not included * in the simulation, then simulation will not show important effects * Name or number nodes, 0 is ground, can use names or numbers with hspice * Name components * Put description of each component in .sp file, make liberal use of * comments, they are tremendous help in getting the connections right. * graphical editors are available from some companies, they can * greatly reduce the incidence of errors from poor schematic->spicefile * transcription * Add commands to specify type and parameters for simulation (e.g. .tran) * Add commands to specify output graphs, files, plots, etc * Run simulation and debug. Drawing schematic from spice file is a good * way to identify errors in interconnection or naming. * ANALYZE RESULTS, THE MOST IMPORTANT, AND MOST OFTEN OVERLOOKED, STEP * * * CIRCUIT COMPONENTS AND DESCRIPTION, FIRST LETTER IDENTIFIES TYPE * V for voltage source, T for transmission line, C for capacitor, R resistor * etc * * voltage source for vdd this is a dc source not used in this RC simulation *element +node -node type value Vdd Vdd 0 DC 2.5V * pulse generator * +node -node V1 V2 TD TR TF PW PER VIN vstimulus 0 PULSE ( 0 2.5 0 0.01N 0.01N 5N 10N) * 1 RC circuit * node1 node2 value R1 vstimulus vout 1k C1 vout 0 1pf * transient simulation for 10ns with 0.001ns time step. Time step * too large may give innacurate results. HSPICE may ignore your * specified time step and do what it wishes * print-step simulation-length start time-step .tran .01ns 10ns 0ns .001ns * save the results for later plotting with awaves (or mwaves, or xelga) .option post * plot the dc characteristic in ascii in the output listing * not used here, is commented out. Note continuation line (initial +) *.plot tran V(vstimulus) *+ V(vout) * measure the parameters of interest. Measure delays at 50% points * results are placed in file_name.mtx files (for HSPICE)where x is 0, 1, 2, ... * the initial simulation is .mt0, each alter statement generates a * new file with the suffix incremented. * to get delay values measure from first rise of vstimulus to first of vout * can extract values with UNIX egrep (not sure what is best with Windows) * egrep 'DELAY|ALTER' TUTORIAL-HSPICE-RC-DEL.chi >measured_results * to get measure statement * outputs (if parameter being measured has "DELAY" in name). * Or in .ext (data) file, need to find out how to extract * initial stimulus change (L to H) measure from first time vstimulus * crosses 1.25V rising to the first time vout crosses 1.25V rising. .measure tran rise_delay trig v(vstimulus) val=1.25 rise=1 + targ v(vout) val=1.25 rise=1 .measure tran fall_delay trig v(vstimulus) val=1.25 fall=1 + targ v(vout) val=1.25 fall=1 * alter statement changes (or adds) commands and reruns simulation * simulation results are files with simulation number as suffix * text after ".alter" and on same line * is comment, very useful in parsing output files .alter Change R1 to 100 Ohms R1 vstimulus vout 100 .alter Change R1 to 10000 Ohms R1 vstimulus vout 10000 VIN vstimulus 0 PULSE ( 0 2.5 0 0.01N 0.01N 10N 20N) * the .end is required by hspice. Some spices (spice3) do not require it * if you leave it out of hspice file, hspice will report "no data" .end *========= spice example file ends on previous line *Many additional capabilities exist. Resistor values can be function of *temperature, Monte Carlo analysis can be performed, Controlled voltage and *current sources are available, subcircuits (macros), optimization, ... *Average current (or voltage) can be determined by charging capacitor with *controlled current source (controlled by parameter to be averaged), *essentially building your own little (simulated) analog computer.