Add parameter m (multiplier), while translating from G or F source

to code model spice2poly
This commit is contained in:
Holger Vogt 2026-02-23 16:06:43 +01:00
parent 39a0fe78cd
commit cf2293c317
1 changed files with 23 additions and 1 deletions

View File

@ -301,7 +301,7 @@ static char *two2three_translate(
char **out_conn;
char **in_conn;
char **coef;
char* multibeg, *multiend, *multi = NULL;
char *card;
@ -313,6 +313,20 @@ static char *two2three_translate(
/* Put the first character into local storage for checking type */
type = *orig_card;
/* There may be a multiplier m=val
Remove it here, add it later */
multibeg = strstr(orig_card, " m=");
if (multibeg) {
multiend = multibeg + 3;
while (*multiend == ' ')
multiend++;
while (*multiend && *multiend != ' ')
multiend++;
multi = copy_substring(multibeg, multiend);
while (multibeg < multiend)
*(multibeg++) = ' ';
}
/* Count the number of tokens for use in parsing */
num_tokens = count_tokens(orig_card);
@ -414,6 +428,9 @@ static char *two2three_translate(
for(i = 0; i < num_coefs; i++)
mod_card_len += strlen(coef[i]) + 1;
if (multi && (type == 'g' || type == 'G' || type == 'f'|| type == 'F'))
mod_card_len += strlen(multi) + 1;
/* Allocate space for the cards and write them into the strings */
*inst_card = TMALLOC(char, inst_card_len);
@ -460,6 +477,11 @@ static char *two2three_translate(
sprintf(*mod_card + strlen(*mod_card), "%s ", coef[i]);
sprintf(*mod_card + strlen(*mod_card), "]");
if (multi && (type == 'g' || type == 'G' || type == 'f' || type == 'F')) {
sprintf(*mod_card + strlen(*mod_card), " %s", multi);
tfree(multi);
}
#ifdef TRACE
/* SDB debug statement */
printf("In two2three_translate, translated statements:\n%s \n%s \n", *inst_card, *mod_card);