add base_name field in xSymbol struct to keep track of the base symbol name the "virtual" symbol is inherited from (instance based implementation selection with schematic=... attribute)

This commit is contained in:
stefan schippers 2023-04-13 22:25:36 +02:00
parent 7537cdef45
commit 340b89c58d
9 changed files with 19 additions and 101 deletions

View File

@ -75,7 +75,7 @@ p{padding: 15px 30px 10px;}
</p>
<ul>
<li><kbd>x1</kbd> is the standard instance using the default <kbd>comp_65nm.sch</kbd></li>
<li><kbd>x2</kbd> is a simplified instance that hust keeps the output low.</li>
<li><kbd>x2</kbd> is a simplified instance that just keeps the output low.</li>
<li><kbd>x3</kbd> uses a parasitic extraction netlist (output will move slower).</li>
</ul>
<p>
@ -84,7 +84,7 @@ p{padding: 15px 30px 10px;}
<img src="instance_based_implementation_04.png">
<p class="important">
Note: when creating alternate alternate netlist files ensure the port order is identical to the base
Note: when creating alternate netlist files ensure the port order is identical to the base
circuit. The assumption for all alternate circuits created using the methods explained above is that the
alternate circuits have all the same interface as the base circuit (same input, output, inout pins, in the same order).
</p><br><br>

View File

@ -1235,6 +1235,7 @@ void get_additional_symbols(int what)
dbg(1, "get_additional_symbols(): adding symbol %s\n", sym);
check_symbol_storage();
copy_symbol(&xctx->sym[j], xctx->inst[i].ptr + xctx->sym);
xctx->sym[j].base_name = (xctx->inst[i].ptr + xctx->sym)->name;
my_strdup(_ALLOC_ID_, &xctx->sym[j].name, sym);
if(spice_sym_def)

View File

