212 int i,
var, ch, np, last;
219 switch(ch = getc(fp)) {
226 case ' ':
case '\t':
case '\f':
case '\r':
230 (void) ungetc(ch, fp);
237 if (cube.fullset != NULL) {
238 (void) fprintf(stderr,
"extra .i ignored\n");
241 if (fscanf(fp,
"%d", &cube.num_binary_vars) != 1)
242 fatal(
"error reading .i");
243 cube.num_vars = cube.num_binary_vars + 1;
244 cube.part_size =
ALLOC(
int, cube.num_vars);
248 }
else if (
equal(word,
"o")) {
249 if (cube.fullset != NULL) {
250 (void) fprintf(stderr,
"extra .o ignored\n");
253 if (cube.part_size == NULL)
254 fatal(
".o cannot appear before .i");
255 if (fscanf(fp,
"%d", &(cube.part_size[cube.num_vars-1]))!=1)
256 fatal(
"error reading .o");
262 }
else if (
equal(word,
"mv")) {
263 if (cube.fullset != NULL) {
264 (void) fprintf(stderr,
"extra .mv ignored\n");
267 if (cube.part_size != NULL)
268 fatal(
"cannot mix .i and .mv");
269 if (fscanf(fp,
"%d %d",
270 &cube.num_vars,&cube.num_binary_vars) != 2)
271 fatal(
"error reading .mv");
272 if (cube.num_binary_vars < 0)
273 fatal(
"num_binary_vars (second field of .mv) cannot be negative");
274 if (cube.num_vars < cube.num_binary_vars)
276 "num_vars (1st field of .mv) must exceed num_binary_vars (2nd field of .mv)");
277 cube.part_size =
ALLOC(
int, cube.num_vars);
278 for(var=cube.num_binary_vars; var < cube.num_vars; var++)
279 if (fscanf(fp,
"%d", &(cube.part_size[var])) != 1)
280 fatal(
"error reading .mv");
286 }
else if (
equal(word,
"p"))
287 (void) fscanf(fp,
"%d", &np);
289 else if (
equal(word,
"e") ||
equal(word,
"end")) {
290 if (cube.fullset == NULL) {
292 }
else if (PLA->F == NULL) {
300 else if (
equal(word,
"kiss"))
304 else if (
equal(word,
"type")) {
312 fatal(
"unknown type in .type command");
315 }
else if (
equal(word,
"ilb")) {
316 if (cube.fullset == NULL)
317 fatal(
"PLA size must be declared before .ilb or .ob");
318 if (PLA->label == NULL)
320 for(var = 0; var < cube.num_binary_vars; var++) {
322 i = cube.first_part[
var];
323 PLA->label[i+1] = util_strsav(word);
325 (void)
sprintf(PLA->label[i],
"%s.bar", word);
327 }
else if (
equal(word,
"ob")) {
328 if (cube.fullset == NULL)
329 fatal(
"PLA size must be declared before .ilb or .ob");
330 if (PLA->label == NULL)
332 var = cube.num_vars - 1;
333 for(i = cube.first_part[var]; i <= cube.last_part[var]; i++) {
335 PLA->label[i] = util_strsav(word);
338 }
else if (
equal(word,
"label")) {
339 if (cube.fullset == NULL)
340 fatal(
"PLA size must be declared before .label");
341 if (PLA->label == NULL)
343 if (fscanf(fp,
"var=%d", &var) != 1)
344 fatal(
"Error reading labels");
345 for(i = cube.first_part[var]; i <= cube.last_part[var]; i++) {
347 PLA->label[i] = util_strsav(word);
350 }
else if (
equal(word,
"symbolic")) {
354 PLA->symbolic = newlist;
362 fatal(
"error reading .symbolic");
365 }
else if (
equal(word,
"symbolic-output")) {
369 PLA->symbolic_output = newlist;
377 fatal(
"error reading .symbolic-output");
381 }
else if (
equal(word,
"phase")) {
382 if (cube.fullset == NULL)
383 fatal(
"PLA size must be declared before .phase");
384 if (PLA->phase != NULL) {
385 (void) fprintf(stderr,
"extra .phase ignored\n");
388 do ch = getc(fp);
while (ch ==
' ' || ch ==
'\t');
389 (void) ungetc(ch, fp);
390 PLA->phase =
set_save(cube.fullset);
391 last = cube.last_part[cube.num_vars - 1];
392 for(i=cube.first_part[cube.num_vars - 1]; i <= last; i++)
393 if ((ch = getc(fp)) ==
'0')
396 fatal(
"only 0 or 1 allowed in phase description");
400 }
else if (
equal(word,
"pair")) {
402 if (PLA->pair != NULL) {
403 (void) fprintf(stderr,
"extra .pair ignored\n");
407 if (fscanf(fp,
"%d", &(pair->
cnt)) != 1)
408 fatal(
"syntax error in .pair");
411 for(i = 0; i < pair->
cnt; i++) {
413 if (word[0] ==
'(') (void)
strcpy(word, word+1);
415 pair->
var1[i] = var+1;
417 fatal(
"syntax error in .pair");
421 if (word[
strlen(word)-1] ==
')') {
422 word[
strlen(word)-1]=
'\0';
425 pair->
var2[i] = var+1;
427 fatal(
"syntax error in .pair");
434 printf(
"%c%s ", ch, word);
439 (void) ungetc(ch, fp);
440 if (cube.fullset == NULL) {
447 if (PLA->F == NULL) {
void skip_line(FILE *fpin, FILE *fpout, bool echo)
void PLA_labels(pPLA PLA)
ABC_NAMESPACE_IMPL_START void cube_setup()
char * get_word(FILE *fp, char *word)
void read_cube(FILE *fp, pPLA PLA)
struct pla_types_struct pla_types[]
static ABC_NAMESPACE_IMPL_START bool line_length_error
unsigned __int64 word
DECLARATIONS ///.
int read_symbolic(FILE *fp, pPLA PLA, char *word, symbolic_t **retval)
bool echo_unknown_commands
#define set_remove(set, e)
int label_index(pPLA PLA, char *word, int *varp, int *ip)
struct symbolic_struct * next