Instructions
  • The Spice Code is divided into colored code blocks. Each color represents a key part of the NAND/NOR gate simulation.
  • Blue block: MOSFET model file (PTM_45nm.txt) and parameter declarations.
  • Green block: Define the voltage source (vdd as positive, gnd or 0 as negative).
  • Yellow block: NAND/NOR subcircuit definition, including input/output names and PMOS/NMOS connections.
  • Red block: Instantiate the NAND/NOR subcircuit in your main code.
  • Teal block: Declare the input waveform.
  • Purple block: Add control statements to run and plot the simulation.
  • Gray block: End your SPICE code.
Steps to Build Your Code:
  1. Arrange the colored blocks in the order listed above for a valid simulation.
  2. Fill in the blanks in each block with the required values and names.
  3. Click Validate to check your code. If correct, you will see a report and input/output graphs.
  4. If your arrangement is valid but differs from the standard diagram, you will see a message:
    "Your arrangement is correct, even though it differs from the diagram. Multiple transistor arrangements are possible for this logic gate."
  5. Click Reset to start over. Click View PTM_45nm.txt to see the MOSFET model file.
Spice Code
  • .include


    * Parameter Declarations

    .PARAM supply=1.1
    .PARAM Lmin=45nm
    .PARAM Wmin=45nm
    .PARAM Wp={2*Wmin}
    .global vdd gnd

  • * Netlist statement to define voltage source

     

  • * Define sub-circuit

    .subckt       
              nmos w={Wmin} L={Lmin}
              nmos w={Wmin} L={Lmin}

              pmos w={Wmin} L={Lmin}
              pmos w={Wmin} L={Lmin}
    .ends

  • *netlist statement to call the gate sub circuit *gate inputs are 'a', 'b' and the gate output is 'out'

           

  • *Declaring Input Waveform
    .PARAM trfin=10p
    .PARAM t1 = 10n
    .PARAM t2 = 20n
    .PARAM t3 = 30n
    .PARAM t4 = 40n
    .PARAM t5 = 1*8000p+1200p
    .PARAM t6 = 1*8000p+1210p
    .PARAM t7 = 1*8000p+5200p
    .PARAM t8 = 1*8000p+5210p

    *Transient Analysis
    .tran 6p 50n

    *Use below line for input (declaring input pwl Waveform)
    *'V1' is the PWL source name, 'a', 'b' are the input names

    V1 a 0 PWL (0 0 't1' 0 't2' 0 't2+trfin' 'supply' 't3' 'supply' 't4' 'supply')
    V2 b 0 PWL (0 0 't1' 0 't1+trfin' 'supply' 't2' 'supply' 't3' 'supply' 't3+trfin' 0 't4' 0)
  • *Control Statements
    .control
    run

    *plots inputs
    plot v(a) v(b)

    *plots output
    plot v(out)

    .endc
  • *End of the code
    .end
Observations