@ -256,6 +256,7 @@ void copy_symbol(xSymbol *dest_sym, xSymbol *src_sym)
int c, j;
*dest_sym = *src_sym;
dest_sym->name = NULL;
dest_sym->base_name = NULL;
dest_sym->prop_ptr = NULL;
dest_sym->type = NULL;
dest_sym->templ = NULL;
@ -456,8 +457,6 @@ void mem_push_undo(void)
void mem_pop_undo(int redo, int set_modify_status)
{
int slot, i, c;
xSymbol *sym;
int j;
if(xctx->no_undo)return;
if(redo == 1) {
@ -581,81 +580,7 @@ void mem_pop_undo(int redo, int set_modify_status)
xctx->sym = my_calloc(_ALLOC_ID_, xctx->symbols, sizeof(xSymbol));
for(i = 0;i<xctx->symbols; ++i) {
sym = &xctx->uslot[slot].symptr[i];
xctx->sym[i] = *sym;
xctx->sym[i].name = NULL;
xctx->sym[i].prop_ptr = NULL;
xctx->sym[i].type = NULL;
xctx->sym[i].templ = NULL;
my_strdup2(_ALLOC_ID_, &xctx->sym[i].name, sym->name);
my_strdup2(_ALLOC_ID_, &xctx->sym[i].type, sym->type);
my_strdup2(_ALLOC_ID_, &xctx->sym[i].templ, sym->templ);
my_strdup2(_ALLOC_ID_, &xctx->sym[i].prop_ptr, sym->prop_ptr);
xctx->sym[i].line = my_calloc(_ALLOC_ID_, cadlayers, sizeof(xLine *));
xctx->sym[i].poly = my_calloc(_ALLOC_ID_, cadlayers, sizeof(xPoly *));
xctx->sym[i].arc = my_calloc(_ALLOC_ID_, cadlayers, sizeof(xArc *));
xctx->sym[i].rect = my_calloc(_ALLOC_ID_, cadlayers, sizeof(xRect *));
xctx->sym[i].lines = my_calloc(_ALLOC_ID_, cadlayers, sizeof(int));
xctx->sym[i].rects = my_calloc(_ALLOC_ID_, cadlayers, sizeof(int));
xctx->sym[i].arcs = my_calloc(_ALLOC_ID_, cadlayers, sizeof(int));
xctx->sym[i].polygons = my_calloc(_ALLOC_ID_, cadlayers, sizeof(int));
xctx->sym[i].text = my_calloc(_ALLOC_ID_, xctx->sym[i].texts, sizeof(xText));
memcpy(xctx->sym[i].lines, sym->lines, sizeof(sym->lines[0]) * cadlayers);
memcpy(xctx->sym[i].rects, sym->rects, sizeof(sym->rects[0]) * cadlayers);
memcpy(xctx->sym[i].arcs, sym->arcs, sizeof(sym->arcs[0]) * cadlayers);
memcpy(xctx->sym[i].polygons, sym->polygons, sizeof(sym->polygons[0]) * cadlayers);
for(c = 0;c<cadlayers; ++c) {
/* symbol lines */
xctx->sym[i].line[c] = my_calloc(_ALLOC_ID_, sym->lines[c], sizeof(xLine));
for(j = 0; j < xctx->sym[i].lines[c]; ++j) {
xctx->sym[i].line[c][j] = sym->line[c][j];
xctx->sym[i].line[c][j].prop_ptr = NULL;
my_strdup(_ALLOC_ID_, & xctx->sym[i].line[c][j].prop_ptr, sym->line[c][j].prop_ptr);
}
/* symbol rects */
xctx->sym[i].rect[c] = my_calloc(_ALLOC_ID_, sym->rects[c], sizeof(xRect));
for(j = 0; j < xctx->sym[i].rects[c]; ++j) {
xctx->sym[i].rect[c][j] = sym->rect[c][j];
xctx->sym[i].rect[c][j].prop_ptr = NULL;
xctx->sym[i].rect[c][j].extraptr = NULL;
my_strdup(_ALLOC_ID_, & xctx->sym[i].rect[c][j].prop_ptr, sym->rect[c][j].prop_ptr);
}
/* symbol arcs */
xctx->sym[i].arc[c] = my_calloc(_ALLOC_ID_, sym->arcs[c], sizeof(xArc));
for(j = 0; j < xctx->sym[i].arcs[c]; ++j) {
xctx->sym[i].arc[c][j] = sym->arc[c][j];
xctx->sym[i].arc[c][j].prop_ptr = NULL;
my_strdup(_ALLOC_ID_, & xctx->sym[i].arc[c][j].prop_ptr, sym->arc[c][j].prop_ptr);
}
/* symbol polygons */
xctx->sym[i].poly[c] = my_calloc(_ALLOC_ID_, sym->polygons[c], sizeof(xPoly));
for(j = 0; j < xctx->sym[i].polygons[c]; ++j) {
int points = sym->poly[c][j].points;
xctx->sym[i].poly[c][j] = sym->poly[c][j];
xctx->sym[i].poly[c][j].prop_ptr = NULL;
xctx->sym[i].poly[c][j].x = my_malloc(_ALLOC_ID_, points * sizeof(double));
xctx->sym[i].poly[c][j].y = my_malloc(_ALLOC_ID_, points * sizeof(double));
xctx->sym[i].poly[c][j].selected_point = my_malloc(_ALLOC_ID_, points * sizeof(unsigned short));
memcpy(xctx->sym[i].poly[c][j].x, sym->poly[c][j].x, points * sizeof(double));
memcpy(xctx->sym[i].poly[c][j].y, sym->poly[c][j].y, points * sizeof(double));
memcpy(xctx->sym[i].poly[c][j].selected_point, sym->poly[c][j].selected_point,
points * sizeof(unsigned short));
my_strdup(_ALLOC_ID_, & xctx->sym[i].poly[c][j].prop_ptr, sym->poly[c][j].prop_ptr);
}
}
/* symbol texts */
for(j = 0; j < xctx->sym[i].texts; ++j) {
xctx->sym[i].text[j] = sym->text[j];
xctx->sym[i].text[j].prop_ptr = NULL;
xctx->sym[i].text[j].txt_ptr = NULL;
xctx->sym[i].text[j].font = NULL;
my_strdup(_ALLOC_ID_, &xctx->sym[i].text[j].prop_ptr, sym->text[j].prop_ptr);
my_strdup(_ALLOC_ID_, &xctx->sym[i].text[j].txt_ptr, sym->text[j].txt_ptr);
my_strdup(_ALLOC_ID_, &xctx->sym[i].text[j].font, sym->text[j].font);
}
copy_symbol(&xctx->sym[i], &xctx->uslot[slot].symptr[i]);
}
/* texts */

View File

@ -3179,6 +3179,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
symbol[symbols].prop_ptr = NULL;
symbol[symbols].type = NULL;
symbol[symbols].templ = NULL;
symbol[symbols].base_name=NULL;
symbol[symbols].name=NULL;
my_strdup2(_ALLOC_ID_, &symbol[symbols].name,name);
/* read symbol from file */

View File

@ -531,8 +531,7 @@ int spice_block_netlist(FILE *fd, int i)
/* int multip; */
char *extra=NULL;
int split_f;
const char *sym_def, *sympath;
struct stat buf;
const char *sym_def;
split_f = tclgetboolvar("split_files");
@ -551,10 +550,8 @@ int spice_block_netlist(FILE *fd, int i)
}
fprintf(fd, "\n* expanding symbol: %s # of pins=%d\n",
xctx->sym[i].name,xctx->sym[i].rects[PINLAYER] );
sympath = abs_sym_path(xctx->sym[i].name, "");
if(!stat(sympath, &buf)) fprintf(fd, "** sym_path: %s\n", abs_sym_path(xctx->sym[i].name, ""));
else fprintf(fd, "** sym_path: %s\n", xctx->sym[i].name);
if(xctx->sym[i].base_name) fprintf(fd, "** sym_path: %s\n", abs_sym_path(xctx->sym[i].base_name, ""));
else fprintf(fd, "** sym_path: %s\n", abs_sym_path(xctx->sym[i].name, ""));
sym_def = get_tok_value(xctx->sym[i].prop_ptr,"spice_sym_def",0);
if(sym_def[0]) {
fprintf(fd, "%s\n", sym_def);

View File

@ -81,8 +81,6 @@ static int tedax_block_netlist(FILE *fd, int i)
int tedax_stop=0;
char filename[PATH_MAX];
char *extra=NULL;
const char *sympath;
struct stat buf;
if(!strcmp( get_tok_value(xctx->sym[i].prop_ptr,"tedax_stop",0),"true") )
tedax_stop=1;
@ -92,9 +90,8 @@ static int tedax_block_netlist(FILE *fd, int i)
fprintf(fd, "\n# expanding symbol: %s # of pins=%d\n",
xctx->sym[i].name,xctx->sym[i].rects[PINLAYER] );
sympath = abs_sym_path(xctx->sym[i].name, "");
if(!stat(sympath, &buf)) fprintf(fd, "## sym_path: %s\n", abs_sym_path(xctx->sym[i].name, ""));
else fprintf(fd, "## sym_path: %s\n", xctx->sym[i].name);
if(xctx->sym[i].base_name) fprintf(fd, "## sym_path: %s\n", abs_sym_path(xctx->sym[i].base_name, ""));
else 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));

