declared more functions static where possible and appropriate

This commit is contained in:
Stefan Frederik 2022-02-19 14:31:55 +01:00
parent 414cba1623
commit d457565c2d
24 changed files with 789 additions and 914 deletions

View File

@ -373,22 +373,6 @@ const char *get_file_path(char *f)
return tclresult();
}
int samefile(const char *fa, const char *fb)
{
struct stat a, b;
int statusa, statusb;
statusa = stat(fa, &a);
statusb = stat(fb, &b);
if(statusa == 0 && statusb == 0 && a.st_ino == b.st_ino) {
return 1;
}
return 0; /* not same of one of the two not existing */
}
/* return value:
* 1 : file saved or not needed to save since no change
* -1 : user cancel
@ -1837,7 +1821,7 @@ void draw_stuff(void)
#endif
}
void restore_selection(double x1, double y1, double x2, double y2)
static void restore_selection(double x1, double y1, double x2, double y2)
{
double xx1,yy1,xx2,yy2;
xx1 = x1; yy1 = y1; xx2 = x2; yy2 = y2;

View File

@ -79,7 +79,8 @@ void redraw_w_a_l_r_p_rubbers(void)
new_polygon(RUBBER);
}
}
void abort_operation(void)
static void abort_operation(void)
{
xctx->no_draw = 0;
tcleval("set constrained_move 0" );
@ -112,7 +113,7 @@ void abort_operation(void)
draw();
}
void start_place_symbol(double mx, double my)
static void start_place_symbol(double mx, double my)
{
xctx->last_command = 0;
rebuild_selected_array();
@ -131,7 +132,7 @@ void start_place_symbol(double mx, double my)
}
}
void start_line(double mx, double my)
static void start_line(double mx, double my)
{
xctx->last_command = STARTLINE;
if(xctx->ui_state & STARTLINE) {
@ -150,7 +151,7 @@ void start_line(double mx, double my)
new_line(PLACE);
}
void start_wire(double mx, double my)
static void start_wire(double mx, double my)
{
xctx->last_command = STARTWIRE;
if(xctx->ui_state & STARTWIRE) {
@ -2099,7 +2100,6 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
}
if( 0 && (key==';') && (state & ControlMask) ) /* testmode: for performance testing */
{
draw_stuff();
break;
}
if(0 && key=='~' && (state & ControlMask)) { /* testmode */

View File

@ -102,11 +102,12 @@ void clip_xy_to_short(double x, double y, short *sx, short *sy)
*sy = y * r;
}
short clip_to_short(double n)
{
return n > SHRT_MAX ? SHRT_MAX : n < SHRT_MIN ? SHRT_MIN : n;
}
/*
*static short clip_to_short(double n)
*{
* return n > SHRT_MAX ? SHRT_MAX : n < SHRT_MIN ? SHRT_MIN : n;
*}
*/
int rectclip(int x1,int y1,int x2,int y2,
double *xa,double *ya,double *xb,double *yb)
/* coordinates should be ordered, x1<x2,ya<yb and so on... */
@ -196,26 +197,6 @@ double dist(double x1,double y1,double x2,double y2,double xa,double ya)
if(debug_var>=0) {fprintf(errfp, "dist(): Internal error, \n");exit(1);}
}
/*obsolete, will be removed */
double rectdist(double x1,double y1,double x2,double y2,double xa,double ya)
{
double distance,dist;
double xa1,ya1;
xa1 = xa - x1; xa1*=xa1;
ya1 = ya - y1; ya1*=ya1;
distance = xa1 + ya1;
xa1 = xa - x1; xa1*=xa1;
ya1 = ya - y2; ya1*=ya1;
if((dist = xa1 + ya1) < distance) distance = dist;
xa1 = xa - x2; xa1*=xa1;
ya1 = ya - y1; ya1*=ya1;
if((dist = xa1 + ya1) < distance) distance = dist;
xa1 = xa - x2; xa1*=xa1;
ya1 = ya - y2; ya1*=ya1;
if((dist = xa1 + ya1) < distance) distance = dist;
return distance;
}
int touch(double x1,double y1,double x2,double y2,double xa,double ya)
/* improved touch check routine, */
/* works if segments are given from left to right, i.e. x1<=x2 */

View File

