Пример #1
0
int Add_i4Dlin( int owner, int components) {
	
    circuit c = NewCircuit();
	c.nI = 4;
    c.nO = components;

    c.updatef = i4Dlin;
    
    c.iplen = 9;
    c.iparams = (int*)calloc(c.iplen,sizeof(int));
    c.iparams[0] = components;



    c.plen = 5;
    c.params = (double*)calloc(c.plen,sizeof(double));
    


    c.vplen = components;
    c.vpparams = (double**)malloc(c.vplen * sizeof(double*));
    for (int i = 0; i < components; i++) {
	c.vpparams[i] = (double*)calloc(1, sizeof(double)); // this is the forcefield
    }


    int index = AddToCircuits(c,owner);
    
    printf("cCore: Added 4D interpolator.\n");
    return index;
	
}
Пример #2
0
/******************************************************
 * inputs[0] = coordinate x
 * outputs[0-dim-1] = interpolated vector field
 * params[0] = dx grid step
 * params[1] = size of box
 * iparams[0] = number of points
 * iparams[1] = number of components
 * iparams[2] = periodic 0|1
 * ***************************************************/
int Add_i1Dlin( int owner, int components, double dx, int pbc) {
	
    circuit c = NewCircuit();

    c.nI = 1;
    c.nO = components;
	
	c.plen = 2;
	c.params = (double*)calloc(c.plen,sizeof(double));
	c.params[0] = dx;
	c.params[1] = dx*2;
	
	c.iplen = 2;
	c.iparams = (int*)calloc(c.iplen,sizeof(int));
	c.iparams[0] = 2;
	c.iparams[1] = components;
	c.iparams[2] = pbc;
	
	c.vplen = components;
	c.vpparams = (void**)malloc(c.vplen*sizeof(double*));
	for (int i = 0; i < c.vplen; i++) {
		c.vpparams[i] = (double*)calloc(2,sizeof(double)); //this contains the data - just 2 points
	}
	
    c.updatef = i1Dlin_periodic;
    
    int index = AddToCircuits(c,owner);
    
    printf("cCore: Added 1D interpolator.\n");
    return index;
	
}
Пример #3
0
/******************************************************
 * inputs[0-2] 		= coordinates x y z
 * outputs[0-comp-1] 	= interpolated vector field
 * params[0-2] 	= steps dx dy dz
 * params[3-5] 	= sizes of pbc box
 * iparams[0] 	= components
 * iparams[1-3]	= number of points nx ny nz
 * iparams[4] 	= size of field (1 component) nx*ny*nz
 * iparams[5] 	= size of zy plane (1 component) ny*nz
 * iparams[6-8]	= periodic 0|1 along each direction
 * ***************************************************/
