view ueda/unet-bind/enterinst.c @ 128:e90e948e9368

m4-fp: SRAM_TSOPII_44 footprint added
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 16 Jul 2020 18:23:22 +0000
parents ffab0a4424ad
children
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "struct.h"

extern char *copystr();
extern struct instance *enter_instance();

process_hier_attr(oc, hier)
	register struct outcomp *oc;
	char *hier;
{
	register struct instance *inst;

	if (!strncmp(hier, "flip:", 5)) {
		if (oc->npins != 2 || oc->grid_pkg) {
			fprintf(stderr,
				"error: hier=flip:... makes no sense for %s\n",
				oc->name);
			exit(1);
		}
		oc->reverse_2pin = 1;
		hier += 5;
	}
	oc->altname = hier;
	inst = enter_instance(hier);
	inst->outcomp = oc;
}

process_slotmap_attr(oc, slotmap_file)
	struct outcomp *oc;
	char *slotmap_file;
{
	FILE *stream;
	char linebuf[256];
	int lineno;
	register char *cp;
	char *instname, *slot;
	register struct instance *inst;

	stream = fopen(slotmap_file, "r");
	if (!stream) {
		perror(slotmap_file);
		exit(1);
	}
	for (lineno = 1; fgets(linebuf, sizeof linebuf, stream); lineno++) {
		cp = index(linebuf, '\n');
		if (!cp) {
			fprintf(stderr,
			"error: %s line %d is too long or unterminated\n",
				slotmap_file, lineno);
			exit(1);
		}
		*cp = '\0';
		for (cp = linebuf; isspace(*cp); cp++)
			;
		if (*cp == '\0' || *cp == '#')
			continue;
		instname = cp;
		while (*cp && !isspace(*cp))
			cp++;
		if (*cp)
			*cp++ = '\0';
		while (isspace(*cp))
			cp++;
		if (*cp == '\0' || *cp == '#')
			slot = 0;
		else {
			slot = cp;
			while (*cp && !isspace(*cp))
				cp++;
			if (*cp)
				*cp++ = '\0';
		}
		inst = enter_instance(instname);
		inst->outcomp = oc;
		if (slot)
			slot = copystr(slot);
		inst->slot = slot;
	}
	fclose(stream);
}