Switch Capacitor Circuit Simulation Using SCAP

Lab Excercise: Simulation of Switch Capacitor Circuits Using SCAP.


SCAP is a simulation tool which is used to analyze switch capacitor circuits. The switch capacitor circuits discussed in class are modelled in the form of a file usually with .swt extension.It contains the information about the circuit and the file should be written in a format readable by SCAP.Let us analyze this simple switch-capacitor circuit as shown below in the fig.

Follow the steps given below to understand the usage of SCAP


1.If this is the first time to use SCAP type add_mgc ee584 in your command prompt and then press enter this creates a new directory under mgc called ee584 and under it creates a tut directory where an example file of a low pass filter is stored,students are encouraged to analyse those files after finishing this tutorial.

2.Type sp ee584 in your command prompt and then press enter.

3.Then open your favourite text editor and type the following this is the description of the circuit shown above

timing ; 
/*This defines a clock called phi1 which is high for 1/2 master clock period*/

   clock  phi1 1  (0   1/2) ;  
   
end ;
/*this defines a subcircuit called lpf(K:phi1)*/

subckt (1  3)  lpf(K:phi1) ; 
 /*it says switch1 controlled by clock phi1 between nodes 1 and 2*/
   s1 (1  2)  phi1 ;         
   s2 (2  3)  #phi1 ;
/*it says capacitor between nodes 2 and 0 of value 1picofarad*/
   c1 (2  0)  1.0p ;         
   c2 (3  0)  11.31527p ;
end ;

/*higher Level circuit description*/
circuit ;
/*this describes that a voltage source is connected between 1 and 0*/
   vin (1   0)  ; 
/*the subcircuit is taken in between nodes 1 and 2 at higher level*/         
   x1 (1  2)  lpf(phi1) ; 
end ;

end ;


Save this file under the directory scap which is under your ee584 directory as ex1.swt.

4.Then start typing these files.These files are actually the files which are used to analyse the .swt file.these are also stored in the same directory where your .swt file is stored.

/*it calls in the file to be analysed*/
circuit ex1.swt; 
/*It defines a Master clock of 256 KHz*/
fsample 256K;
/*range where the circuit is analysed is between 10-50KHz,200 pts logrithamically distributed are taken*/    
fre 10 50K log 200;
/*input is given at node 1*/ 
in 1; 
/*output is seen at node 2*
out 2; 


Save this file as ex1.fre this file is for the frequency analysis of the file.

5.Now type this in your command prompt scap ex1.fre. This will create a file in svdx format and the file name will be ex1.fre.svdx.

6.Now type mslab in your command prompt.You will see this dialog box appear on the screen type as shown in the fig and then click on OK.MSlab is mentors Mixed signal architect.It basically does time domain simulation.Remember to have the logic name same as the waveform database directory name.


7.You will have the following menus as shown in the fig

8.Click on the menu option SVDX(with a arrow pointing to the left) and you will get the dialog box asking you to select the file to analysed and you should select ex1.fre.svdx under the scap directory.Then you will get a message saying the file was imported.
9.Click on the trace option you will get a trace window and the following menu option in the screen

10.Click on the ADD STK option in the menu and you will see the following dialog box appear on the screen and double click on ex1 and you will have the waveforms in ex1. Select node 2 using left mouse button and then click on OK.

After you Click on OK you will see the following appear on the screen

The X-axis ois a linear scale so to change the X-axis to a log scale use the right mouse button and click it on the trace window. You will get a sub menu. Then goto windows and you will see the following dialog box appear on the screen.Do the following as shown in the dialog box

You should see the Trace window showing the output response of a low pass filter.

Note: You have the option ADD OVL if you want to compare two wave forms. You can use the option and select the two waveforms in the dialog box and then click on OK to see the waveforms appear in the screen in two different colours. The waveforms you generate will be saved in the ex1 directory under the scap directory.

11.Now you are done with the frequency analysis lets do the timing analysis. Type the following files and save it under the scap directory.

/*generates a step input of 1V*/
create var  step 1; 
/*generates a sine wave input with freq = 800Hz*/
create expr sine sin(twopi * 800 * time ); 


save it with the file name ex1.src


/*uses the file to be analysed*/
circuit ex1.swt; 
/*calls the source file to take the inputs */
source  ex1.src;
/*master clock with frequency 256 Khz*/ 
fsample 256K;    
/*analysed for a time = 100 time cycles of the master clk period*/
tim 100;
/*calls the variable step from the source file*/         
in 1 step;      
out 2;


save it with the file name ex1.step.tim

circuit ex1.swt;
source  ex1.src;
fsample 256K;
tim 400;       /*400 time cycles of the master clock*/
in 1 sine;
out 2;


save it with the file name ex1.sine.tim


ALL these files should be saved under the scap directory.
This is the source file which has the info about the various types of input which can be given for timing analysis.
Repeat the the same procedure mentioned above for the files ex1.1.tim and ex1.2.tim
Play around with other menus in the mslab under the trace window option also.
. NOTE:once you repeat the procedure for one .tim file you will see the waveform for that particular .tim file and next time you analyse another .tim file you will not be able to see the waveform of the previous .tim file the waveforms are seen only once.So every time you take and analyse a .tim.svdx file that particular inputs response will be seen.The waveform name will be the same.