instance based schematic selection: if instance specified schematic=... not existing use base schematic (symbolname.sch)
This commit is contained in:
parent
7639d65dc5
commit
c06a896d4f
|
|
@ -217,7 +217,7 @@ void print_version()
|
||||||
printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
char *escape_chars(const char *source)
|
char *escape_chars(const char *source, const char *charset)
|
||||||
{
|
{
|
||||||
int s=0;
|
int s=0;
|
||||||
int d=0;
|
int d=0;
|
||||||
|
|
@ -236,32 +236,41 @@ char *escape_chars(const char *source)
|
||||||
size += 2;
|
size += 2;
|
||||||
my_realloc(_ALLOC_ID_, &dest, size);
|
my_realloc(_ALLOC_ID_, &dest, size);
|
||||||
}
|
}
|
||||||
switch(source[s]) {
|
if(!strcmp(charset, "")) {
|
||||||
case '\n':
|
switch(source[s]) {
|
||||||
dest[d++] = '\\';
|
case '\n':
|
||||||
dest[d++] = 'n';
|
dest[d++] = '\\';
|
||||||
break;
|
dest[d++] = 'n';
|
||||||
case '\t':
|
break;
|
||||||
dest[d++] = '\\';
|
case '\t':
|
||||||
dest[d++] = 't';
|
dest[d++] = '\\';
|
||||||
break;
|
dest[d++] = 't';
|
||||||
case '\\':
|
break;
|
||||||
case '\'':
|
case '\\':
|
||||||
case ' ':
|
case '\'':
|
||||||
case ';':
|
case ' ':
|
||||||
case '$':
|
case ';':
|
||||||
case '!':
|
case '$':
|
||||||
case '#':
|
case '!':
|
||||||
case '{':
|
case '#':
|
||||||
case '}':
|
case '{':
|
||||||
case '[':
|
case '}':
|
||||||
case ']':
|
case '[':
|
||||||
case '"':
|
case ']':
|
||||||
|
case '"':
|
||||||
|
dest[d++] = '\\';
|
||||||
|
dest[d++] = source[s];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dest[d++] = source[s];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(strchr(charset, source[s])) {
|
||||||
dest[d++] = '\\';
|
dest[d++] = '\\';
|
||||||
dest[d++] = source[s];
|
dest[d++] = source[s];
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
dest[d++] = source[s];
|
dest[d++] = source[s];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
|
@ -1850,6 +1859,7 @@ void get_additional_symbols(int what)
|
||||||
static int num_syms; /* no context switch between start and end so it is safe */
|
static int num_syms; /* no context switch between start and end so it is safe */
|
||||||
Int_hashentry *found;
|
Int_hashentry *found;
|
||||||
Int_hashtable sym_table = {NULL, 0};
|
Int_hashtable sym_table = {NULL, 0};
|
||||||
|
struct stat buf;
|
||||||
|
|
||||||
if(what == 1) { /* start */
|
if(what == 1) { /* start */
|
||||||
int_hash_init(&sym_table, HASHSIZE);
|
int_hash_init(&sym_table, HASHSIZE);
|
||||||
|
|
@ -1864,6 +1874,7 @@ void get_additional_symbols(int what)
|
||||||
char *verilog_sym_def = NULL;
|
char *verilog_sym_def = NULL;
|
||||||
char *default_schematic = NULL;
|
char *default_schematic = NULL;
|
||||||
char *sch = NULL;
|
char *sch = NULL;
|
||||||
|
char symbol_base_sch[PATH_MAX] = "";
|
||||||
|
|
||||||
/* copy instance based *_sym_def attributes to symbol */
|
/* copy instance based *_sym_def attributes to symbol */
|
||||||
my_strdup(_ALLOC_ID_, &spice_sym_def, get_tok_value(xctx->inst[i].prop_ptr,"spice_sym_def",0));
|
my_strdup(_ALLOC_ID_, &spice_sym_def, get_tok_value(xctx->inst[i].prop_ptr,"spice_sym_def",0));
|
||||||
|
|
@ -1873,6 +1884,11 @@ void get_additional_symbols(int what)
|
||||||
str_replace( get_tok_value(xctx->inst[i].prop_ptr,"schematic",2), "@symname",
|
str_replace( get_tok_value(xctx->inst[i].prop_ptr,"schematic",2), "@symname",
|
||||||
get_cell(xctx->inst[i].name, 0), '\\')));
|
get_cell(xctx->inst[i].name, 0), '\\')));
|
||||||
dbg(1, "get_additional_symbols(): sch=%s\n", sch);
|
dbg(1, "get_additional_symbols(): sch=%s\n", sch);
|
||||||
|
if(sch[0] && stat(abs_sym_path(sch, ""), &buf)) {/* schematic does not exist */
|
||||||
|
my_snprintf(symbol_base_sch, PATH_MAX, "%s.sch", get_cell(xctx->sym[xctx->inst[i].ptr].name, 9999));
|
||||||
|
dbg(1, "get_additional_symbols(): schematic not existing\n");
|
||||||
|
dbg(1, "using: %s\n", symbol_base_sch);
|
||||||
|
}
|
||||||
if(xctx->tok_size && xctx->inst[i].ptr>= 0) { /* token exists and instance points to valid symbol */
|
if(xctx->tok_size && xctx->inst[i].ptr>= 0) { /* token exists and instance points to valid symbol */
|
||||||
int j;
|
int j;
|
||||||
char *sym = NULL;
|
char *sym = NULL;
|
||||||
|
|
@ -1900,12 +1916,18 @@ void get_additional_symbols(int what)
|
||||||
copy_symbol(&xctx->sym[j], symptr);
|
copy_symbol(&xctx->sym[j], symptr);
|
||||||
xctx->sym[j].base_name = symptr->name;
|
xctx->sym[j].base_name = symptr->name;
|
||||||
my_strdup(_ALLOC_ID_, &xctx->sym[j].name, sym);
|
my_strdup(_ALLOC_ID_, &xctx->sym[j].name, sym);
|
||||||
|
|
||||||
/* the copied symbol will not inherit the default_schematic attribute otherwise it will also
|
/* the copied symbol will not inherit the default_schematic attribute otherwise it will also
|
||||||
* be skipped */
|
* be skipped */
|
||||||
if(default_schematic) {
|
if(default_schematic) {
|
||||||
my_strdup(_ALLOC_ID_, &xctx->sym[j].prop_ptr,
|
my_strdup(_ALLOC_ID_, &xctx->sym[j].prop_ptr,
|
||||||
subst_token(xctx->sym[j].prop_ptr, "default_schematic", NULL)); /* delete attribute */
|
subst_token(xctx->sym[j].prop_ptr, "default_schematic", NULL)); /* delete attribute */
|
||||||
}
|
}
|
||||||
|
/* if symbol has no corresponding schematic file use symbol base schematic */
|
||||||
|
if(symbol_base_sch[0]) {
|
||||||
|
my_strdup(_ALLOC_ID_, &xctx->sym[j].prop_ptr,
|
||||||
|
subst_token(xctx->sym[j].prop_ptr, "schematic", symbol_base_sch));
|
||||||
|
}
|
||||||
if(spice_sym_def) {
|
if(spice_sym_def) {
|
||||||
my_strdup(_ALLOC_ID_, &xctx->sym[j].prop_ptr,
|
my_strdup(_ALLOC_ID_, &xctx->sym[j].prop_ptr,
|
||||||
subst_token(xctx->sym[j].prop_ptr, "spice_sym_def", spice_sym_def));
|
subst_token(xctx->sym[j].prop_ptr, "spice_sym_def", spice_sym_def));
|
||||||
|
|
|
||||||
|
|
@ -795,12 +795,15 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
||||||
Tcl_ResetResult(interp);
|
Tcl_ResetResult(interp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* escape_chars source
|
/* escape_chars source [charset]
|
||||||
* escape tcl special characters with backslash */
|
* escape tcl special characters with backslash
|
||||||
|
* if charset is given escape characters in charset */
|
||||||
else if(!strcmp(argv[1], "escape_chars"))
|
else if(!strcmp(argv[1], "escape_chars"))
|
||||||
{
|
{
|
||||||
if(argc > 2) {
|
if(argc > 3) {
|
||||||
Tcl_SetResult(interp, escape_chars(argv[2]), TCL_VOLATILE);
|
Tcl_SetResult(interp, escape_chars(argv[2], argv[3]), TCL_VOLATILE);
|
||||||
|
} else if(argc > 2) {
|
||||||
|
Tcl_SetResult(interp, escape_chars(argv[2], ""), TCL_VOLATILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2163,6 +2163,9 @@ int print_spice_element(FILE *fd, int inst)
|
||||||
/* Symbol format string contains model=@modp,
|
/* Symbol format string contains model=@modp,
|
||||||
* instance attributes does not contain a modp=xxx,
|
* instance attributes does not contain a modp=xxx,
|
||||||
* look up modp in **parent** symbol template attribute */
|
* look up modp in **parent** symbol template attribute */
|
||||||
|
dbg(1, "model: instance=%s ,val=%s, tok=%s, value=%s template=%s\n",
|
||||||
|
xctx->inst[inst].instname,
|
||||||
|
val, token, value, xctx->hier_attr[xctx->currsch - 1].templ);
|
||||||
if(value[0] == '\0') {
|
if(value[0] == '\0') {
|
||||||
value=get_tok_value(xctx->hier_attr[xctx->currsch - 1].templ, val+1, 0);
|
value=get_tok_value(xctx->hier_attr[xctx->currsch - 1].templ, val+1, 0);
|
||||||
}
|
}
|
||||||
|
|
@ -2170,7 +2173,7 @@ int print_spice_element(FILE *fd, int inst)
|
||||||
else if(val[0] == '@' && !strpbrk(value + 1, "@ ")) {
|
else if(val[0] == '@' && !strpbrk(value + 1, "@ ")) {
|
||||||
/* value = translate(inst, val); */
|
/* value = translate(inst, val); */
|
||||||
value = get_tok_value(xctx->inst[inst].prop_ptr, val + 1, 0);
|
value = get_tok_value(xctx->inst[inst].prop_ptr, val + 1, 0);
|
||||||
dbg(1, "val=%s, tok=%s, value=%s template=%s\n",
|
dbg(1, "val=%s, tok=%s, value=%s template=%s",
|
||||||
val, token, value, xctx->hier_attr[xctx->currsch - 1].templ);
|
val, token, value, xctx->hier_attr[xctx->currsch - 1].templ);
|
||||||
if(value[0] == '\0') {
|
if(value[0] == '\0') {
|
||||||
value=get_tok_value(xctx->hier_attr[xctx->currsch - 1].templ, val+1, 0);
|
value=get_tok_value(xctx->hier_attr[xctx->currsch - 1].templ, val+1, 0);
|
||||||
|
|
|
||||||
|
|
@ -708,7 +708,7 @@ static void delete_schematic_data(int delete_pixmap)
|
||||||
* inst & wire .node fields, instance name hash */
|
* inst & wire .node fields, instance name hash */
|
||||||
remove_symbols();
|
remove_symbols();
|
||||||
str_replace(NULL, NULL, NULL, 0);
|
str_replace(NULL, NULL, NULL, 0);
|
||||||
escape_chars(NULL);
|
escape_chars(NULL, "");
|
||||||
sanitize(NULL);
|
sanitize(NULL);
|
||||||
is_generator(NULL);
|
is_generator(NULL);
|
||||||
extra_rawfile(3, NULL, NULL, -1.0, -1.0);
|
extra_rawfile(3, NULL, NULL, -1.0, -1.0);
|
||||||
|
|
|
||||||
|
|
@ -1607,8 +1607,6 @@ extern void hash_name(char *token, int remove);
|
||||||
extern void hash_names(int inst, int action); /* if i == -1 hash all instances, else do only inst */
|
extern void hash_names(int inst, int action); /* if i == -1 hash all instances, else do only inst */
|
||||||
extern void floater_hash_all_names(void);
|
extern void floater_hash_all_names(void);
|
||||||
extern void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2);
|
extern void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2);
|
||||||
/* extern char *escape_chars(char *dest, const char *source, int size); */
|
|
||||||
|
|
||||||
extern void set_inst_prop(int i);
|
extern void set_inst_prop(int i);
|
||||||
extern void unselect_wire(int i);
|
extern void unselect_wire(int i);
|
||||||
extern void select_hilight_net(void);
|
extern void select_hilight_net(void);
|
||||||
|
|
@ -1679,7 +1677,7 @@ extern void change_elem_order(int n);
|
||||||
extern int is_generator(const char *name);
|
extern int is_generator(const char *name);
|
||||||
extern char *str_chars_replace(const char *str, const char *replace_set, const char with);
|
extern char *str_chars_replace(const char *str, const char *replace_set, const char with);
|
||||||
extern char *str_replace(const char *str, const char *rep, const char *with, int escape);
|
extern char *str_replace(const char *str, const char *rep, const char *with, int escape);
|
||||||
extern char *escape_chars(const char *source);
|
extern char *escape_chars(const char *source, const char *charset);
|
||||||
extern int set_different_token(char **s,const char *new, const char *old);
|
extern int set_different_token(char **s,const char *new, const char *old);
|
||||||
extern void print_hilight_net(int show);
|
extern void print_hilight_net(int show);
|
||||||
extern void list_hilights(void);
|
extern void list_hilights(void);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue