Instructions
  • The Spice Code is partially filled and divided into code blocks.
  • Drag and drop these code blocks to arrange them in the correct order for the code to work.
  • Complete the partially filled code blocks
  • Once you have completed the code and rearranged the blocks as required, click on validate. This will give the report and input-output graphs upon a successful code.
  • Clicking on reset will reset the experiment and you can start your practice again.
  • You can find the MOSFET model text file ("PTM_45nm.txt") in a separate pop-up window upon clicking "View PTM_45nm.txt"
Spice Code
  • * D_FLip-Flop *

    .include


    * Parameter Declarations

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

  • * Netlist statement to define voltage source

     

  • * Defining the inverter subcircuit
    .subckt inverter in out
    MP1 out in vdd vdd pmos w={Wmin} L={Lmin}
    Mn1 out in 0 0 NMOS W={Wmin} L={Lmin}
    .ends inverter

    * Defining the pass transistor subcircuit
    .subckt pass_transistor control in out
    Xinv control not inverter
    MP1 out not in vdd pmos w={Wp} L={Lmin}
    MN1 out control in 0 nmos W={Wmin} L={Lmin}
    .ends

    * Defining the 2:1 MUX subcircuit
    .subckt mux a b s out
    Xinvs s s_ inverter
    Xpt1 s_ a out pass_transistor
    Xpt2 s b out pass_transistor
    .ends

    * Defining the D-Latch subcircuit
    .subckt d_latch in clk out
    Xinv1 out neg inverter
    Xmux neg in clk temp mux
    Xinv2 temp out inverter
    .ends

  • * Define sub-circuit

    .subckt       
          inverter
            d_latch
            d_latch
    .ends

  • *netlist statement to call the gate sub circuit *gate inputs are 'a', 'clk' 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 = 10n
    .PARAM t6 = 20n
    .PARAM t7 = 30n
    .PARAM half = 5n
    .PARAM quarter = 2.5n

    *Transient Analysis
    .tran 6p 70n

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

    V1 a 0 PWL (0 0 'half' 0 'half+trfin' 'supply' 't1' 'supply' 't1+half' 'supply' 't1+half+trfin' 0 't2' 0 't2+half' 0 't2+half+trfin' 'supply' 't3' 'supply' 't3+half' 'supply' 't3+half+trfin' 0 't4' 0 't5' 0 't5+quarter' 0 't5+quarter+trfin' 'supply' 't5+(3*quarter)' 'supply' 't5+(3*quarter)+trfin' 0 't6' 0 't7' 0 )
    V2 clk 0 PWL (0 0 't1' 0 't1+trfin' 'supply' 't2' 'supply' 't2+trfin' 0 't3' 0 't3+trfin' 'supply' 't4' 'supply' 't4+trfin' 0 't5' 0 't5+trfin' 'supply' 't6' 'supply' 't6+trfin' 0 't7' 0)
  • *Control Statements
    .control
    run

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

    *plots output
    plot v(out)

    .endc
  • *End of the code
    .end
Observations