@ -122,7 +122,7 @@ void print_image()
}
#if HAS_CAIRO==1
void set_cairo_color(int layer)
static void set_cairo_color(int layer)
{
cairo_set_source_rgb(xctx->cairo_ctx,
(double)xctx->xcolor_array[layer].red/65535.0,
@ -691,7 +691,7 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,short tmp_flip, short rot
}
}
void drawgrid()
static void drawgrid()
{
double x,y;
double delta,tmp;
@ -1599,7 +1599,7 @@ int schematic_waves_loaded(void)
return 0;
}
void get_bus_value(int n_bits, int hex_digits, SPICE_DATA **idx_arr, int p, char *busval,
static void get_bus_value(int n_bits, int hex_digits, SPICE_DATA **idx_arr, int p, char *busval,
double vthl, double vthh)
{
double val;
@ -2649,7 +2649,7 @@ void draw_graph(int i, const int flags, Graph_ctx *gr)
/* flags:
* see draw_graph()
*/
void draw_graph_all(int flags)
static void draw_graph_all(int flags)
{
int i, sch_loaded, hide_graphs;
int bbox_set = 0;

View File

@ -89,27 +89,6 @@ char *my_strtok_r(char *str, const char *delim, const char *quote, char **savept
else return NULL; /* no more tokens */
}
char *xmy_strtok_r(char *str, const char *delim, char **saveptr)
{
char *tok;
if(str) { /* 1st call */
*saveptr = str;
}
while(**saveptr && strchr(delim, **saveptr) ) { /* skip separators */
++(*saveptr);
}
tok = *saveptr; /* start of token */
while(**saveptr && !strchr(delim, **saveptr) ) { /* look for separator marking end of current token */
++(*saveptr);
}
if(**saveptr) {
**saveptr = '\0'; /* mark end of token */
++(*saveptr); /* if not at end of string advance one char for next iteration */
}
if(tok[0]) return tok; /* return token */
else return NULL; /* no more tokens */
}
size_t my_strdup(int id, char **dest, const char *src) /* empty source string --> dest=NULL */
{
size_t len;
@ -1014,52 +993,7 @@ static void edit_text_property(int x)
}
/* x=0 use text widget x=1 use vim editor */
static void edit_symbol_property(int x)
{
char *result=NULL;
int *ii = &xctx->edit_sym_i; /* static var */
int *netl_com = &xctx->netlist_commands; /* static var */
*ii=xctx->sel_array[0].n;
*netl_com = 0;
if ((xctx->inst[*ii].ptr + xctx->sym)->type!=NULL)
*netl_com =
!strcmp( (xctx->inst[*ii].ptr+ xctx->sym)->type, "netlist_commands");
if(xctx->inst[*ii].prop_ptr!=NULL) {
if(*netl_com && x==1) {
tclsetvar("retval",get_tok_value( xctx->inst[*ii].prop_ptr,"value",0));
} else {
tclsetvar("retval",xctx->inst[*ii].prop_ptr);
}
}
else {
tclsetvar("retval","");
}
my_strdup(91, &xctx->old_prop, xctx->inst[*ii].prop_ptr);
tclsetvar("symbol",xctx->inst[*ii].name);
if(x==0) {
tcleval("edit_prop {Input property:}");
my_strdup(77, &result, tclresult());
}
else {
/* edit_vi_netlist_prop will replace \" with " before editing,
replace back " with \" when done and wrap the resulting text with quotes
("text") when done */
if(*netl_com && x==1) tcleval("edit_vi_netlist_prop {Input property:}");
else if(x==1) tcleval("edit_vi_prop {Input property:}");
else if(x==2) tcleval("viewdata $::retval");
my_strdup(78, &result, tclresult());
}
dbg(1, "edit_symbol_property(): before update_symbol, modified=%d\n", xctx->modified);
update_symbol(result, x);
my_free(728, &result);
dbg(1, "edit_symbol_property(): done update_symbol, modified=%d\n", xctx->modified);
*ii=-1;
}
/* x=0 use text widget x=1 use vim editor */
void update_symbol(const char *result, int x)
static void update_symbol(const char *result, int x)
{
int k, sym_number;
int no_change_props=0;
@ -1218,6 +1152,51 @@ void update_symbol(const char *result, int x)
my_free(734, &xctx->old_prop);
}
/* x=0 use text widget x=1 use vim editor */
static void edit_symbol_property(int x)
{
char *result=NULL;
int *ii = &xctx->edit_sym_i; /* static var */
int *netl_com = &xctx->netlist_commands; /* static var */
*ii=xctx->sel_array[0].n;
*netl_com = 0;
if ((xctx->inst[*ii].ptr + xctx->sym)->type!=NULL)
*netl_com =
!strcmp( (xctx->inst[*ii].ptr+ xctx->sym)->type, "netlist_commands");
if(xctx->inst[*ii].prop_ptr!=NULL) {
if(*netl_com && x==1) {
tclsetvar("retval",get_tok_value( xctx->inst[*ii].prop_ptr,"value",0));
} else {
tclsetvar("retval",xctx->inst[*ii].prop_ptr);
}
}
else {
tclsetvar("retval","");
}
my_strdup(91, &xctx->old_prop, xctx->inst[*ii].prop_ptr);
tclsetvar("symbol",xctx->inst[*ii].name);
if(x==0) {
tcleval("edit_prop {Input property:}");
my_strdup(77, &result, tclresult());
}
else {
/* edit_vi_netlist_prop will replace \" with " before editing,
replace back " with \" when done and wrap the resulting text with quotes
("text") when done */
if(*netl_com && x==1) tcleval("edit_vi_netlist_prop {Input property:}");
else if(x==1) tcleval("edit_vi_prop {Input property:}");
else if(x==2) tcleval("viewdata $::retval");
my_strdup(78, &result, tclresult());
}
dbg(1, "edit_symbol_property(): before update_symbol, modified=%d\n", xctx->modified);
update_symbol(result, x);
my_free(728, &result);
dbg(1, "edit_symbol_property(): done update_symbol, modified=%d\n", xctx->modified);
*ii=-1;
}
void change_elem_order(void)
{
xInstance tmpinst;

View File

@ -25,7 +25,7 @@
static double distance; /* safe to keep even with multiple schematics */
static Selected sel; /* safe to keep even with multiple schematics */
void find_closest_net(double mx,double my)
static void find_closest_net(double mx,double my)
/* returns the net that is closest to the mouse pointer */
/* if there are nets and distance < CADWIREMINDIST */
{
@ -47,7 +47,7 @@ void find_closest_net(double mx,double my)
}
}
void find_closest_polygon(double mx,double my)
static void find_closest_polygon(double mx,double my)
/* returns the polygon that is closest to the mouse pointer */
/* if there are lines and distance < CADWIREMINDIST */
{
@ -83,7 +83,7 @@ void find_closest_polygon(double mx,double my)
}
void find_closest_line(double mx,double my)
static void find_closest_line(double mx,double my)
/* returns the line that is closest to the mouse pointer */
/* if there are lines and distance < CADWIREMINDIST */
{
@ -172,7 +172,7 @@ void find_closest_net_or_symbol_pin(double mx,double my, double *x, double *y)
my_free(752, &type);
}
void find_closest_arc(double mx,double my)
static void find_closest_arc(double mx,double my)
{
double dist, angle, angle1, angle2;
int i,c,r=-1, col;
@ -223,7 +223,7 @@ void find_closest_arc(double mx,double my)
}
void find_closest_box(double mx,double my)
static void find_closest_box(double mx,double my)
{
double tmp;
int i,c,r=-1, col = 0;
@ -250,7 +250,7 @@ void find_closest_box(double mx,double my)
}
}
void find_closest_element(double mx,double my)
static void find_closest_element(double mx,double my)
{
double tmp;
int i,r=-1;
@ -274,7 +274,7 @@ void find_closest_element(double mx,double my)
}
}
void find_closest_text(double mx,double my)
static void find_closest_text(double mx,double my)
{
short rot,flip;
double xx1,xx2,yy1,yy2;

View File

@ -544,7 +544,7 @@ void hilight_child_pins(void)
}
int bus_search(const char*s)
static int bus_search(const char*s)
{
int c, bus=0;
while( (c=*s++) ) {
@ -760,7 +760,7 @@ int search(const char *tok, const char *val, int sub, int sel)
/* "drill" option (pass through resistors or pass gates or whatever elements with */
/* 'propag' properties set on pins) */
void drill_hilight(int mode)
static void drill_hilight(int mode)
{
char *netname=NULL, *propagated_net=NULL;
int mult=0;
@ -1184,7 +1184,7 @@ void propagate_hilights(int set, int clear, int mode)
#define STACKMAX 200
int get_logic_value(int inst, int n)
static int get_logic_value(int inst, int n)
{
int /* mult, */ val;
Hilight_hashentry *entry;
@ -1205,17 +1205,7 @@ int get_logic_value(int inst, int n)
return val;
}
void print_stack(int *stack, int sp)
{
int i;
fprintf(errfp, "stack: ");
for(i = 0; i < sp; i++) {
fprintf(errfp, "%d ", stack[i]);
}
fprintf(errfp, "\n");
}
int eval_logic_expr(int inst, int output)
static int eval_logic_expr(int inst, int output)
{
int stack[STACKMAX];
int pos = 0, i, s, sp = 0;
@ -1387,7 +1377,7 @@ int eval_logic_expr(int inst, int output)
* to minimize get_token_value() lookups in simulation loops
*/
void create_simdata(void)
static void create_simdata(void)
{
int i, j;
const char *str;
@ -1432,7 +1422,7 @@ void free_simdata(void)
xctx->simdata_ninst = 0;
}
void propagate_logic()
static void propagate_logic()
{
/* char *propagated_net=NULL; */
int found, iter = 0 /* , mult */;

View File

@ -26,7 +26,7 @@
#endif
#include <locale.h>
void sig_handler(int s){
static void sig_handler(int s){
char emergency_prefix[PATH_MAX];
const char *emergency_dir;
@ -58,13 +58,15 @@ void sig_handler(int s){
exit(EXIT_FAILURE);
}
void child_handler(int signum)
#if 0
static void child_handler(int signum)
{
/* fprintf(errfp, "SIGCHLD received\n"); */
#ifdef __unix__
wait(NULL);
#endif
}
#endif
int main(int argc, char **argv)
{

View File

@ -164,7 +164,7 @@ void check_collapsing_objects()
}
}
void update_symbol_bboxes(short rot, short flip)
static void update_symbol_bboxes(short rot, short flip)
{
int i, n;
short save_flip, save_rot;

View File

@ -157,7 +157,7 @@ static void instpininsert(int n,int pin, double x0, double y0, int x, int y)
}
Instpinentry *delinstpinentry(Instpinentry *t)
static Instpinentry *delinstpinentry(Instpinentry *t)
{
Instpinentry *tmp;
@ -412,7 +412,8 @@ void netlist_options(int i)
}
/* used only for debug */
void print_wires(void)
#if 0
static void print_wires(void)
{
int i,j;
Wireentry *ptr;
@ -438,6 +439,7 @@ void print_wires(void)
}
draw();
}
#endif
static void signal_short( char *n1, char *n2)
{
@ -457,7 +459,7 @@ static void signal_short( char *n1, char *n2)
}
}
void wirecheck(int k) /* recursive routine */
static void wirecheck(int k) /* recursive routine */
{
int tmpi,tmpj, counti,countj,i,j;
int touches;

View File

@ -24,7 +24,7 @@
#define SHORT 1
#define LONG 2
void check_opt(char *opt, char *optval, int type)
static void check_opt(char *opt, char *optval, int type)
{
if( (type == SHORT && *opt == 'd') || (type == LONG && !strcmp("debug", opt)) ) {
if(optval) debug_var=atoi(optval);

View File

@ -70,7 +70,7 @@ void clear_expandlabel_data(void)
my_free(868, &dest_string.str);
}
void str_char_replace(char s[], char chr, char repl_chr)
static void str_char_replace(char s[], char chr, char repl_chr)
{
int i=0;
while(s[i]!='\0')

View File

@ -671,7 +671,7 @@ static void fill_ps_colors()
}
void create_ps(char **psfile, int what)
static void create_ps(char **psfile, int what)
{
double dx, dy, scale, scaley;
int landscape=1;

View File

@ -866,7 +866,7 @@ char *read_line(FILE *fp, int dbg_level)
/* return "/<prefix><random string of random_size characters>"
* example: "/xschem_undo_dj5hcG38T2"
*/
const char *random_string(const char *prefix)
static const char *random_string(const char *prefix)
{
static const char *charset="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
static const int random_size=10;
@ -1541,7 +1541,7 @@ static void load_line(FILE *fd)
xctx->lines[c]++;
}
void read_xschem_file(FILE *fd)
static void read_xschem_file(FILE *fd)
{
int i, found, endfile;
char name_embedded[PATH_MAX];
@ -1725,7 +1725,7 @@ void make_symbol(void)
}
void make_schematic(const char *schname)
static void make_schematic(const char *schname)
{
FILE *fd=NULL;
@ -2364,7 +2364,7 @@ static void use_lcc_pins(int level, char *symtype, char (*filename)[PATH_MAX])
}
}
void calc_symbol_bbox(int pos)
static void calc_symbol_bbox(int pos)
{
int c, i, count = 0;
xRect boundbox, tmp;

View File

@ -41,7 +41,7 @@ void statusmsg(char str[],int n)
}
}
int get_instance(const char *s)
static int get_instance(const char *s)
{
int i, found=0;
for(i=0;i<xctx->instances;i++) {
@ -61,7 +61,7 @@ int get_instance(const char *s)
return i;
}
void xschem_cmd_help(int argc, const char **argv)
static void xschem_cmd_help(int argc, const char **argv)
{
Tcl_ResetResult(interp);
Tcl_AppendResult(interp,

View File

@ -91,6 +91,102 @@ void hier_psprint(void) /* netlister driver */
draw();
}
static char *model_name_result = NULL; /* safe even with multiple schematics */
static char *model_name(const char *m)
{
char *m_lower = NULL;
char *modelname = NULL;
int n;
int l = strlen(m) + 1;
my_strdup(255, &m_lower, m);
strtolower(m_lower);
my_realloc(256, &modelname, l);
my_realloc(257, &model_name_result, l);
n = sscanf(m_lower, " %s %s", model_name_result, modelname);
if(n<2) my_strncpy(model_name_result, m_lower, l);
else {
/* build a hash key value with no spaces to make device_model attributes with different spaces equivalent*/
my_strcat(296, &model_name_result, modelname);
}
my_free(948, &modelname);
my_free(949, &m_lower);
return model_name_result;
}
static void spice_netlist(FILE *fd, int spice_stop )
{
int i, flag = 0;
char *type=NULL;
int top_sub;
top_sub = tclgetboolvar("top_subckt");
if(!spice_stop) {
xctx->prep_net_structs = 0;
prepare_netlist_structs(1);
traverse_node_hash(); /* print all warnings about unconnected floatings etc */
for(i=0;i<xctx->instances;i++) /* print first ipin/opin defs ... */
{
if( strcmp(get_tok_value(xctx->inst[i].prop_ptr,"spice_ignore",0),"true")==0 ) continue;
if(xctx->inst[i].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "spice_ignore",0 ), "true") ) {
continue;
}
my_strdup(388, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type && IS_PIN(type) ) {
if(top_sub && !flag) {
fprintf(fd, "*.PININFO ");
flag = 1;
}
if(top_sub) {
int d = 'X';
if(!strcmp(type, "ipin")) d = 'I';
if(!strcmp(type, "opin")) d = 'O';
if(!strcmp(type, "iopin")) d = 'B';
fprintf(fd, "%s:%c ",get_tok_value(xctx->inst[i].prop_ptr, "lab",0), d);
} else {
print_spice_element(fd, i) ; /* this is the element line */
}
}
}
if(top_sub) fprintf(fd, "\n");
for(i=0;i<xctx->instances;i++) /* ... then print other lines */
{
if( strcmp(get_tok_value(xctx->inst[i].prop_ptr,"spice_ignore",0),"true")==0 ) continue;
if(xctx->inst[i].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "spice_ignore",0 ), "true") ) {
continue;
}
my_strdup(390, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type && !IS_LABEL_OR_PIN(type) ) {
/* already done in global_spice_netlist */
if(!strcmp(type,"netlist_commands") && xctx->netlist_count==0) continue;
if(xctx->netlist_count &&
!strcmp(get_tok_value(xctx->inst[i].prop_ptr, "only_toplevel", 0), "true")) continue;
if(!strcmp(type,"netlist_commands")) {
fprintf(fd,"**** begin user architecture code\n");
print_spice_element(fd, i) ; /* this is the element line */
fprintf(fd,"**** end user architecture code\n");
} else {
const char *m;
if(print_spice_element(fd, i)) fprintf(fd, "**** end_element\n");
/* hash device_model attribute if any */
m = get_tok_value(xctx->inst[i].prop_ptr, "device_model", 0);
if(m[0]) str_hash_lookup(model_table, model_name(m), m, XINSERT);
else {
m = get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "device_model", 0);
if(m[0]) str_hash_lookup(model_table, model_name(m), m, XINSERT);
}
my_free(951, &model_name_result);
}
}
}
my_free(952, &type);
}
if(!spice_stop && !xctx->netlist_count) redraw_hilights(0); /* draw_hilight_net(1); */
}
void global_spice_netlist(int global) /* netlister driver */
{
int first;
@ -379,29 +475,6 @@ void global_spice_netlist(int global) /* netlister driver */
xctx->netlist_count = 0;
}
static char *model_name_result = NULL; /* safe even with multiple schematics */
static char *model_name(const char *m)
{
char *m_lower = NULL;
char *modelname = NULL;
int n;
int l = strlen(m) + 1;
my_strdup(255, &m_lower, m);
strtolower(m_lower);
my_realloc(256, &modelname, l);
my_realloc(257, &model_name_result, l);
n = sscanf(m_lower, " %s %s", model_name_result, modelname);
if(n<2) my_strncpy(model_name_result, m_lower, l);
else {
/* build a hash key value with no spaces to make device_model attributes with different spaces equivalent*/
my_strcat(296, &model_name_result, modelname);
}
my_free(948, &modelname);
my_free(949, &m_lower);
return model_name_result;
}
void spice_block_netlist(FILE *fd, int i)
{
int spice_stop=0;
@ -478,79 +551,6 @@ void spice_block_netlist(FILE *fd, int i)
}
}
void spice_netlist(FILE *fd, int spice_stop )
{
int i, flag = 0;
char *type=NULL;
int top_sub;
top_sub = tclgetboolvar("top_subckt");
if(!spice_stop) {
xctx->prep_net_structs = 0;
prepare_netlist_structs(1);
traverse_node_hash(); /* print all warnings about unconnected floatings etc */
for(i=0;i<xctx->instances;i++) /* print first ipin/opin defs ... */
{
if( strcmp(get_tok_value(xctx->inst[i].prop_ptr,"spice_ignore",0),"true")==0 ) continue;
if(xctx->inst[i].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "spice_ignore",0 ), "true") ) {
continue;
}
my_strdup(388, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type && IS_PIN(type) ) {
if(top_sub && !flag) {
fprintf(fd, "*.PININFO ");
flag = 1;
}
if(top_sub) {
int d = 'X';
if(!strcmp(type, "ipin")) d = 'I';
if(!strcmp(type, "opin")) d = 'O';
if(!strcmp(type, "iopin")) d = 'B';
fprintf(fd, "%s:%c ",get_tok_value(xctx->inst[i].prop_ptr, "lab",0), d);
} else {
print_spice_element(fd, i) ; /* this is the element line */
}
}
}
if(top_sub) fprintf(fd, "\n");
for(i=0;i<xctx->instances;i++) /* ... then print other lines */
{
if( strcmp(get_tok_value(xctx->inst[i].prop_ptr,"spice_ignore",0),"true")==0 ) continue;
if(xctx->inst[i].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "spice_ignore",0 ), "true") ) {
continue;
}
my_strdup(390, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type && !IS_LABEL_OR_PIN(type) ) {
/* already done in global_spice_netlist */
if(!strcmp(type,"netlist_commands") && xctx->netlist_count==0) continue;
if(xctx->netlist_count &&
!strcmp(get_tok_value(xctx->inst[i].prop_ptr, "only_toplevel", 0), "true")) continue;
if(!strcmp(type,"netlist_commands")) {
fprintf(fd,"**** begin user architecture code\n");
print_spice_element(fd, i) ; /* this is the element line */
fprintf(fd,"**** end user architecture code\n");
} else {
const char *m;
if(print_spice_element(fd, i)) fprintf(fd, "**** end_element\n");
/* hash device_model attribute if any */
m = get_tok_value(xctx->inst[i].prop_ptr, "device_model", 0);
if(m[0]) str_hash_lookup(model_table, model_name(m), m, XINSERT);
else {
m = get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "device_model", 0);
if(m[0]) str_hash_lookup(model_table, model_name(m), m, XINSERT);
}
my_free(951, &model_name_result);
}
}
}
my_free(952, &type);
}
if(!spice_stop && !xctx->netlist_count) redraw_hilights(0); /* draw_hilight_net(1); */
}
/* GENERIC PURPOSE HASH TABLE */

View File

@ -353,18 +353,3 @@ void storeobject(int pos, double x1,double y1,double x2,double y2,
set_modify(1);
}
}
void freenet_nocheck(int i)
{
int j;
my_free(959, &xctx->wire[i].prop_ptr);
my_free(960, &xctx->wire[i].node);
for(j=i+1;j<xctx->wires;j++)
{
xctx->wire[j-1] = xctx->wire[j];
xctx->wire[j].prop_ptr=NULL;
xctx->wire[j].node=NULL;
} /*end for j */
xctx->wires--;
}

View File

@ -390,7 +390,7 @@ static void svg_drawgrid()
}
void svg_embedded_image(xRect *r, double rx1, double ry1, double rx2, double ry2, int rot, int flip)
static void svg_embedded_image(xRect *r, double rx1, double ry1, double rx2, double ry2, int rot, int flip)
{
const char *ptr;
double x1, y1, x2, y2, w, h, scalex = 1.0, scaley = 1.0;

View File

@ -22,6 +22,106 @@
#include "xschem.h"
static void tedax_netlist(FILE *fd, int tedax_stop )
{
int i;
char *type=NULL;
if(!tedax_stop) {
xctx->prep_net_structs = 0;
prepare_netlist_structs(1);
traverse_node_hash(); /* print all warnings about unconnected floatings etc */
}
if(!tedax_stop) {
for(i=0;i<xctx->instances;i++) /* print first ipin/opin defs ... */
{
if( strcmp(get_tok_value(xctx->inst[i].prop_ptr,"tedax_ignore",0),"true")==0 ) continue;
if(xctx->inst[i].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "tedax_ignore",0 ), "true") ) {
continue;
}
my_strdup(421, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type && IS_PIN(type) ) {
print_tedax_element(fd, i) ; /* this is the element line */
}
}
for(i=0;i<xctx->instances;i++) /* ... then print other lines */
{
if( strcmp(get_tok_value(xctx->inst[i].prop_ptr,"tedax_ignore",0),"true")==0 ) continue;
if(xctx->inst[i].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "tedax_ignore",0 ), "true") ) {
continue;
}
my_strdup(423, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type && !IS_LABEL_OR_PIN(type) ) {
/* already done in global_tedax_netlist */
if(!strcmp(type,"netlist_commands") && xctx->netlist_count==0) continue;
if(xctx->netlist_count &&
!strcmp(get_tok_value(xctx->inst[i].prop_ptr, "only_toplevel", 0), "true")) continue;
if(!strcmp(type,"netlist_commands")) {
fprintf(fd,"#**** begin user architecture code\n");
print_tedax_element(fd, i) ; /* this is the element line */
fprintf(fd,"#**** end user architecture code\n");
} else {
print_tedax_element(fd, i) ; /* this is the element line */
}
}
}
my_free(967, &type);
}
if(!tedax_stop && !xctx->netlist_count) redraw_hilights(0); /* draw_hilight_net(1); */
}
static void tedax_block_netlist(FILE *fd, int i)
{
int tedax_stop=0;
char filename[PATH_MAX];
const char *str_tmp;
char *extra=NULL;
char *sch = NULL;
if(!strcmp( get_tok_value(xctx->sym[i].prop_ptr,"tedax_stop",0),"true") )
tedax_stop=1;
else
tedax_stop=0;
if((str_tmp = get_tok_value(xctx->sym[i].prop_ptr, "schematic",0 ))[0]) {
my_strdup2(1256, &sch, str_tmp);
my_strncpy(filename, abs_sym_path(sch, ""), S(filename));
my_free(1257, &sch);
} else {
my_strncpy(filename, add_ext(abs_sym_path(xctx->sym[i].name, ""), ".sch"), S(filename));
}
fprintf(fd, "\n# expanding symbol: %s # of pins=%d\n",
xctx->sym[i].name,xctx->sym[i].rects[PINLAYER] );
fprintf(fd, "## sym_path: %s\n", abs_sym_path(xctx->sym[i].name, ""));
fprintf(fd, "## sch_path: %s\n", filename);
fprintf(fd, "begin netlist v1 %s\n",skip_dir(xctx->sym[i].name));
print_tedax_subckt(fd, i);
my_strdup(420, &extra, get_tok_value(xctx->sym[i].prop_ptr,"extra",0) );
/* this is now done in print_spice_subckt */
/*
* fprintf(fd, "%s ", extra ? extra : "" );
*/
/* 20081206 new get_sym_template does not return token=value pairs where token listed in extra */
fprintf(fd, "%s", get_sym_template(xctx->sym[i].templ, extra));
my_free(966, &extra);
fprintf(fd, "\n");
load_schematic(1,filename, 0);
tedax_netlist(fd, tedax_stop);
xctx->netlist_count++;
if(xctx->schprop && xctx->schprop[0]) {
fprintf(fd,"#**** begin user architecture code\n");
fprintf(fd, "%s\n", xctx->schprop);
fprintf(fd,"#**** end user architecture code\n");
}
fprintf(fd, "end netlist\n\n");
}
void global_tedax_netlist(int global) /* netlister driver */
{
FILE *fd;
@ -147,104 +247,3 @@ void global_tedax_netlist(int global) /* netlister driver */
}
void tedax_block_netlist(FILE *fd, int i)
{
int tedax_stop=0;
char filename[PATH_MAX];
const char *str_tmp;
char *extra=NULL;
char *sch = NULL;
if(!strcmp( get_tok_value(xctx->sym[i].prop_ptr,"tedax_stop",0),"true") )
tedax_stop=1;
else
tedax_stop=0;
if((str_tmp = get_tok_value(xctx->sym[i].prop_ptr, "schematic",0 ))[0]) {
my_strdup2(1256, &sch, str_tmp);
my_strncpy(filename, abs_sym_path(sch, ""), S(filename));
my_free(1257, &sch);
} else {
my_strncpy(filename, add_ext(abs_sym_path(xctx->sym[i].name, ""), ".sch"), S(filename));
}
fprintf(fd, "\n# expanding symbol: %s # of pins=%d\n",
xctx->sym[i].name,xctx->sym[i].rects[PINLAYER] );
fprintf(fd, "## sym_path: %s\n", abs_sym_path(xctx->sym[i].name, ""));
fprintf(fd, "## sch_path: %s\n", filename);
fprintf(fd, "begin netlist v1 %s\n",skip_dir(xctx->sym[i].name));
print_tedax_subckt(fd, i);
my_strdup(420, &extra, get_tok_value(xctx->sym[i].prop_ptr,"extra",0) );
/* this is now done in print_spice_subckt */
/*
* fprintf(fd, "%s ", extra ? extra : "" );
*/
/* 20081206 new get_sym_template does not return token=value pairs where token listed in extra */
fprintf(fd, "%s", get_sym_template(xctx->sym[i].templ, extra));
my_free(966, &extra);
fprintf(fd, "\n");
load_schematic(1,filename, 0);
tedax_netlist(fd, tedax_stop);
xctx->netlist_count++;
if(xctx->schprop && xctx->schprop[0]) {
fprintf(fd,"#**** begin user architecture code\n");
fprintf(fd, "%s\n", xctx->schprop);
fprintf(fd,"#**** end user architecture code\n");
}
fprintf(fd, "end netlist\n\n");
}
void tedax_netlist(FILE *fd, int tedax_stop )
{
int i;
char *type=NULL;
if(!tedax_stop) {
xctx->prep_net_structs = 0;
prepare_netlist_structs(1);
traverse_node_hash(); /* print all warnings about unconnected floatings etc */
}
if(!tedax_stop) {
for(i=0;i<xctx->instances;i++) /* print first ipin/opin defs ... */
{
if( strcmp(get_tok_value(xctx->inst[i].prop_ptr,"tedax_ignore",0),"true")==0 ) continue;
if(xctx->inst[i].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "tedax_ignore",0 ), "true") ) {
continue;
}
my_strdup(421, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type && IS_PIN(type) ) {
print_tedax_element(fd, i) ; /* this is the element line */
}
}
for(i=0;i<xctx->instances;i++) /* ... then print other lines */
{
if( strcmp(get_tok_value(xctx->inst[i].prop_ptr,"tedax_ignore",0),"true")==0 ) continue;
if(xctx->inst[i].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "tedax_ignore",0 ), "true") ) {
continue;
}
my_strdup(423, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type && !IS_LABEL_OR_PIN(type) ) {
/* already done in global_tedax_netlist */
if(!strcmp(type,"netlist_commands") && xctx->netlist_count==0) continue;
if(xctx->netlist_count &&
!strcmp(get_tok_value(xctx->inst[i].prop_ptr, "only_toplevel", 0), "true")) continue;
if(!strcmp(type,"netlist_commands")) {
fprintf(fd,"#**** begin user architecture code\n");
print_tedax_element(fd, i) ; /* this is the element line */
fprintf(fd,"#**** end user architecture code\n");
} else {
print_tedax_element(fd, i) ; /* this is the element line */
}
}
}
my_free(967, &type);
}
if(!tedax_stop && !xctx->netlist_count) redraw_hilights(0); /* draw_hilight_net(1); */
}

