simplified simdata struct
This commit is contained in:
parent
e7d28947c1
commit
8dbe8b7771
|
|
@ -1127,7 +1127,7 @@ int eval_logic_expr(int inst, int output)
|
||||||
char *str;
|
char *str;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
str = xctx->simdata.inst[inst].pin[output].function;
|
str = xctx->simdata[inst].pin[output].function;
|
||||||
dbg(1, "eval_logic_expr(): inst=%d pin=%d function=%s\n", inst, output, str ? str : "NULL");
|
dbg(1, "eval_logic_expr(): inst=%d pin=%d function=%s\n", inst, output, str ? str : "NULL");
|
||||||
if(!str) return 2; /* no logic function defined, return LOGIC_X */
|
if(!str) return 2; /* no logic function defined, return LOGIC_X */
|
||||||
while(str[pos]) {
|
while(str[pos]) {
|
||||||
|
|
@ -1275,29 +1275,30 @@ int eval_logic_expr(int inst, int output)
|
||||||
/* fast access to symbol "function#" and symbol pin "clock" and "goto" attributes
|
/* fast access to symbol "function#" and symbol pin "clock" and "goto" attributes
|
||||||
* to minimize get_token_value() lookups in simulation loops
|
* to minimize get_token_value() lookups in simulation loops
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void create_simdata(void)
|
void create_simdata(void)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
const char *str;
|
const char *str;
|
||||||
free_simdata();
|
free_simdata();
|
||||||
my_realloc(60, &xctx->simdata.inst, xctx->instances * sizeof(struct simdata_inst));
|
my_realloc(60, &xctx->simdata, xctx->instances * sizeof(struct simdata));
|
||||||
xctx->simdata.ninst = xctx->instances;
|
xctx->simdata_ninst = xctx->instances;
|
||||||
for(i = 0; i < xctx->instances; i++) {
|
for(i = 0; i < xctx->instances; i++) {
|
||||||
xSymbol *symbol = xctx->inst[i].ptr + xctx->sym;
|
xSymbol *symbol = xctx->inst[i].ptr + xctx->sym;
|
||||||
int npin = symbol->rects[PINLAYER];
|
int npin = symbol->rects[PINLAYER];
|
||||||
xctx->simdata.inst[i].pin = NULL;
|
xctx->simdata[i].pin = NULL;
|
||||||
my_realloc(61, &xctx->simdata.inst[i].pin, npin * sizeof(struct simdata_pin));
|
my_realloc(61, &xctx->simdata[i].pin, npin * sizeof(struct simdata_pin));
|
||||||
xctx->simdata.inst[i].npin = npin;
|
xctx->simdata[i].npin = npin;
|
||||||
for(j = 0; j < npin; j++) {
|
for(j = 0; j < npin; j++) {
|
||||||
char function[20];
|
char function[20];
|
||||||
xctx->simdata.inst[i].pin[j].function=NULL;
|
xctx->simdata[i].pin[j].function=NULL;
|
||||||
xctx->simdata.inst[i].pin[j].go_to=NULL;
|
xctx->simdata[i].pin[j].go_to=NULL;
|
||||||
my_snprintf(function, S(function), "function%d", j);
|
my_snprintf(function, S(function), "function%d", j);
|
||||||
my_strdup(717, &xctx->simdata.inst[i].pin[j].function, get_tok_value(symbol->prop_ptr, function, 0));
|
my_strdup(717, &xctx->simdata[i].pin[j].function, get_tok_value(symbol->prop_ptr, function, 0));
|
||||||
my_strdup(963, &xctx->simdata.inst[i].pin[j].go_to,
|
my_strdup(963, &xctx->simdata[i].pin[j].go_to,
|
||||||
get_tok_value(symbol->rect[PINLAYER][j].prop_ptr, "goto", 0));
|
get_tok_value(symbol->rect[PINLAYER][j].prop_ptr, "goto", 0));
|
||||||
str = get_tok_value(symbol->rect[PINLAYER][j].prop_ptr, "clock", 0);
|
str = get_tok_value(symbol->rect[PINLAYER][j].prop_ptr, "clock", 0);
|
||||||
xctx->simdata.inst[i].pin[j].clock = str[0] ? str[0] - '0' : -1;
|
xctx->simdata[i].pin[j].clock = str[0] ? str[0] - '0' : -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1306,20 +1307,21 @@ void free_simdata(void)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
if(xctx->simdata.inst) {
|
if(xctx->simdata) {
|
||||||
for(i = 0; i < xctx->simdata.ninst; i++) {
|
for(i = 0; i < xctx->simdata_ninst; i++) { /* can not use xctx->instances if a new sch is loaded */
|
||||||
int npin = xctx->simdata.inst[i].npin;
|
int npin = xctx->simdata[i].npin;
|
||||||
for(j = 0; j < npin; j++) {
|
for(j = 0; j < npin; j++) {
|
||||||
my_free(1219, &xctx->simdata.inst[i].pin[j].function);
|
my_free(1219, &xctx->simdata[i].pin[j].function);
|
||||||
my_free(1220, &xctx->simdata.inst[i].pin[j].go_to);
|
my_free(1220, &xctx->simdata[i].pin[j].go_to);
|
||||||
}
|
}
|
||||||
my_free(1221, &xctx->simdata.inst[i].pin);
|
my_free(1221, &xctx->simdata[i].pin);
|
||||||
}
|
}
|
||||||
my_free(1222, &xctx->simdata.inst);
|
my_free(1222, &xctx->simdata);
|
||||||
}
|
}
|
||||||
|
xctx->simdata_ninst = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DELAYED_ASSIGN
|
#define DELAYED_ASSIGN /* fixes bidirectional devices (avoid infinite loops) */
|
||||||
void propagate_logic()
|
void propagate_logic()
|
||||||
{
|
{
|
||||||
/* char *propagated_net=NULL; */
|
/* char *propagated_net=NULL; */
|
||||||
|
|
@ -1335,20 +1337,21 @@ void propagate_logic()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
prepare_netlist_structs(0);
|
prepare_netlist_structs(0);
|
||||||
|
if(!xctx->simdata) create_simdata();
|
||||||
while(1) {
|
while(1) {
|
||||||
found=0;
|
found=0;
|
||||||
for(i=0; i<xctx->simdata.ninst; i++) {
|
for(i=0; i<xctx->instances; i++) {
|
||||||
npin = xctx->simdata.inst[i].npin;
|
npin = xctx->simdata[i].npin;
|
||||||
#ifdef DELAYED_ASSIGN
|
#ifdef DELAYED_ASSIGN
|
||||||
my_realloc(778, &newval_arr, npin * sizeof(int));
|
my_realloc(778, &newval_arr, npin * sizeof(int));
|
||||||
for(j=0; j<npin;j++) newval_arr[j] = -10000;
|
for(j=0; j<npin;j++) newval_arr[j] = -10000;
|
||||||
#endif
|
#endif
|
||||||
for(j=0; j<npin;j++) {
|
for(j=0; j<npin;j++) {
|
||||||
if(xctx->simdata.inst && xctx->simdata.inst[i].pin && xctx->simdata.inst[i].pin[j].go_to) {
|
if(xctx->simdata && xctx->simdata[i].pin && xctx->simdata[i].pin[j].go_to) {
|
||||||
int n = 1;
|
int n = 1;
|
||||||
const char *propag;
|
const char *propag;
|
||||||
int clock_pin, clock_val, clock_oldval;
|
int clock_pin, clock_val, clock_oldval;
|
||||||
clock_pin = xctx->simdata.inst[i].pin[j].clock;
|
clock_pin = xctx->simdata[i].pin[j].clock;
|
||||||
if(clock_pin != -1) {
|
if(clock_pin != -1) {
|
||||||
/* no bus_hilight_lookup --> no bus expansion */
|
/* no bus_hilight_lookup --> no bus expansion */
|
||||||
entry = hilight_lookup(xctx->inst[i].node[j], 0, XLOOKUP); /* clock pin */
|
entry = hilight_lookup(xctx->inst[i].node[j], 0, XLOOKUP); /* clock pin */
|
||||||
|
|
@ -1370,15 +1373,15 @@ void propagate_logic()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dbg(1, "propagate_logic(): inst=%d pin %d, goto=%s\n", i,j, xctx->simdata.inst[i].pin[j].go_to);
|
dbg(1, "propagate_logic(): inst=%d pin %d, goto=%s\n", i,j, xctx->simdata[i].pin[j].go_to);
|
||||||
while(1) {
|
while(1) {
|
||||||
propag = find_nth(xctx->simdata.inst[i].pin[j].go_to, ',', n);
|
propag = find_nth(xctx->simdata[i].pin[j].go_to, ',', n);
|
||||||
n++;
|
n++;
|
||||||
if(!propag[0]) break;
|
if(!propag[0]) break;
|
||||||
propagate = atoi(propag);
|
propagate = atoi(propag);
|
||||||
if(propagate < 0 || propagate >= npin) {
|
if(propagate < 0 || propagate >= npin) {
|
||||||
dbg(0, "Error: inst: %s, pin %d, goto set to %s <<%d>>\n",
|
dbg(0, "Error: inst: %s, pin %d, goto set to %s <<%d>>\n",
|
||||||
xctx->inst[i].instname, j, xctx->simdata.inst[i].pin[j].go_to, propagate);
|
xctx->inst[i].instname, j, xctx->simdata[i].pin[j].go_to, propagate);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(!xctx->inst[i].node[propagate]) {
|
if(!xctx->inst[i].node[propagate]) {
|
||||||
|
|
@ -1442,7 +1445,7 @@ void logic_set(int value, int num)
|
||||||
|
|
||||||
tclsetvar("tclstop", "0");
|
tclsetvar("tclstop", "0");
|
||||||
prepare_netlist_structs(0);
|
prepare_netlist_structs(0);
|
||||||
if(!xctx->simdata.inst) create_simdata();
|
if(!xctx->simdata) create_simdata();
|
||||||
rebuild_selected_array();
|
rebuild_selected_array();
|
||||||
newval = value;
|
newval = value;
|
||||||
if(!xctx->no_draw && !big) {
|
if(!xctx->no_draw && !big) {
|
||||||
|
|
|
||||||
|
|
@ -652,7 +652,7 @@ void prepare_netlist_structs(int for_netlist)
|
||||||
if (for_netlist>0 && xctx->prep_net_structs) return;
|
if (for_netlist>0 && xctx->prep_net_structs) return;
|
||||||
else if (!for_netlist && xctx->prep_hi_structs) return;
|
else if (!for_netlist && xctx->prep_hi_structs) return;
|
||||||
/* delete instance pins spatial hash, wires spatial hash, node_hash, wires and inst nodes.*/
|
/* delete instance pins spatial hash, wires spatial hash, node_hash, wires and inst nodes.*/
|
||||||
else delete_netlist_structs();
|
delete_netlist_structs();
|
||||||
free_simdata(); /* invalidate simulation cache */
|
free_simdata(); /* invalidate simulation cache */
|
||||||
dbg(1, "prepare_netlist_structs(): extraction\n");
|
dbg(1, "prepare_netlist_structs(): extraction\n");
|
||||||
if(xctx->netlist_count == 0 ) startlevel = xctx->currsch;
|
if(xctx->netlist_count == 0 ) startlevel = xctx->currsch;
|
||||||
|
|
|
||||||
|
|
@ -406,8 +406,8 @@ void alloc_xschem_data()
|
||||||
xctx->maxsel = 0;
|
xctx->maxsel = 0;
|
||||||
xctx->prep_net_structs = 0;
|
xctx->prep_net_structs = 0;
|
||||||
xctx->prep_hi_structs = 0;
|
xctx->prep_hi_structs = 0;
|
||||||
xctx->simdata.inst = NULL;
|
xctx->simdata = NULL;
|
||||||
xctx->simdata.ninst = 0;
|
xctx->simdata_ninst = 0;
|
||||||
xctx->prep_hash_inst = 0;
|
xctx->prep_hash_inst = 0;
|
||||||
xctx->prep_hash_wires = 0;
|
xctx->prep_hash_wires = 0;
|
||||||
xctx->modified = 0;
|
xctx->modified = 0;
|
||||||
|
|
|
||||||
10
src/xschem.h
10
src/xschem.h
|
|
@ -495,16 +495,11 @@ struct simdata_pin {
|
||||||
short clock;
|
short clock;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct simdata_inst {
|
struct simdata {
|
||||||
struct simdata_pin *pin;
|
struct simdata_pin *pin;
|
||||||
int npin;
|
int npin;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct simdata {
|
|
||||||
struct simdata_inst *inst;
|
|
||||||
int ninst;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
xWire *wire;
|
xWire *wire;
|
||||||
xText *text;
|
xText *text;
|
||||||
|
|
@ -564,7 +559,8 @@ typedef struct {
|
||||||
int prep_hi_structs;
|
int prep_hi_structs;
|
||||||
int prep_hash_inst;
|
int prep_hash_inst;
|
||||||
int prep_hash_wires;
|
int prep_hash_wires;
|
||||||
struct simdata simdata;
|
struct simdata *simdata;
|
||||||
|
int simdata_ninst;
|
||||||
int modified;
|
int modified;
|
||||||
int semaphore;
|
int semaphore;
|
||||||
int get_tok_size;
|
int get_tok_size;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue