Fix bug in the LOGICEXP scan_gates optimizer. Some gates with an inverting output were generated with bad logic which gave incorrect simulation results.

This commit is contained in:
Brian Taylor 2024-03-28 15:11:38 -07:00 committed by Holger Vogt
parent 415d94bee0
commit c3fa6328a1
1 changed files with 16 additions and 0 deletions

View File

@ -22,6 +22,7 @@
#include "ngspice/dstring.h"
#include "ngspice/logicexp.h"
#include "ngspice/udevices.h"
#include "ngspice/cpextern.h"
static char *get_pindly_instance_name(void);
static char *get_inst_name(void);
@ -573,6 +574,21 @@ static void scan_gates(DSTRING *lhs)
{
struct gate_data *current = NULL, *previous = NULL, *last_curr = NULL;
struct gate_data *prev = NULL;
int ps_scan_gates_noopt = 0;
if (!cp_getvar("ps_scan_gates_noopt", CP_NUM, &ps_scan_gates_noopt, 0)) {
ps_scan_gates_noopt = 0;
}
if (ps_scan_gates_noopt) {
current = last_gate;
if (ds_get_length(lhs) > 0) {
assert(current->finished == FALSE);
tfree(current->outp);
current->outp = TMALLOC(char, ds_get_length(lhs) + 1);
strcpy(current->outp, ds_get_buf(lhs));
}
return;
}
current = first_gate;
while (current) {