View File

@ -36,17 +36,6 @@ unsigned int str_hash(const char *tok)
return hash;
}
/* seems unused */
int name_strcmp(char *s, char *d) /* compare strings up to '\0' or'[' */
{
while(*s == *d) {
if(*s == '\0' || *s == '[') return 0;
s++;
d++;
}
return *s - *d;
}
/* 20180926 added token_size */
/* what:
* 0,XINSERT : lookup token and insert xctx->inst[value].instname in hash table
@ -580,7 +569,7 @@ const char *get_sym_template(char *s,char *extra)
return result;
}
const char *find_bracket(const char *s)
static const char *find_bracket(const char *s)
{
while(*s!='['&& *s!='\0') s++;
return s;
@ -588,7 +577,7 @@ const char *find_bracket(const char *s)
/* caller is responsible for freeing up storage for return value
* return NULL if no matching token found */
char *get_pin_attr_from_inst(int inst, int pin, const char *attr)
static char *get_pin_attr_from_inst(int inst, int pin, const char *attr)
{
int attr_size;
char *pinname = NULL, *pname = NULL, *pin_attr_value = NULL;
@ -701,7 +690,7 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
int is_quoted(const char *s)
static int is_quoted(const char *s)
{
int c, escape = 0;
int openquote = 0;
@ -733,6 +722,178 @@ int is_quoted(const char *s)
return 0;
}
static void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 20071217 */
{
int i=0, multip, tmp;
const char *str_ptr;
register int c, state=TOK_BEGIN, space;
const char *lab;
char *template=NULL,*format=NULL,*s, *name=NULL, *token=NULL;
const char *value;
int pin_number;
int sizetok=0;
int token_pos=0, escape=0;
int no_of_pins=0;
/* Inst_hashentry *ptr; */
my_strdup(513, &template, (xctx->inst[inst].ptr + xctx->sym)->templ);
my_strdup(514, &name, xctx->inst[inst].instname);
if(!name) my_strdup(50, &name, get_tok_value(template, "name", 0));
/* allow format string override in instance */
my_strdup(1000, &format, get_tok_value(xctx->inst[inst].prop_ptr,"vhdl_format",2));
if(!format || !format[0])
my_strdup(516, &format, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr,"vhdl_format",2));
if((name==NULL) || (format==NULL) ) {
my_free(1047, &template);
my_free(1048, &name);
my_free(1151, &format);
return; /*do no netlist unwanted insts(no format) */
}
no_of_pins= (xctx->inst[inst].ptr + xctx->sym)->rects[PINLAYER];
s=format;
dbg(1, "print_vhdl_primitive(): name=%s, format=%s xctx->netlist_count=%d\n",name,format, xctx->netlist_count);
fprintf(fd, "---- start primitive ");
lab=expandlabel(name, &tmp);
fprintf(fd, "%d\n",tmp);
/* begin parsing format string */
while(1)
{
c=*s++;
if(c=='\\') {
escape=1;
c=*s++;
}
else escape=0;
if(c=='\n' && escape ) c=*s++; /* 20171030 eat escaped newlines */
space=SPACE(c);
if( state==TOK_BEGIN && (c=='@' || c=='%') && !escape ) state=TOK_TOKEN;
else if(state==TOK_TOKEN && token_pos > 1 &&
(
( (space || c == '%' || c == '@') && !escape ) ||
( (!space && c != '%' && c != '@') && escape )
)
) {
state=TOK_SEP;
}
STR_ALLOC(&token, token_pos, &sizetok);
if(state==TOK_TOKEN) {
token[token_pos++]=c; /* 20171029 remove escaping backslashes */
}
else if(state==TOK_SEP) /* got a token */
{
token[token_pos]='\0';
token_pos=0;
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
/* xctx->tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!xctx->tok_size)
value=get_tok_value(template, token+1, 0);
if(!xctx->tok_size && token[0] =='%') {
fputs(token + 1, fd);
} else if(value && value[0]!='\0')
{ /* instance names (name) and node labels (lab) go thru the expandlabel function. */
/*if something else must be parsed, put an if here! */
if(!(strcmp(token+1,"name"))) {
if( (lab=expandlabel(value, &tmp)) != NULL)
fprintf(fd, "----name(%s)", lab);
else
fprintf(fd, "%s", value);
}
else if(!(strcmp(token+1,"lab"))) {
if( (lab=expandlabel(value, &tmp)) != NULL)
fprintf(fd, "----pin(%s)", lab);
else
fprintf(fd, "%s", value);
}
else fprintf(fd, "%s", value);
}
else if(strcmp(token,"@symname")==0) /* of course symname must not be present */
/* in hash table */
{
fprintf( fd, "%s",skip_dir(xctx->inst[inst].name) );
}
else if (strcmp(token,"@symname_ext")==0)
{
fputs(get_cell_w_ext(xctx->inst[inst].name, 0), fd);
}
else if(strcmp(token,"@schname")==0) /* of course schname must not be present */
/* in hash table */
{
/* fputs(xctx->sch[xctx->currsch],fd); */
fputs(xctx->current_name, fd);
}
else if(strcmp(token,"@pinlist")==0) /* of course pinlist must not be present */
/* in hash table. print multiplicity */
{ /* and node number: m1 n1 m2 n2 .... */
for(i=0;i<no_of_pins;i++)
{
char *prop = (xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][i].prop_ptr;
if(strcmp(get_tok_value(prop,"vhdl_ignore",0), "true")) {
str_ptr = net_name(inst,i, &multip, 0, 1);
fprintf(fd, "----pin(%s) ", str_ptr);
}
}
}
else if(token[0]=='@' && token[1]=='@') { /* recognize single pins 15112003 */
for(i=0;i<no_of_pins;i++) {
xSymbol *ptr = xctx->inst[inst].ptr + xctx->sym;
if(!strcmp( get_tok_value(ptr->rect[PINLAYER][i].prop_ptr,"name",0), token+2)) {
if(strcmp(get_tok_value(ptr->rect[PINLAYER][i].prop_ptr,"vhdl_ignore",0), "true")) {
str_ptr = net_name(inst,i, &multip, 0, 1);
fprintf(fd, "----pin(%s) ", str_ptr);
}
break;
}
}
}
/* reference by pin number instead of pin name, allows faster lookup of the attached net name 20180911 */
else if(token[0]=='@' && token[1]=='#') {
pin_number = atoi(token+2);
if(pin_number < no_of_pins) {
char *prop = (xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][pin_number].prop_ptr;
if(strcmp(get_tok_value(prop,"vhdl_ignore",0), "true")) {
str_ptr = net_name(inst,pin_number, &multip, 0, 1);
fprintf(fd, "----pin(%s) ", str_ptr);
}
}
}
else if(!strncmp(token,"@tcleval", 8)) {
/* char tclcmd[strlen(token)+100] ; */
size_t s;
char *tclcmd=NULL;
s = token_pos + strlen(name) + strlen(xctx->inst[inst].name) + 100;
tclcmd = my_malloc(518, s);
Tcl_ResetResult(interp);
my_snprintf(tclcmd, s, "tclpropeval {%s} {%s} {%s}", token, name, xctx->inst[inst].name);
tcleval(tclcmd);
fprintf(fd, "%s", tclresult());
my_free(1049, &tclcmd);
}
if(c!='%' && c!='@' && c!='\0' ) fputc(c,fd);
if(c == '@' || c == '%') s--;
state=TOK_BEGIN;
}
else if(state==TOK_BEGIN && c!='\0') fputc(c,fd);
if(c=='\0')
{
fputc('\n',fd);
fprintf(fd, "---- end primitive\n");
break ;
}
}
my_free(1050, &template);
my_free(1051, &format);
my_free(1052, &name);
my_free(1053, &token);
}
const char *subst_token(const char *s, const char *tok, const char *new_val)
/* given a string <s> with multiple "token=value ..." assignments */
/* substitute <tok>'s value with <new_val> */
@ -1093,10 +1254,6 @@ void print_vhdl_element(FILE *fd, int inst)
}
}
if(tmp) fprintf(fd, "\n)\n");
dbg(2, "print_vhdl_element(): printing port maps \n");
/* print port map */
fprintf(fd, "port map(\n" );
@ -2129,6 +2286,180 @@ void print_tedax_element(FILE *fd, int inst)
my_free(1039, &token);
}
/* print verilog element if verilog_format is specified */
static void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level primitives, 15112003 */
{
int i=0, multip, tmp;
const char *str_ptr;
register int c, state=TOK_BEGIN, space;
const char *lab;
char *template=NULL,*format=NULL,*s=NULL, *name=NULL, *token=NULL;
const char *value;
int sizetok=0;
int token_pos=0, escape=0;
int no_of_pins=0;
/* Inst_hashentry *ptr; */
my_strdup(519, &template,
(xctx->inst[inst].ptr + xctx->sym)->templ);
my_strdup(520, &name,xctx->inst[inst].instname);
if(!name) my_strdup(4, &name, get_tok_value(template, "name", 0));
/* allow format string override in instance */
my_strdup(1186, &format, get_tok_value(xctx->inst[inst].prop_ptr,"verilog_format",2));
if(!format || !format[0])
my_strdup(522, &format, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr,"verilog_format",2));
if((name==NULL) || (format==NULL) ) {
my_free(1054, &template);
my_free(1055, &name);
my_free(1056, &format);
return; /*do no netlist unwanted insts(no format) */
}
no_of_pins= (xctx->inst[inst].ptr + xctx->sym)->rects[PINLAYER];
s=format;
dbg(1, "print_verilog_primitive(): name=%s, format=%s xctx->netlist_count=%d\n",name,format, xctx->netlist_count);
fprintf(fd, "---- start primitive ");
lab=expandlabel(name, &tmp);
fprintf(fd, "%d\n",tmp);
/* begin parsing format string */
while(1)
{
c=*s++;
if(c=='\\') {
escape=1;
c=*s++;
}
else escape=0;
if(c=='\n' && escape ) c=*s++; /* 20171030 eat escaped newlines */
space=SPACE(c);
if( state==TOK_BEGIN && (c=='@' || c=='%') && !escape ) state=TOK_TOKEN;
else if(state==TOK_TOKEN && token_pos > 1 &&
(
( (space || c == '%' || c == '@') && !escape ) ||
( (!space && c != '%' && c != '@') && escape )
)
) {
state=TOK_SEP;
}
STR_ALLOC(&token, token_pos, &sizetok);
if(state==TOK_TOKEN) {
token[token_pos++]=c;
}
else if(state==TOK_SEP) /* got a token */
{
token[token_pos]='\0';
token_pos=0;
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
/* xctx->tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!xctx->tok_size)
value=get_tok_value(template, token+1, 0);
if(!xctx->tok_size && token[0] =='%') {
fputs(token + 1, fd);
} else if(value && value[0]!='\0') {
/* instance names (name) and node labels (lab) go thru the expandlabel function. */
/*if something else must be parsed, put an if here! */
if(!(strcmp(token+1,"name"))) {
if( (lab=expandlabel(value, &tmp)) != NULL)
fprintf(fd, "----name(%s)", lab);
else
fprintf(fd, "%s", value);
}
else if(!(strcmp(token+1,"lab"))) {
if( (lab=expandlabel(value, &tmp)) != NULL)
fprintf(fd, "----pin(%s)", lab);
else
fprintf(fd, "%s", value);
}
else fprintf(fd, "%s", value);
}
else if(strcmp(token,"@symname")==0) /* of course symname must not be present */
/* in hash table */
{
fprintf( fd, "%s",skip_dir(xctx->inst[inst]. name) );
}
else if (strcmp(token,"@symname_ext")==0)
{
fputs(get_cell_w_ext(xctx->inst[inst].name, 0), fd);
}
else if(strcmp(token,"@schname")==0) /* of course schname must not be present */
/* in hash table */
{
/* fputs(xctx->sch[xctx->currsch],fd); */
fputs(xctx->current_name, fd);
}
else if(strcmp(token,"@pinlist")==0) /* of course pinlist must not be present */
/* in hash table. print multiplicity */
{ /* and node number: m1 n1 m2 n2 .... */
for(i=0;i<no_of_pins;i++)
{
char *prop = (xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][i].prop_ptr;
if(strcmp(get_tok_value(prop, "verilog_ignore",0), "true")) {
str_ptr = net_name(inst,i, &multip, 0, 1);
fprintf(fd, "----pin(%s) ", str_ptr);
}
}
}
else if(token[0]=='@' && token[1]=='@') { /* recognize single pins 15112003 */
for(i=0;i<no_of_pins;i++) {
char *prop = (xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][i].prop_ptr;
if(!strcmp( get_tok_value(prop,"name",0), token+2)) {
if(strcmp(get_tok_value(prop, "verilog_ignore",0), "true")) {
str_ptr = net_name(inst,i, &multip, 0, 1);
fprintf(fd, "----pin(%s) ", str_ptr);
}
break;
}
}
}
/* reference by pin number instead of pin name, allows faster lookup of the attached net name 20180911 */
else if(token[0]=='@' && token[1]=='#') {
int pin_number = atoi(token+2);
if(pin_number < no_of_pins) {
const char *vi;
char *prop = (xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][pin_number].prop_ptr;
vi = get_tok_value(prop,"verilog_ignore",0);
if(strcmp(vi, "true")) {
str_ptr = net_name(inst,pin_number, &multip, 0, 1);
fprintf(fd, "----pin(%s) ", str_ptr);
}
}
}
else if(!strncmp(token,"@tcleval", 8)) {
/* char tclcmd[strlen(token)+100] ; */
size_t s;
char *tclcmd=NULL;
s = token_pos + strlen(name) + strlen(xctx->inst[inst].name) + 100;
tclcmd = my_malloc(524, s);
Tcl_ResetResult(interp);
my_snprintf(tclcmd, s, "tclpropeval {%s} {%s} {%s}", token, name, xctx->inst[inst].name);
tcleval(tclcmd);
fprintf(fd, "%s", tclresult());
my_free(1057, &tclcmd);
}
if(c!='%' && c!='@' && c!='\0') fputc(c,fd);
if(c == '@' || c == '%') s--;
state=TOK_BEGIN;
}
else if(state==TOK_BEGIN && c!='\0') fputc(c,fd);
if(c=='\0')
{
fputc('\n',fd);
fprintf(fd, "---- end primitive\n");
break ;
}
}
my_free(1058, &template);
my_free(1059, &format);
my_free(1060, &name);
my_free(1061, &token);
}
/* verilog module instantiation:
cmos_inv
#(
@ -2357,353 +2688,6 @@ const char *net_name(int i, int j, int *multip, int hash_prefix_unnamed_net, int
}
}
void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 20071217 */
{
int i=0, multip, tmp;
const char *str_ptr;
register int c, state=TOK_BEGIN, space;
const char *lab;
char *template=NULL,*format=NULL,*s, *name=NULL, *token=NULL;
const char *value;
int pin_number;
int sizetok=0;
int token_pos=0, escape=0;
int no_of_pins=0;
/* Inst_hashentry *ptr; */
my_strdup(513, &template, (xctx->inst[inst].ptr + xctx->sym)->templ);
my_strdup(514, &name, xctx->inst[inst].instname);
if(!name) my_strdup(50, &name, get_tok_value(template, "name", 0));
/* allow format string override in instance */
my_strdup(1000, &format, get_tok_value(xctx->inst[inst].prop_ptr,"vhdl_format",2));
if(!format || !format[0])
my_strdup(516, &format, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr,"vhdl_format",2));
if((name==NULL) || (format==NULL) ) {
my_free(1047, &template);
my_free(1048, &name);
my_free(1151, &format);
return; /*do no netlist unwanted insts(no format) */
}
no_of_pins= (xctx->inst[inst].ptr + xctx->sym)->rects[PINLAYER];
s=format;
dbg(1, "print_vhdl_primitive(): name=%s, format=%s xctx->netlist_count=%d\n",name,format, xctx->netlist_count);
fprintf(fd, "---- start primitive ");
lab=expandlabel(name, &tmp);
fprintf(fd, "%d\n",tmp);
/* begin parsing format string */
while(1)
{
c=*s++;
if(c=='\\') {
escape=1;
c=*s++;
}
else escape=0;
if(c=='\n' && escape ) c=*s++; /* 20171030 eat escaped newlines */
space=SPACE(c);
if( state==TOK_BEGIN && (c=='@' || c=='%') && !escape ) state=TOK_TOKEN;
else if(state==TOK_TOKEN && token_pos > 1 &&
(
( (space || c == '%' || c == '@') && !escape ) ||
( (!space && c != '%' && c != '@') && escape )
)
) {
state=TOK_SEP;
}
STR_ALLOC(&token, token_pos, &sizetok);
if(state==TOK_TOKEN) {
token[token_pos++]=c; /* 20171029 remove escaping backslashes */
}
else if(state==TOK_SEP) /* got a token */
{
token[token_pos]='\0';
token_pos=0;
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
/* xctx->tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!xctx->tok_size)
value=get_tok_value(template, token+1, 0);
if(!xctx->tok_size && token[0] =='%') {
fputs(token + 1, fd);
} else if(value && value[0]!='\0')
{ /* instance names (name) and node labels (lab) go thru the expandlabel function. */
/*if something else must be parsed, put an if here! */
if(!(strcmp(token+1,"name"))) {
if( (lab=expandlabel(value, &tmp)) != NULL)
fprintf(fd, "----name(%s)", lab);
else
fprintf(fd, "%s", value);
}
else if(!(strcmp(token+1,"lab"))) {
if( (lab=expandlabel(value, &tmp)) != NULL)
fprintf(fd, "----pin(%s)", lab);
else
fprintf(fd, "%s", value);
}
else fprintf(fd, "%s", value);
}
else if(strcmp(token,"@symname")==0) /* of course symname must not be present */
/* in hash table */
{
fprintf( fd, "%s",skip_dir(xctx->inst[inst].name) );
}
else if (strcmp(token,"@symname_ext")==0)
{
fputs(get_cell_w_ext(xctx->inst[inst].name, 0), fd);
}
else if(strcmp(token,"@schname")==0) /* of course schname must not be present */
/* in hash table */
{
/* fputs(xctx->sch[xctx->currsch],fd); */
fputs(xctx->current_name, fd);
}
else if(strcmp(token,"@pinlist")==0) /* of course pinlist must not be present */
/* in hash table. print multiplicity */
{ /* and node number: m1 n1 m2 n2 .... */
for(i=0;i<no_of_pins;i++)
{
char *prop = (xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][i].prop_ptr;
if(strcmp(get_tok_value(prop,"vhdl_ignore",0), "true")) {
str_ptr = net_name(inst,i, &multip, 0, 1);
fprintf(fd, "----pin(%s) ", str_ptr);
}
}
}
else if(token[0]=='@' && token[1]=='@') { /* recognize single pins 15112003 */
for(i=0;i<no_of_pins;i++) {
xSymbol *ptr = xctx->inst[inst].ptr + xctx->sym;
if(!strcmp( get_tok_value(ptr->rect[PINLAYER][i].prop_ptr,"name",0), token+2)) {
if(strcmp(get_tok_value(ptr->rect[PINLAYER][i].prop_ptr,"vhdl_ignore",0), "true")) {
str_ptr = net_name(inst,i, &multip, 0, 1);
fprintf(fd, "----pin(%s) ", str_ptr);
}
break;
}
}
}
/* reference by pin number instead of pin name, allows faster lookup of the attached net name 20180911 */
else if(token[0]=='@' && token[1]=='#') {
pin_number = atoi(token+2);
if(pin_number < no_of_pins) {
char *prop = (xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][pin_number].prop_ptr;
if(strcmp(get_tok_value(prop,"vhdl_ignore",0), "true")) {
str_ptr = net_name(inst,pin_number, &multip, 0, 1);
fprintf(fd, "----pin(%s) ", str_ptr);
}
}
}
else if(!strncmp(token,"@tcleval", 8)) {
/* char tclcmd[strlen(token)+100] ; */
size_t s;
char *tclcmd=NULL;
s = token_pos + strlen(name) + strlen(xctx->inst[inst].name) + 100;
tclcmd = my_malloc(518, s);
Tcl_ResetResult(interp);
my_snprintf(tclcmd, s, "tclpropeval {%s} {%s} {%s}", token, name, xctx->inst[inst].name);
tcleval(tclcmd);
fprintf(fd, "%s", tclresult());
my_free(1049, &tclcmd);
}
if(c!='%' && c!='@' && c!='\0' ) fputc(c,fd);
if(c == '@' || c == '%') s--;
state=TOK_BEGIN;
}
else if(state==TOK_BEGIN && c!='\0') fputc(c,fd);
if(c=='\0')
{
fputc('\n',fd);
fprintf(fd, "---- end primitive\n");
break ;
}
}
my_free(1050, &template);
my_free(1051, &format);
my_free(1052, &name);
my_free(1053, &token);
}
/* print verilog element if verilog_format is specified */
void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level primitives, 15112003 */
{
int i=0, multip, tmp;
const char *str_ptr;
register int c, state=TOK_BEGIN, space;
const char *lab;
char *template=NULL,*format=NULL,*s=NULL, *name=NULL, *token=NULL;
const char *value;
int sizetok=0;
int token_pos=0, escape=0;
int no_of_pins=0;
/* Inst_hashentry *ptr; */
my_strdup(519, &template,
(xctx->inst[inst].ptr + xctx->sym)->templ);
my_strdup(520, &name,xctx->inst[inst].instname);
if(!name) my_strdup(4, &name, get_tok_value(template, "name", 0));
/* allow format string override in instance */
my_strdup(1186, &format, get_tok_value(xctx->inst[inst].prop_ptr,"verilog_format",2));
if(!format || !format[0])
my_strdup(522, &format, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr,"verilog_format",2));
if((name==NULL) || (format==NULL) ) {
my_free(1054, &template);
my_free(1055, &name);
my_free(1056, &format);
return; /*do no netlist unwanted insts(no format) */
}
no_of_pins= (xctx->inst[inst].ptr + xctx->sym)->rects[PINLAYER];
s=format;
dbg(1, "print_verilog_primitive(): name=%s, format=%s xctx->netlist_count=%d\n",name,format, xctx->netlist_count);
fprintf(fd, "---- start primitive ");
lab=expandlabel(name, &tmp);
fprintf(fd, "%d\n",tmp);
/* begin parsing format string */
while(1)
{
c=*s++;
if(c=='\\') {
escape=1;
c=*s++;
}
else escape=0;
if(c=='\n' && escape ) c=*s++; /* 20171030 eat escaped newlines */
space=SPACE(c);
if( state==TOK_BEGIN && (c=='@' || c=='%') && !escape ) state=TOK_TOKEN;
else if(state==TOK_TOKEN && token_pos > 1 &&
(
( (space || c == '%' || c == '@') && !escape ) ||
( (!space && c != '%' && c != '@') && escape )
)
) {
state=TOK_SEP;
}
STR_ALLOC(&token, token_pos, &sizetok);
if(state==TOK_TOKEN) {
token[token_pos++]=c;
}
else if(state==TOK_SEP) /* got a token */
{
token[token_pos]='\0';
token_pos=0;
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
/* xctx->tok_size==0 indicates that token(+1) does not exist in instance attributes */
if(!xctx->tok_size)
value=get_tok_value(template, token+1, 0);
if(!xctx->tok_size && token[0] =='%') {
fputs(token + 1, fd);
} else if(value && value[0]!='\0') {
/* instance names (name) and node labels (lab) go thru the expandlabel function. */
/*if something else must be parsed, put an if here! */
if(!(strcmp(token+1,"name"))) {
if( (lab=expandlabel(value, &tmp)) != NULL)
fprintf(fd, "----name(%s)", lab);
else
fprintf(fd, "%s", value);
}
else if(!(strcmp(token+1,"lab"))) {
if( (lab=expandlabel(value, &tmp)) != NULL)
fprintf(fd, "----pin(%s)", lab);
else
fprintf(fd, "%s", value);
}
else fprintf(fd, "%s", value);
}
else if(strcmp(token,"@symname")==0) /* of course symname must not be present */
/* in hash table */
{
fprintf( fd, "%s",skip_dir(xctx->inst[inst]. name) );
}
else if (strcmp(token,"@symname_ext")==0)
{
fputs(get_cell_w_ext(xctx->inst[inst].name, 0), fd);
}
else if(strcmp(token,"@schname")==0) /* of course schname must not be present */
/* in hash table */
{
/* fputs(xctx->sch[xctx->currsch],fd); */
fputs(xctx->current_name, fd);
}
else if(strcmp(token,"@pinlist")==0) /* of course pinlist must not be present */
/* in hash table. print multiplicity */
{ /* and node number: m1 n1 m2 n2 .... */
for(i=0;i<no_of_pins;i++)
{
char *prop = (xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][i].prop_ptr;
if(strcmp(get_tok_value(prop, "verilog_ignore",0), "true")) {
str_ptr = net_name(inst,i, &multip, 0, 1);
fprintf(fd, "----pin(%s) ", str_ptr);
}
}
}
else if(token[0]=='@' && token[1]=='@') { /* recognize single pins 15112003 */
for(i=0;i<no_of_pins;i++) {
char *prop = (xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][i].prop_ptr;
if(!strcmp( get_tok_value(prop,"name",0), token+2)) {
if(strcmp(get_tok_value(prop, "verilog_ignore",0), "true")) {
str_ptr = net_name(inst,i, &multip, 0, 1);
fprintf(fd, "----pin(%s) ", str_ptr);
}
break;
}
}
}
/* reference by pin number instead of pin name, allows faster lookup of the attached net name 20180911 */
else if(token[0]=='@' && token[1]=='#') {
int pin_number = atoi(token+2);
if(pin_number < no_of_pins) {
const char *vi;
char *prop = (xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][pin_number].prop_ptr;
vi = get_tok_value(prop,"verilog_ignore",0);
if(strcmp(vi, "true")) {
str_ptr = net_name(inst,pin_number, &multip, 0, 1);
fprintf(fd, "----pin(%s) ", str_ptr);
}
}
}
else if(!strncmp(token,"@tcleval", 8)) {
/* char tclcmd[strlen(token)+100] ; */
size_t s;
char *tclcmd=NULL;
s = token_pos + strlen(name) + strlen(xctx->inst[inst].name) + 100;
tclcmd = my_malloc(524, s);
Tcl_ResetResult(interp);
my_snprintf(tclcmd, s, "tclpropeval {%s} {%s} {%s}", token, name, xctx->inst[inst].name);
tcleval(tclcmd);
fprintf(fd, "%s", tclresult());
my_free(1057, &tclcmd);
}
if(c!='%' && c!='@' && c!='\0') fputc(c,fd);
if(c == '@' || c == '%') s--;
state=TOK_BEGIN;
}
else if(state==TOK_BEGIN && c!='\0') fputc(c,fd);
if(c=='\0')
{
fputc('\n',fd);
fprintf(fd, "---- end primitive\n");
break ;
}
}
my_free(1058, &template);
my_free(1059, &format);
my_free(1060, &name);
my_free(1061, &token);
}
int isonlydigit(const char *s)
{
char c;

View File

@ -23,6 +23,56 @@
#include "xschem.h"
static Str_hashentry *subckt_table[HASHSIZE]; /* safe even with multiple schematics */
static void verilog_netlist(FILE *fd , int verilog_stop)
{
int i;
char *type=NULL;
if(!verilog_stop) {
xctx->prep_net_structs = 0;
prepare_netlist_structs(1);
dbg(2, "verilog_netlist(): end prepare_netlist_structs\n");
traverse_node_hash(); /* print all warnings about unconnected floatings etc */
dbg(2, "verilog_netlist(): end traverse_node_hash\n");
}
fprintf(fd,"---- begin signal list\n"); /* these are needed even if signal list empty */
if(!verilog_stop) print_verilog_signals(fd);
fprintf(fd,"---- end signal list\n"); /* these are needed even if signal list empty */
if(!verilog_stop)
{
for(i=0;i<xctx->instances;i++) /* ... print all element except ipin opin labels use package */
{
if( strcmp(get_tok_value(xctx->inst[i].prop_ptr,"verilog_ignore",0),"true")==0 ) continue;
if(xctx->inst[i].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "verilog_ignore",0 ), "true") ) {
continue;
}
dbg(2, "verilog_netlist(): into the netlisting loop\n");
my_strdup(570, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type &&
( !IS_LABEL_OR_PIN(type) &&
strcmp(type,"netlist_commands")&&
strcmp(type,"timescale")&&
strcmp(type,"verilog_preprocessor")
))
{
if(xctx->lastsel)
{
if(xctx->inst[i].sel==SELECTED) print_verilog_element(fd, i) ;
}
else print_verilog_element(fd, i) ; /* this is the element line */
}
}
my_free(1084, &type);
}
dbg(1, "verilog_netlist(): end\n");
if(!verilog_stop && !xctx->netlist_count) redraw_hilights(0); /*draw_hilight_net(1); */
}
void global_verilog_netlist(int global) /* netlister driver */
{
FILE *fd;
@ -513,52 +563,3 @@ void verilog_block_netlist(FILE *fd, int i)
my_free(1083, &tmp_string);
}
void verilog_netlist(FILE *fd , int verilog_stop)
{
int i;
char *type=NULL;
if(!verilog_stop) {
xctx->prep_net_structs = 0;
prepare_netlist_structs(1);
dbg(2, "verilog_netlist(): end prepare_netlist_structs\n");
traverse_node_hash(); /* print all warnings about unconnected floatings etc */
dbg(2, "verilog_netlist(): end traverse_node_hash\n");
}
fprintf(fd,"---- begin signal list\n"); /* these are needed even if signal list empty */
if(!verilog_stop) print_verilog_signals(fd);
fprintf(fd,"---- end signal list\n"); /* these are needed even if signal list empty */
if(!verilog_stop)
{
for(i=0;i<xctx->instances;i++) /* ... print all element except ipin opin labels use package */
{
if( strcmp(get_tok_value(xctx->inst[i].prop_ptr,"verilog_ignore",0),"true")==0 ) continue;
if(xctx->inst[i].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "verilog_ignore",0 ), "true") ) {
continue;
}
dbg(2, "verilog_netlist(): into the netlisting loop\n");
my_strdup(570, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type &&
( !IS_LABEL_OR_PIN(type) &&
strcmp(type,"netlist_commands")&&
strcmp(type,"timescale")&&
strcmp(type,"verilog_preprocessor")
))
{
if(xctx->lastsel)
{
if(xctx->inst[i].sel==SELECTED) print_verilog_element(fd, i) ;
}
else print_verilog_element(fd, i) ; /* this is the element line */
}
}
my_free(1084, &type);
}
dbg(1, "verilog_netlist(): end\n");
if(!verilog_stop && !xctx->netlist_count) redraw_hilights(0); /*draw_hilight_net(1); */
}

View File

@ -24,6 +24,94 @@
static Str_hashentry *subckt_table[HASHSIZE]; /* safe even with multiple schematics */
static void vhdl_netlist(FILE *fd , int vhdl_stop)
{
int i,l;
char *type=NULL;
/* set_modify(1); */ /* 20160302 prepare_netlist_structs could change schematic (wire node naming for example) */
if(!vhdl_stop) {
xctx->prep_net_structs = 0;
prepare_netlist_structs(1);
traverse_node_hash(); /* print all warnings about unconnected floatings etc */
}
dbg(1, "vhdl_netlist(): architecture declarations\n");
fprintf(fd, "//// begin user declarations\n");
for(l=0;l<xctx->instances;l++)
{
if( strcmp(get_tok_value(xctx->inst[l].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue;
if(!(xctx->inst[l].ptr+ xctx->sym)->type) continue;
if(xctx->inst[l].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[l].ptr+ xctx->sym)->prop_ptr, "vhdl_ignore",0 ), "true") ) {
continue;
}
if(!strcmp((xctx->inst[l].ptr+ xctx->sym)->type, "arch_declarations") )
fprintf(fd, "%s\n", xctx->inst[l].prop_ptr? xctx->inst[l].prop_ptr: "");
}
fprintf(fd, "//// end user declarations\n");
dbg(1, "vhdl_netlist(): print erc checks\n");
if(!vhdl_stop) print_vhdl_signals(fd);
dbg(1, "vhdl_netlist(): done print erc checks\n");
dbg(1, "vhdl_netlist(): attributes\n");
fprintf(fd, "//// begin user attributes\n");
for(l=0;l<xctx->instances;l++)
{
if( strcmp(get_tok_value(xctx->inst[l].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue;
if(xctx->inst[l].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[l].ptr+ xctx->sym)->prop_ptr, "vhdl_ignore",0 ), "true") ) {
continue;
}
my_strdup(602, &type,(xctx->inst[l].ptr+ xctx->sym)->type);
if( type && (strcmp(type,"attributes"))==0)
{
if(xctx->inst[l].prop_ptr) fprintf(fd, "\n%s\n", xctx->inst[l].prop_ptr);
}
}
fprintf(fd, "//// end user attributes\n");
fprintf(fd, "begin\n"); /* begin reintroduced 09122003 */
if(!vhdl_stop)
{
for(i=0;i<xctx->instances;i++) /* ... print all element except ipin opin labels use package */
{ /* dont print elements with vhdl_ignore=true set in symbol */
if( strcmp(get_tok_value(xctx->inst[i].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue;
if(xctx->inst[i].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "vhdl_ignore",0 ), "true") ) {
continue;
}
dbg(2, "vhdl_netlist(): into the netlisting loop\n");
my_strdup(603, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type &&
( !IS_LABEL_OR_PIN(type) &&
strcmp(type,"generic")&&
strcmp(type,"use")&&
strcmp(type,"netlist_commands")&&
strcmp(type,"package") &&
strcmp(type,"attributes") &&
strcmp(type,"port_attributes") &&
strcmp(type,"arch_declarations")
))
{
if(xctx->lastsel)
{
if(xctx->inst[i].sel==SELECTED) {
print_vhdl_element(fd, i) ;
}
} else {
print_vhdl_element(fd, i) ;
}
}
}
my_free(1097, &type);
}
dbg(1, "vhdl_netlist(): end\n");
if(!vhdl_stop && !xctx->netlist_count) redraw_hilights(0); /* draw_hilight_net(1); */
}
void global_vhdl_netlist(int global) /* netlister driver */
{
FILE *fd;
@ -633,90 +721,3 @@ void vhdl_block_netlist(FILE *fd, int i)
my_free(1096, &type);
}
void vhdl_netlist(FILE *fd , int vhdl_stop)
{
int i,l;
char *type=NULL;
/* set_modify(1); */ /* 20160302 prepare_netlist_structs could change schematic (wire node naming for example) */
if(!vhdl_stop) {
xctx->prep_net_structs = 0;
prepare_netlist_structs(1);
traverse_node_hash(); /* print all warnings about unconnected floatings etc */
}
dbg(1, "vhdl_netlist(): architecture declarations\n");
fprintf(fd, "//// begin user declarations\n");
for(l=0;l<xctx->instances;l++)
{
if( strcmp(get_tok_value(xctx->inst[l].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue;
if(!(xctx->inst[l].ptr+ xctx->sym)->type) continue;
if(xctx->inst[l].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[l].ptr+ xctx->sym)->prop_ptr, "vhdl_ignore",0 ), "true") ) {
continue;
}
if(!strcmp((xctx->inst[l].ptr+ xctx->sym)->type, "arch_declarations") )
fprintf(fd, "%s\n", xctx->inst[l].prop_ptr? xctx->inst[l].prop_ptr: "");
}
fprintf(fd, "//// end user declarations\n");
dbg(1, "vhdl_netlist(): print erc checks\n");
if(!vhdl_stop) print_vhdl_signals(fd);
dbg(1, "vhdl_netlist(): done print erc checks\n");
dbg(1, "vhdl_netlist(): attributes\n");
fprintf(fd, "//// begin user attributes\n");
for(l=0;l<xctx->instances;l++)
{
if( strcmp(get_tok_value(xctx->inst[l].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue;
if(xctx->inst[l].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[l].ptr+ xctx->sym)->prop_ptr, "vhdl_ignore",0 ), "true") ) {
continue;
}
my_strdup(602, &type,(xctx->inst[l].ptr+ xctx->sym)->type);
if( type && (strcmp(type,"attributes"))==0)
{
if(xctx->inst[l].prop_ptr) fprintf(fd, "\n%s\n", xctx->inst[l].prop_ptr);
}
}
fprintf(fd, "//// end user attributes\n");
fprintf(fd, "begin\n"); /* begin reintroduced 09122003 */
if(!vhdl_stop)
{
for(i=0;i<xctx->instances;i++) /* ... print all element except ipin opin labels use package */
{ /* dont print elements with vhdl_ignore=true set in symbol */
if( strcmp(get_tok_value(xctx->inst[i].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue;
if(xctx->inst[i].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "vhdl_ignore",0 ), "true") ) {
continue;
}
dbg(2, "vhdl_netlist(): into the netlisting loop\n");
my_strdup(603, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type &&
( !IS_LABEL_OR_PIN(type) &&
strcmp(type,"generic")&&
strcmp(type,"use")&&
strcmp(type,"netlist_commands")&&
strcmp(type,"package") &&
strcmp(type,"attributes") &&
strcmp(type,"port_attributes") &&
strcmp(type,"arch_declarations")
))
{
if(xctx->lastsel)
{
if(xctx->inst[i].sel==SELECTED) {
print_vhdl_element(fd, i) ;
}
} else {
print_vhdl_element(fd, i) ;
}
}
}
my_free(1097, &type);
}
dbg(1, "vhdl_netlist(): end\n");
if(!vhdl_stop && !xctx->netlist_count) redraw_hilights(0); /* draw_hilight_net(1); */
}

View File

@ -78,7 +78,7 @@ static int client_msg(Display *disp, Window win, char *msg, /* {{{ */
}/*}}}*/
int window_state (Display *disp, Window win, char *arg) {/*{{{*/
static int window_state (Display *disp, Window win, char *arg) {/*{{{*/
char arg_copy[256]; /* overflow safe */
unsigned long action;
int i;
@ -198,7 +198,7 @@ void windowid(const char *winpath)
Tcl_SetResult(interp,"",TCL_STATIC);
}
int err(Display *display, XErrorEvent *xev)
static int err(Display *display, XErrorEvent *xev)
{
char s[1024]; /* overflow safe 20161122 */
int l=250;
@ -210,7 +210,7 @@ int err(Display *display, XErrorEvent *xev)
return 0;
}
unsigned int find_best_color(char colorname[])
static unsigned int find_best_color(char colorname[])
{
int i;
double distance=10000000000.0, dist, r, g, b, red, green, blue;
@ -291,7 +291,7 @@ static void init_color_array(double dim, double dim_bg)
}
}
void init_pixdata()/* populate xctx->fill_type array that is used in create_gc() to set fill styles */
static void init_pixdata()/* populate xctx->fill_type array that is used in create_gc() to set fill styles */
{
int i,j, full, empty;
for(i=0;i<cadlayers;i++) {
@ -374,7 +374,7 @@ static void free_xschem_data()
my_free(269, &xctx);
}
void create_gc(void)
static void create_gc(void)
{
int i;
for(i=0;i<cadlayers;i++)
@ -388,7 +388,7 @@ void create_gc(void)
}
}
void free_gc()
static void free_gc()
{
int i;
for(i=0;i<cadlayers;i++) {
@ -619,7 +619,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path)
xctx->time_last_modify = 0;
}
void delete_schematic_data(void)
static void delete_schematic_data(void)
{
dbg(1, "delete_schematic_data()\n");
unselect_all();
@ -642,7 +642,7 @@ void delete_schematic_data(void)
free_xschem_data(); /* delete the xctx struct */
}
void xwin_exit(void)
static void xwin_exit(void)
{
int i;
@ -889,13 +889,13 @@ void toggle_fullscreen(const char *topwin)
}
void tclexit(ClientData s)
static void tclexit(ClientData s)
{
dbg(1, "tclexit() INVOKED\n");
if(init_done) xwin_exit();
}
int source_tcl_file(char *s)
static int source_tcl_file(char *s)
{
char tmp[1024];
if(Tcl_EvalFile(interp, s)==TCL_ERROR) {
@ -1513,7 +1513,7 @@ void change_linewidth(double w)
/* clears and creates cairo_sfc, cairo_ctx, cairo_save_sfc, cairo_save_ctx
* and sets some graphical attributes */
void resetcairo(int create, int clear, int force_or_resize)
static void resetcairo(int create, int clear, int force_or_resize)
{
#if HAS_CAIRO==1
dbg(1, "resetcairo() %d, %d, %d\n", create, clear, force_or_resize);

View File

@ -1033,7 +1033,6 @@ extern int calc_custom_data_yrange(int sweep_idx, const char *express, Graph_ctx
extern int schematic_waves_loaded(void);
extern int edit_wave_attributes(int what, int i, Graph_ctx *gr);
extern void draw_graph(int i, int flags, Graph_ctx *gr);
extern void draw_graph_all(int flags);
extern void setup_graph_data(int i, const int flags, int skip, Graph_ctx *gr);
extern double timer(int start);
extern void enable_layers(void);
@ -1054,7 +1053,6 @@ extern void schematic_in_new_window(void);
extern void symbol_in_new_window(void);
extern void new_xschem_process(const char *cell, int symbol);
extern void ask_new_file(void);
extern int samefile(const char *fa, const char *fb);
extern void saveas(const char *f, int type);
extern const char *get_file_path(char *f);
extern int save(int confirm);
@ -1065,7 +1063,6 @@ extern int name_strcmp(char *s, char *d) ;
extern int search(const char *tok, const char *val, int sub, int sel);
extern int process_options(int argc, char **argv);
extern void calc_drawing_bbox(xRect *boundbox, int selected);
extern void create_ps(char **psfile, int what);
extern int ps_draw(int what);
extern void svg_draw(void);
extern void set_viewport_size(int w, int h, double lw);
@ -1078,7 +1075,6 @@ extern const char *rel_sym_path(const char *s);
extern const char *abs_sym_path(const char *s, const char *ext);
extern const char *add_ext(const char *f, const char *ext);
extern void make_symbol(void);
extern void make_schematic(const char *schname);
extern void make_schematic_symbol_from_sel(void);
extern const char *get_sym_template(char *s, char *extra);
/* bit0: invoke change_linewidth(), bit1: centered zoom */
@ -1103,7 +1099,6 @@ extern void hash_inst(int what, int n);
extern void del_inst_table(void);
extern void hash_wires(void);
extern void hash_wire(int what, int n, int incremental);
extern void wirecheck(int k);
extern void hash_instances(void); /* 20171203 insert instance bbox in spatial hash table */
#if HAS_CAIRO==1
@ -1117,20 +1112,10 @@ extern unsigned short select_object(double mx,double my, unsigned short sel_mode
int override_lock); /* return type 20160503 */
extern void unselect_all(void);
extern void select_inside(double x1,double y1, double x2, double y2, int sel);
extern void xwin_exit(void);
extern void resetcairo(int create, int clear, int force_or_resize);
extern int Tcl_AppInit(Tcl_Interp *interp);
extern int source_tcl_file(char *s);
extern int callback(const char *winpath, int event, int mx, int my, KeySym key,
int button, int aux, int state);
extern void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h);
extern void find_closest_net(double mx,double my);
extern void find_closest_box(double mx,double my);
extern void find_closest_arc(double mx,double my);
extern void find_closest_element(double mx,double my);
extern void find_closest_line(double mx,double my);
extern void find_closest_polygon(double mx,double my);
extern void find_closest_text(double mx,double my);
extern Selected find_closest_obj(double mx,double my);
extern void find_closest_net_or_symbol_pin(double mx,double my, double *x, double *y);
@ -1146,7 +1131,6 @@ extern void filledrect(int c, int what, double rectx1,double recty1,
extern void drawtempline(GC gc, int what, double x1,double y1,double x2,double y2);
extern void drawgrid(void);
extern void drawtemprect(GC gc, int what, double rectx1,double recty1,
double rectx2,double recty2);
extern void drawtemparc(GC gc, int what, double x, double y, double r, double a, double b);
@ -1160,7 +1144,6 @@ extern void draw_temp_string(GC gc,int what, const char *str, short rot, short f
double x1, double y1, double xscale, double yscale);
extern void draw(void);
extern short clip_to_short(double n);
extern void clip_xy_to_short(double x, double y, short *sx, short *sy);
extern int clip( double*,double*,double*,double*);
extern int textclip(int x1,int y1,int x2,int y2,
@ -1191,19 +1174,13 @@ extern void store_arc(int pos, double x, double y, double r, double a, double b,
unsigned int rectcolor, unsigned short sel, char *prop_ptr);
extern void hier_psprint(void);
extern void freenet_nocheck(int i);
extern void spice_netlist(FILE *fd, int spice_stop);
extern void tedax_netlist(FILE *fd, int spice_stop);
extern void global_spice_netlist(int global);
extern void global_tedax_netlist(int global);
extern void vhdl_netlist(FILE *fd, int vhdl_stop);
extern void global_vhdl_netlist(int global);
extern void verilog_netlist(FILE *fd, int verilog_stop);
extern void global_verilog_netlist(int global);
extern void vhdl_block_netlist(FILE *fd, int i);
extern void verilog_block_netlist(FILE *fd, int i);
extern void spice_block_netlist(FILE *fd, int i);
extern void tedax_block_netlist(FILE *fd, int i);
extern void remove_symbols(void);
extern void remove_symbol(int i);
extern void clear_drawing(void);
@ -1231,7 +1208,6 @@ extern void load_schematic(int load_symbol, const char *abs_name, int reset_undo
extern int check_loaded(const char *f, char *win_path);
extern void link_symbols_to_instances(int from);
extern void load_ascii_string(char **ptr, FILE *fd);
extern void read_xschem_file(FILE *fd);
extern char *read_line(FILE *fp, int dbg_level);
extern void read_record(int firstchar, FILE *fp, int dbg_level);
extern void create_sch_from_sym(void);
@ -1303,8 +1279,6 @@ extern void print_spice_subckt(FILE *fd, int symbol);
extern void print_tedax_subckt(FILE *fd, int symbol);
extern void print_vhdl_element(FILE *fd, int inst);
extern void print_verilog_element(FILE *fd, int inst);
extern void print_verilog_primitive(FILE *fd, int inst);
extern void print_vhdl_primitive(FILE *fd, int inst);
extern const char *get_tok_value(const char *s,const char *tok,int with_quotes);
extern const char *list_tokens(const char *s, int with_quotes);
extern int my_snprintf(char *str, int size, const char *fmt, ...);
@ -1387,7 +1361,6 @@ extern void display_hilights(char **str);
extern void redraw_hilights(int clear);
extern void set_tcl_netlist_type(void);
extern void prepare_netlist_structs(int for_netlist);
extern void create_simdata(void);
extern void free_simdata(void);
extern void delete_netlist_structs(void);
extern void delete_inst_node(int i);
@ -1405,23 +1378,17 @@ extern void launcher();
extern void windowid(const char *winpath);
extern void preview_window(const char *what, const char *tk_win_path, const char *fname);
extern int new_schematic(const char *what, const char *win_path, const char *fname);
extern int window_state (Display *disp, Window win, char *arg);
extern void toggle_fullscreen(const char *topwin);
extern void toggle_only_probes();
extern void update_symbol(const char *result, int x);
extern void tclexit(ClientData s);
extern int build_colors(double dim, double dim_bg); /* reparse the TCL 'colors' list and reassign colors 20171113 */
extern void set_clip_mask(int what);
#ifdef __unix__
extern int pending_events(void);
#endif
extern void drill_hilight(int mode);
extern void get_square(double x, double y, int *xx, int *yy);
extern void del_wire_table(void);
extern void del_object_table(void);
extern const char *random_string(const char *prefix);
extern const char *create_tmpdir(char *prefix);
extern FILE *open_tmpfile(char *prefix, char **filename);
extern void child_handler(int signum);
#endif /*CADGLOBALS */