Add port directions when logicexp or pindly are present.

This commit is contained in:
Brian Taylor 2023-01-30 14:41:49 -08:00
parent da6a311260
commit dcafbbcf90
3 changed files with 28 additions and 2 deletions

View File

@ -340,6 +340,7 @@ static int lex_gate_op(int c)
static int lex_ident(int c)
{
/* Pspice and MicroCap are vague about what defines an identifier */
if (isalnum(c) || c == '_' || c == '/' || c == '-')
return c;
else
@ -1614,6 +1615,7 @@ BOOL f_logicexp(char *line)
if (!expect_token(t, LEX_ID, NULL, TRUE, 10)) goto error_return;
(void) add_sym_tab_entry(parse_lexer->lexer_buf,
SYM_INPUT, &parse_lexer->lexer_sym_tab);
u_remember_pin(parse_lexer->lexer_buf, 1);
}
/* num_outs output ids */
for (i = 0; i < num_outs; i++) {
@ -1621,6 +1623,7 @@ BOOL f_logicexp(char *line)
if (!expect_token(t, LEX_ID, NULL, TRUE, 11)) goto error_return;
(void) add_sym_tab_entry(parse_lexer->lexer_buf,
SYM_OUTPUT, &parse_lexer->lexer_sym_tab);
u_remember_pin(parse_lexer->lexer_buf, 2);
}
/* timing model */
t = lex_scan();
@ -2154,6 +2157,7 @@ static BOOL new_gen_output_models(LEXER lx)
if (pline) {
pline_arr[idx++] = pline;
(void) set_ena_name(ds_get_buf(&enable_name), pline);
u_remember_pin(lx->lexer_buf, 3);
} else {
goto err_return;
}
@ -2247,6 +2251,7 @@ BOOL f_pindly(char *line)
if (!expect_token(t, LEX_ID, NULL, TRUE, 61)) goto error_return;
pline = add_new_pindly_line(pindly_tab);
(void) set_in_name(lxr->lexer_buf, pline);
u_remember_pin(lxr->lexer_buf, 1);
}
/* num_ena enable nodes which are ignored */
@ -2254,6 +2259,9 @@ BOOL f_pindly(char *line)
for (i = 0; i < num_ena + num_refs; i++) {
t = lexer_scan(lxr);
if (!expect_token(t, LEX_ID, NULL, TRUE, 62)) goto error_return;
if (i < num_ena) {
u_remember_pin(lxr->lexer_buf, 1);
}
}
/* num_ios output ids */
pline = NULL;
@ -2265,6 +2273,7 @@ BOOL f_pindly(char *line)
else
pline = pline->next;
(void) set_out_name(lxr->lexer_buf, pline);
u_remember_pin(lxr->lexer_buf, 2);
}
if (!new_gen_output_models(lxr)) {

View File

@ -389,6 +389,22 @@ static void add_port_name(char *name)
add_pin_name(name, &port_names_list);
}
void u_remember_pin(char *name, int type)
{
switch (type) {
case 1: add_input_pin(name);
break;
case 2: add_output_pin(name);
break;
case 3: add_tristate_pin(name);
break;
case 4: add_port_name(name);
break;
default:
break;
}
}
static void add_all_port_names(char *subckt_line)
{
char *copy_line, *tok, *pos;
@ -398,7 +414,7 @@ static void add_all_port_names(char *subckt_line)
}
if (ps_port_directions & 4) {
printf("TRANS_IN %s\n", subckt_line);
} else if (ps_port_directions) {
} else if (ps_port_directions & 1) {
printf("%s\n", subckt_line);
}
copy_line = tprintf("%s", subckt_line);
@ -921,7 +937,7 @@ static void determine_port_type(void)
port_type = "IN";
}
}
if (ps_port_directions) {
if (ps_port_directions & 1) {
printf("port: %s %s\n", x->name, port_type);
}
}

View File

@ -9,5 +9,6 @@ struct card *replacement_udevice_cards(void);
void cleanup_udevice(void);
void u_add_instance(char *str);
void u_add_logicexp_model(char *tmodel, char *xspice_gate, char *model_name);
void u_remember_pin(char *name, int type);
#endif