view ueda/uschem-netlist/netobj.c @ 0:cd92449fdb51

initial import of ueda and ifctf-part-lib from ifctfvax CVS
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 20 Jul 2015 00:24:37 +0000
parents
children
line wrap: on
line source

#include <sys/types.h>
#include <stdio.h>
#include "netlist.h"
#include "../libuschem/schemstruct.h"

extern struct net *alloc_nethead();
extern struct net *get_nethead_for_netname();

extern struct schem *curschem;
extern int global_errflag;

static struct net *curnet;
static struct schemobj *cur_grouphead;

process_netobj(obj)
	register struct schemobj *obj;
{
	register struct netpoint *netpt;

	if (!obj->netobj_grouphead || obj->netobj_grouphead != cur_grouphead) {
		curnet = NULL;
		cur_grouphead = obj->netobj_grouphead;
	}
	if (!curnet && obj->netobj_netname)
		curnet = get_nethead_for_netname(obj->netobj_netname);
	for (netpt = obj->netobj_points; netpt; netpt = netpt->netpt_next)
		if (netpt->netpt_type == NETPT_TYPE_PIN)
			process_netpoint(obj, netpt);
}

process_netpoint(netobj, netpt)
	struct schemobj *netobj;
	register struct netpoint *netpt;
{
	struct schemobj *comp;
	char *soughtpin;
	int bynum;

	if (!netpt->netpt_pin_nameref) {
		fprintf(stderr,
"%s: line %d: Pin connection specified by coordinates only not netlistable\n",
			curschem->orig_filename, netobj->obj_lineno);
		fprintf(stderr, "Run uschem-rewrite -g %s to fix\n",
			curschem->orig_filename);
		global_errflag++;
		return;
	}
	if (parse_pin_nameref(curschem, netobj->obj_lineno,
				netpt->netpt_pin_nameref, &comp, &soughtpin,
				&bynum) < 0) {
		/* error msg already printed */
		global_errflag++;
		return;
	}
	/* handle unnamed nets -- point of no return */
	if (!curnet) {
		curnet = alloc_nethead();
		add_unnamed_net(curnet);
	}
	do_connect(curnet, comp, soughtpin, bynum, netobj->obj_lineno);
}