View File

@ -432,8 +432,7 @@ int verilog_block_netlist(FILE *fd, int i)
char cellname[PATH_MAX];
const char *str_tmp, *fmt_attr = NULL;
int split_f;
const char *sym_def, *sympath;
struct stat buf;
const char *sym_def;
char *extra_ptr, *saveptr1, *extra_token, *extra = NULL, *extra2=NULL;
@ -455,9 +454,8 @@ int verilog_block_netlist(FILE *fd, int i)
dbg(1, "verilog_block_netlist(): expanding %s\n", xctx->sym[i].name);
fprintf(fd, "\n// expanding symbol: %s # of pins=%d\n",
xctx->sym[i].name,xctx->sym[i].rects[PINLAYER] );
sympath = abs_sym_path(xctx->sym[i].name, "");
if(!stat(sympath, &buf)) fprintf(fd, "// sym_path: %s\n", abs_sym_path(xctx->sym[i].name, ""));
else fprintf(fd, "// sym_path: %s\n", xctx->sym[i].name);
if(xctx->sym[i].base_name) fprintf(fd, "// sym_path: %s\n", abs_sym_path(xctx->sym[i].base_name, ""));
else fprintf(fd, "// sym_path: %s\n", abs_sym_path(xctx->sym[i].name, ""));
sym_def = get_tok_value(xctx->sym[i].prop_ptr,"verilog_sym_def",0);
if(sym_def[0]) {
fprintf(fd, "%s\n", sym_def);

View File

@ -529,8 +529,7 @@ int vhdl_block_netlist(FILE *fd, int i)
char *abs_path = NULL;
const char *str_tmp;
int split_f;
const char *sym_def, *sympath;
struct stat buf;
const char *sym_def;
split_f = tclgetboolvar("split_files");
if(!strcmp( get_tok_value(xctx->sym[i].prop_ptr,"vhdl_stop",0),"true") )
@ -550,10 +549,8 @@ int vhdl_block_netlist(FILE *fd, int i)
dbg(1, "vhdl_block_netlist(): expanding %s\n", xctx->sym[i].name);
fprintf(fd, "\n-- expanding symbol: %s # of pins=%d\n",
xctx->sym[i].name,xctx->sym[i].rects[PINLAYER] );
sympath = abs_sym_path(xctx->sym[i].name, "");
if(!stat(sympath, &buf)) fprintf(fd, "-- sym_path: %s\n", abs_sym_path(xctx->sym[i].name, ""));
else fprintf(fd, "-- sym_path: %s\n", xctx->sym[i].name);
if(xctx->sym[i].base_name) fprintf(fd, "-- sym_path: %s\n", abs_sym_path(xctx->sym[i].base_name, ""));
else fprintf(fd, "-- sym_path: %s\n", abs_sym_path(xctx->sym[i].name, ""));
sym_def = get_tok_value(xctx->sym[i].prop_ptr,"vhdl_sym_def",0);
if(sym_def[0]) {
fprintf(fd, "%s\n", sym_def);

View File

@ -495,6 +495,8 @@ typedef struct
typedef struct
{
char *name;
const char *base_name; /* points to the base symbol name this symbol is inherited from
* (schematic attribute set on instances, create "virtual" symbol) */
double minx;
double maxx;
double miny;