Home
Appendix 2 Alecsis standard libraries
Contents
1. ifndef DWORD ALIGNMENT define va arg list mode mode list sizeof __ mode 1 else DWORD_ALIGNMENT define va arg list mode sizeof __mode TYPE DOUBLE amp int list DWORD SIZE mode list sizeof mode DWORD SIZE int list DWORD SIZE mode list sizeof mode 1 172 Alecsis 2 3 User s manual endif DWORD ALIGNMENT endif VARARGS INCLUDED
2. int i for i 0 i lt nring i if i nring 1 clone inv i nodes 0 nodes i vdd vss else clone inv i nodes i 1 nodes i vdd vss RRR KK k k k k k KR k k KKK RRR KK KR KKK KK RK K KK H d KK KK RK KK KR KK KK K KKK K K K KK KK define Period 50ns root module ring oscilator ring rn vgen vdd node tmp 5 lt 0 5v 4 5v 0 5v 4 5v 0 5v vdd Vdd 0 5v rn Vdd 0 tmp action 5 timing tstop Period a_step a_stepmin Period 200 out node tmp 0 node tmp 1 node tmp 2 node tmp 3 node tmp 4 ifdef GNU action static GnuOnLine gp ring Ring oscillator process initial gp add traces tmp0o tmpl tmp2 tmp3 tmp4 0 gp time frame Period Period 100 gp value frame 0v 5v gp open channel M process post moment gp send data tmp 0 tmp 1 tmp 2 tmp 3 tmp 4 process final gp main loop Appendix 2 Alecsis standard libraries 169 endi f RRR KKK RK KR KK k k k KK K H k H KR d K lt d KR H de RRR KK H d k K KK KK K K K K K K k K K K K k K K KK KKK Usage of gnulib functions are under preprocessor option ifdef GNU so they will be activated if Alecsis is invoked using alec DGNU ring where ring ac is the name of the file listed above Firstly an instance of class GnuOnLine with name gp is declared Constructor receives two parameters both have default values First is the file name used t
3. flush results tell gnu const char set value margins public GnuOnLine const char gnu dat const char Alecsis results GnuOnLine time frame double double double 0 0 value frame double double open channel const char open channel double double double double double 0 0 const char send data double aea endi f The most appropriate way to explain these functions is to give an example Here is an ring oscillator description where CMOS inverter is used as ring element This inverter is cloned using clone command in an ring of inverters 5 inverters in our example 168 Alecsis 2 3 User s manual RRR KK k k k KR k k k k KK k H k KK K d k H KKK K H K H d H d K KK KKK K K K H K K K K k k k K K K K K K KK KK spice include omos mod include lt alec h gt include lt gnulib h gt library gnulib RRR KK RR KK k H k H k KK k H de KK H d KKK RK K H K H d H d K KR KK d HK d K K K J K K K K k K K Kk K K K KK KK define analog inverter as a subcircuit module inverter In Out vdd vss mup Out In vdd vdd model pomos 1 5u w 35u ad as 170p pd ps 50u mdwn Out In vss vss model nomos 1 5u w 10u ad as 50p pd ps 35u RRR KK k k k KR H k H k KK k H k KKK d k KK KK K H K H K H K K d K H d K K K K K k K K K K k K K K K K K K K Kk KK module ring node vdd vss node nodes inverter inv action structural int nring
4. Appendix 2 Alecsis standard libraries In this Appendix only headers of standard libraries These headers are included using included command In headers all declarations are given All definitions modules functions etc mentioned in the headers are in one file For instance header alec h corresponds to library alec ao referenced as library alec Only some of the files that are stored in directory alecsis include are given here In future issues of this Manual we will give the most important headers specific for digital simulation too Files are given in alphabetical order A2 1 alec h This is a standard library containing all main definitions and declarations needed The header is in the standard place directory alecsis include under the name alec h and the library body is in the file alec ao directory alecsis 1ib Header file heeds to be included using include command Library alec need not to be given explicitely using 1 option or Library command as it is standard library The content of the header file is following Faculty of Electronic Engineering Nis Alecsis 2 hybrid simulator library header file Library alec These declarations are not a must but compiler will complain 162 Appendix 2 Alecsis standard libraries 163 about parameters for functions listed below k ifndef ALEC INCLUDED define ALEC INCLUDED ifndef NULL define NULL 0 endif NULL
5. ar extern int strcmp const char const char extern int strlen const char extern int get_info int extern int get_info int char extern int atoi const char extern double atof const char extern int system const char extern int set_bpoint double standard Boolean choices define True 1 define False 0 alternative solution Bool type typedef enum false true Bool switch like choices define On 1 define Off 0 Integration method choices define None 0 define EulerBackward 1 define Gear2 2 Matrix renumeration options define None 0 define Fast 1 define Best 2 define Frontal 3 dcon choices define Initial 1 4 define Always 2 get info selection indx define CurrentPath 0 define ParentPath 1 define CurrentLevel 2 the most common implicit aliases implicit resistor r capacitor c inductor 1 vgen V cgen i mosfet m bjt qi jfet j diode d switch S pulse generator defined as a module module pulse nl n2 action double vlo low level double vhi high level double tr rise delay Appendix 2 Alecsis standard libraries 165 double twl double tf 0 double twh 0 double td 0 7 high level pulse width fall delay low level pulse width start delay time NSS XSS ifndef BIT INCLUDED include lt bit h gt endif BIT INCLUDED overloaded l
6. b h Functions declared here are used for on line viewing of simulation results They enable inter process communication with program gnuplot that is used for viewing of simuation results Function bodies are in library gnul ib that is to be appended using library command or 1 command option Kifndef _GNULIB INCLUDED define GNULIB INCLUDED include lt alec h gt include lt unistd h gt typedef enum Lines Points LinesPoints Impulses LineStyle struct TraceList char name int channel LineStyle lst Appendix 2 Alecsis standard libraries 167 struct TraceList next typedef enum CallGnu Close ExitStyle class gnu protected char gnufile char title FILE fp int ntraces nchannels LineStyle line style TraceList traceh tracet public gnu const char gnu dat const char Alecsis results gnu set line style LineStyle add_trace const char LineStyle Lines int 1 add traces const char add data double Bool update double close data ExitStyle const char geom report T struct ResultBuffer double time double values struct ResultBuffer next d class GnuOnLine public gnu protected double tstop update period double tprint last time double vmin vmax double cmin cmax Bool channel open first update int channel 2 ResultBuffer rbh rbt char plot_mess create plot mess initialize
7. e double double double double double double acos double extern asin double Ja extern extern extern extern extern extern extern extern extern extern extern extern extern extern extern extern extern atan double atan2 double cos double sin double tan double cosh double sinh double tanh double exp double log double 10910 double pow double double sqrt double ceil double fabs double floor double double T extern int abs int These constants may be of some help in modelling define M E 2 7182818284590452354 define M LOG2E 1 4426950408889634074 define M LOGI0E 0 43429448190325182765 define M LN2 0 69314718055994530942 define M_LN10 2 30258509299404568402 define M PI 3 14159265358979323846 define M PI 2 1 57079632679489661923 define M PI 4 0 78539816339744830962 define M 1 PI 0 31830988618379067154 define M 2 PI 0 63661977236758134308 define M 2 SORTPI 1 12837916709551257390 define M SORT2 1 41421356237309504880 define M SORTI1 2 0 70710678118654752440 Hendif A2 6 unistd h An equivalent of UNIX uni std h file There is no appropriate library Here are declarations of functions ifndef UNISTD INCLUDED define UNISTD INCLUDED unistd h for forking and pipelining used to enable simultaneous simulation and viewing of results see section on gnulib h symbolic constants and structures which are
8. ifndef EOF define EOF 1 endif EOF ifndef MAX define MAX x _y _x gt _y x endif MAX ifndef MIN define MIN x _y _x lt _y x JE endif MIN define cout stdout define cin stdin define cerr stderr typedef struct int sents char ptr char base int flag char _ file FILE standard built in function prototypes extern int printf const char extern int fprintf FILE const char extern int sprintf char const char extern int fputc char FILE extern int putc char FILE extern int putchar char extern char fgetc FILE extern char getc FILE extern char gets char extern char fgets char int FILE extern char getchar void extern int exit int 0 extern FILE fopen const char extern int fclose FILE extern int fflush FILE extern int feof FILE extern int fseek FILE int int extern int ftell FILE extern int rewind FILE extern int fwrite const void int int extern int fread void int int FILE extern void calloc int int extern void malloc int extern void free void extern double node value int int extern double drand void extern void srand int 1 const char FILE 164 Alecsis 2 3 User s manual extern double time_now void extern void warning const char int 0 extern char strcpy char const ch
9. o store waveform data in this example ring dat extension dat is added to the given name The second parameter is waveform title to appear above the graphics Class method add_traces is invoked in process initial It gives the number of waveforms to be traced and their names This method is realized as the function with variable name of arguments and the list of arguments has to be finished with 0 All waveforms are drawn on one graphics i e with one y axis Method time frame gives the last time point for x axis the first time point is assumed to be 0 and the time step for waveform updating Method value_ frame gives initial range for y axis scale min and max It is to be noted that y axis range will be automatically updated during the simulation as we usually do not know range of our simulation results in advance However x axis cannot be updated so arguments to time frame must be correct Method open_ channel opens the communication channel with gnuplot In the process post moment method send data is used It is invoked as post moment since simulation results can be sent after given time instant is solved The number of arguments has to agree with number of non zero arguments ofadd traces In the process final function main loop is invoked Without this function gnuplot will close the drawing when the simulation is finished Function main loop leave program gnuplot active and gives you normal gnuplot prompt so you can analy
10. se the waveforms create different output formats etc when the simulation is finished Class GnuOnLine can be used for all standard simulation problems However we have used Alecsis to solve partial differential eguations simulation of micromechanical sensors and have also created on line viewing for spatial 3D drawings Class GnuOnLine was used there as a base class to create derived classes for specific problems A2 5 math h We implemented all mathematics functions as instructions of virtual processor of simulation so their execution does not reguire including this header nor appending of a library body The following declarations are given so you can see what was implemented and what was not RRR KR k k RK KR He dc H k KR k H d lt KK KR RK KK d HK d K H K H d KK K H K H d HK K K 3 K HK K K K K k K K K K K K KKK KKK This file contains prototype declarations for ALECSIS2 0 built in math functions Since they really work as instructions the declarations are necessary just that compiler Alecsis 2 3 User s manual does not complain about arguments when invoked with O optimizer option The simulator works O K without this file A He H K KR H de HK H K He K He K He de KR K He KK Se Ke H K He K He d Ke d KR K Ke K K K K J K K K K K K K K K K K K K K K Kk K K K K K ifndef MATH_INCLUDED define MATH INCLUDED double double double double double double double double double double double doubl
11. st char o downshiftl define isalpha c ctypel cl U L define isupper c _ ctype cl U define islower c ctypel cle L define isdigit c ctypel cle N define isalnum c ctypel_ cle U L N define isspace c ctypel cle S 166 Alecsis 2 3 User s manual define ispunct __c ctype __cl amp P define isprint c ctype _cl l amp _P _U N _B define isgraph c ctype __c l amp _P _U _L _N define iscntrl c ctypel cl C define isascii c c lt 0177 define toupper c upshift cl define tolower c downshift cl define toascii c c endif A2 3 bit h This file contains only declarations while the definitions are in the library alec This is the elementary system of state bit containing 0 and 1 logic zero and one as well as the functions for overload of elementary operators Faculty of Electronic Engineering Nis Alecsis 2 0 hybrid simulator library header file Library alec Content predefined two valued logic system x Hifndef BIT INCLUDED define BIT INCLUDED typedef enum 0 1 void _ void bit overloaded logical operators for type bit extern bit operator bit extern bit operator amp bit bit E extern bit operator bit bit extern bit operator bit D extern bit operator amp bit bit extern bit operator bit bit Hendif A2 4 gnuli
12. t lt and gt gt C style I O FILE fp int i FILE fp double d FILE fp const char s FILE fp char c FILE operator lt lt FILE operator lt lt FILE operator lt lt FILE operator lt lt FILE operator gt gt FILE fp char amp c endif ALEC INCLUDED This library contains prototypes of all intrinsic functions of general usage The rest of C functions except the mathematical are not implemented and cannot be called Command implicit used in this file gives possibility to use Alecsis similarly as SPICE We realized trapezoidal voltage generator as a module its declaration is given above Beside standard C functions alec h contains a prototype of function warning that is specific for simulaiton and is therefore not a standard C function You can use this function to print information of place time and context the process current component etc during the execution If the argument differs from 0 the simulator stops the execution otherwise the simulation continues A2 2 ctype h This is not a real library since it has only the header file there is no file named ctype ao This library contains the definitions of macros for work with characters ifndef CTYPE INCLUDED define CTYPE INCLUDED define U 01 define L 02 define N 04 define S 010 define P 020 define C 040 define _B 0100 extern const char ctypel l extern const char _upshift extern con
13. used for support of the usr group standard Appendix 2 Alecsis standard libraries 171 ifndef NULL define NULL 0 endif He ifndef R OK Symbolic constants for the access function define R OK define W_OK define X_OK define F_OK endif OPNA Symbolic constants for the lseek function ifndef SEEK SET define SEEK SET define SEEK CUR 1 define SEEK END 2 endif include lt time h gt HHHHHH NL HHH HH TH e o extern int close int extern int dup int extern int execl const char const char extern int execv const char const char extern int pipe int extern int read int char int extern int write int const char int extern int fork extern int wait extern int select int int int int struct timeval Hendif A2 7 varargs h Two macros for work with functions and action blocks with variable number of arguments no library body are in the file varargs h Explanations of how to use them are in Chapter 4 for functions and in Chapter 5 for act ion parameters Meaning of definition of DWORD ALIGNMENT is explained there too Hifndef VARARGS INCLUDED define VARARGS INCLUDED ALECSIS2 0 Header file from standard C varargs h Use mode int for char and short types define TYPE DOUBLE 8 define DWORD SIZE 8 define va start list par list char amp _ par sizeof par
Download Pdf Manuals
Related Search
Related Contents
AKG C417 PP User Manual Samsung AQV09YWAX manual de utilizador Service Manual Cuestionario 16 Copyright © All rights reserved.
Failed to retrieve file