int Add_i3Dlin( int owner, int components) {

    //printf("%i \n",xsize);

    circuit c = NewCircuit();
    c.nI = 3;
    c.nO = components;

    c.iplen = 9;
    c.iparams = (int*)calloc(c.iplen,sizeof(int));
    c.iparams[0] = components;


    c.plen = 6;
    c.params = (double*)calloc(c.plen,sizeof(double));
    
    c.vplen = components;
    c.vpparams = (double**)malloc(c.vplen * sizeof(double*));
    for (int i = 0; i < components; i++) {
	c.vpparams[i] = (double*)calloc(1, sizeof(double)); // this is the forcefield
    }
 
    c.updatef = i3Dlin; //this is the default scanner update function
    int index = AddToCircuits(c,owner);
    printf("cCore: i3Dlin initialised\n");
    return index;

}
Пример #4
0
int Add_Comparison(int owner, char* type, int ni) {
    
    circuit c = NewCircuit();

    c.nI = ni;
    c.nO = 1;

    //c.plen = 1;
    //c.params = (double*)calloc(c.plen,sizeof(double));

    int template = GetCircuitIndex(type);
Пример #5
0
CIRCUITPTR makeStubCircuit(STRING circuitname, LIBRARYPTR lib)
{
    FUNCTIONPTR fun;
    CIRCUITPTR  cir;
    NewFunction(fun);
    NewCircuit(cir);
    fun->circuit = cir;
    cir->function = fun;
    fun->name = cs(circuitname);
    cir->name = cs(circuitname);
    fun->library = lib;
    fun->next = lib->function;
    lib->function = fun;
    cir->flag.l |= EXTERNAL_STUB;
    return cir;
}
Пример #6
0
CIRCUITPTR makeLocalCopy (CIRCUITPTR remote, char *outcircuit)
{
   CIRCUITPTR cirlocal;
   FUNCTIONPTR funclocal;
   LIBRARYPTR liblocal=NIL;
   char buf1[9];
   char buf2[9];
   STRING myCirName;
   STRING myFunName;
   
   myCirName=buf1;
   myFunName=buf2;

   myCirName="Flt";
   myFunName="Flt";

// make local library
   if ( liblocal == NIL )
      liblocal=findLocalLib();

   if ( outcircuit )
   {
      myCirName=outcircuit;
      myFunName=outcircuit;
   }
   else
   {
      char tmp[100];
      strcpy(tmp,remote->name);
      myCirName=cs(concat(tmp, myCirName));
      strcpy(tmp,remote->function->name);
      myFunName=cs(concat(tmp, myFunName));
   }
/*
 * find out whether this circuit already exists
 */
   if( sdfexistscir(myCirName, myFunName, liblocal->name) )
   { 
      /*  already in database : read it */
      sdfreadcir((int) SDFCIRBODY, myCirName, myFunName, 
		 liblocal->name);
      cirlocal=thiscir;
      funclocal=cirlocal->function;
   }
   else
   {    
      // create a new function   
      NewFunction(funclocal);
      funclocal->name=cs(myFunName);
      // create a new circuit
      NewCircuit(cirlocal);
      cirlocal->name=cs(myCirName);
   }
   
// initialize the function  
   funclocal->library=liblocal;
// link the local function list
   funclocal->next=liblocal->function;
   liblocal->function=funclocal;

// link the local circuit list
   cirlocal->function=funclocal;
   cirlocal->next=funclocal->circuit;
   funclocal->circuit=cirlocal;
// copy the remote circuit
   cirlocal->cirport=remote->cirport;
   cirlocal->cirinst=remote->cirinst;
   cirlocal->netlist=remote->netlist;
   cirlocal=setCurcirc(cirlocal);

   return cirlocal;
}
Пример #7
0
/* * * * * * * * * 
 *
 * This routine attaches the cell denoted by 'map' into the 
 * library structure.
 * in all cases, the pointers in the map structure
 * will be set the the corresponding lbrary, function, circuit and layout.
 * If the cell (or its library, function, etc.) does not exists it will be created.
 */
void attach_map_to_lib(MAPTABLEPTR  map )

{
LIBRARYPTR
   lib;
register FUNCTIONPTR
   func;
register CIRCUITPTR
   cir;
register LAYOUTPTR
   lay;
/* long
   time(); */

if(Seadif_open == FALSE)
   {
   attach_fish_map_to_lib(map);
   return;
   }

   

/*
 * look for the library
 */
if(existslib(map->library) == FALSE || sdfreadlib(SDFLIBSTAT, map->library) == FALSE)
   { /* does not exist: make it and write.... */ 
   NewLibrary(lib);
   lib->name = canonicstring(map->library);
   lib->technology = Technologystring;
      
   NewStatus(lib->status);
   lib->status->timestamp = time(0);
   lib->status->program = canonicstring(DEFAULT_PROGRAM);
   lib->status->author = Authorstring;
   map->librarystruct = lib;
   
   if(No_sdf_write == FALSE && sdfwritelib(SDFLIBSTAT, lib) == FALSE)
      error(WARNING,"cannot write lib into seadif");
   }
else
   map->librarystruct = thislib;

/*
 * look for this function
 */
if(existsfun(map->function, map->library) == FALSE || 
   sdfreadfun(SDFFUNSTAT, map->function, map->library) == FALSE)
   { /* not found */
   NewFunction(func);
   func->name = canonicstring(map->function);
   func->type = canonicstring(DEFAULT_TYPE);
   /* no circuits yet */
   NewStatus(func->status);
   func->status->timestamp = time(0);
   func->status->program = canonicstring(DEFAULT_PROGRAM);
   func->status->author = Authorstring;

   func->next = map->librarystruct->function;
   map->librarystruct->function = func;
   
   func->library = map->librarystruct;
   map->functionstruct = func;
   
   if(No_sdf_write == FALSE  && sdfwritefun(SDFFUNSTAT, func) == FALSE)
      error(WARNING,"cannot write func into seadif");
   }
else
   map->functionstruct = thisfun;

/*
 * look for this circuit
 */
if(existscir(map->circuit, map->function, map->library) == FALSE || 
   sdfreadcir(SDFCIRSTAT, map->circuit, map->function, map->library) == FALSE)
   { /* empty */
   NewCircuit(cir);
   cir->name = canonicstring(map->circuit);
   /* no lists yet */
   NewStatus(cir->status);
   cir->status->timestamp = time(0);
   cir->status->program = canonicstring(DEFAULT_PROGRAM);
   cir->status->author = Authorstring;
   
   cir->next = map->functionstruct->circuit;
   map->functionstruct->circuit = cir;

   cir->function = map->functionstruct;
   map->circuitstruct = cir;

   if(No_sdf_write == FALSE && sdfwritecir(SDFCIRSTAT, cir) == FALSE)
      error(WARNING,"cannot write cir into seadif");
   }
else
   map->circuitstruct = thiscir;

/*
 * ready if circuit
 */
if(map->view == circuit_str)
   {
   if (map->circuitstruct->status == NIL) NewStatus(map->circuitstruct->status);
   map->circuitstruct->status->author = Authorstring;
   map->circuitstruct->status->program = canonicstring(DEFAULT_PROGRAM);
   return;
   }

 
/*
 * look for layout
 */
if(existslay(map->layout, map->circuit, map->function, map->library) == FALSE ||
   sdfreadlay(SDFLAYSTAT, map->layout, map->circuit, map->function, map->library) == FALSE)
   { 
   NewLayout(lay);
   lay->name = canonicstring(map->layout);
   NewStatus(lay->status);
   lay->status->timestamp = time(0);
   lay->status->program = canonicstring(DEFAULT_PROGRAM);
   lay->status->author = Authorstring;

   lay->next = map->circuitstruct->layout;
   map->circuitstruct->layout = lay; 

   lay->circuit = map->circuitstruct;
   map->layoutstruct = lay;

   if(No_sdf_write == FALSE && sdfwritelay(SDFLAYSTAT, lay) == FALSE)
      error(WARNING,"cannot write lay into seadif");

   }
else
   map->layoutstruct = thislay;

map->layoutstruct->status->author = Authorstring;
map->layoutstruct->status->program = canonicstring(DEFAULT_PROGRAM);
}
Пример #8
0
/* * * * * * * * * 
 *
 * This routine attaches the cell denoted by 'map' into the 
 * LOCAL library structure (in case fish is not open).
 * in all cases, the pointers in the map structure
 * will be set the the corresponding lbrary, function, circuit and layout.
 * If the cell (or its library, function, etc.) does not exists it will be created.
 */
static void attach_fish_map_to_lib(MAPTABLEPTR  map )

{
LIBRARYPTR
   lib;
register FUNCTIONPTR
   func;
register CIRCUITPTR
   cir;
register LAYOUTPTR
   lay;
/* long
   time(); */
 
/*
 * look for SEADIF struct
 */
if(seadif == NULL)
   { /* make it */
   NewSeadif(seadif);
   NewStatus(seadif->status);
   seadif->status->timestamp = time(0);
   seadif->status->program = canonicstring(DEFAULT_PROGRAM);
   seadif->status->author = canonicstring(DEFAULT_AUTHOR);
   }

/*
 * look for the library
 */
for(lib = seadif->library; lib != NULL && 
                   lib->name != map->library; lib = lib->next)
   /* nothing */;
if(lib == NULL)     
   { /* not found */
   NewLibrary(lib);
   lib->name = canonicstring(map->library);
   lib->technology = Technologystring;
   /* no functions */
   NewStatus(lib->status);
   lib->status->timestamp = time(0);
   lib->status->program = canonicstring(DEFAULT_PROGRAM);
   lib->status->author = canonicstring(DEFAULT_AUTHOR);
   /* link */
   lib->next = seadif->library;
   seadif->library = lib;
   }

map->librarystruct = lib;

/*
 * look for this function
 */
for(func = lib->function; func != NULL && 
                          func->name != map->function; func = func->next)
   /* nothing */;
if(func == NULL)
   { /* not found */
   NewFunction(func);
   func->name = canonicstring(map->function);
   func->type = canonicstring(DEFAULT_TYPE);
   /* no circuits yet */
   NewStatus(func->status);
   func->status->timestamp = time(0);
   func->status->program = canonicstring(DEFAULT_PROGRAM);
   func->status->author = canonicstring(DEFAULT_AUTHOR);
   func->library = lib;
   func->next = lib->function;
   lib->function = func;
   }

map->functionstruct = func;

/*
 * look for this circuit
 */
for(cir = func->circuit; cir != NULL &&
                         cir->name != map->circuit; cir = cir->next)
   /* nothing */;
if(cir == NULL)
   { /* empty */
   NewCircuit(cir);
   cir->name = canonicstring(map->circuit);
   /* no lists yet */
   NewStatus(cir->status);
   cir->status->timestamp = time(0);
   cir->status->program = canonicstring(DEFAULT_PROGRAM);
   cir->status->author = canonicstring(not_in_core_str); /* not in core! */
   cir->function = func;
   cir->next = func->circuit;
   func->circuit = cir;
   }

map->circuitstruct = cir;

/*
 * ready if circuit
 */
if(map->view == circuit_str)
   return;
 
/*
 * look for layout
 */
for(lay = cir->layout; lay != NULL && 
                       lay->name != map->layout; lay = lay->next)
   /* nothing */;
if(lay == NULL)
   {
   NewLayout(lay);
   lay->name = canonicstring(map->layout);
   NewStatus(lay->status);
   lay->status->timestamp = time(0);
   lay->status->program = canonicstring(DEFAULT_PROGRAM);
   lay->status->author = canonicstring(not_in_core_str); /* not in core! */
   lay->circuit = cir;
   lay->next = cir->layout;
   cir->layout = lay;
   }

map->layoutstruct = lay;
}