view ueda/sverp-bind/main.c @ 78:be1fe110b6ab

pads2gpcb: output offset implemented
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Mon, 01 Feb 2016 02:22:37 +0000
parents 61272ee5aadc
children
line wrap: on
line source

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

extern char *MCLfile;

char *input_filename, *output_filename;
char *starpoints_file;
int check_completeness, unbound_instances;

struct wantattr *want_attr_list;
static struct wantattr **wantattr_tailp = &want_attr_list;

static void
add_wanted_attr(attr)
	char *attr;
{
	struct wantattr *wa;

	wa = (struct wantattr *) malloc(sizeof(struct wantattr) +
					strlen(attr) + 1);
	if (!wa) {
		perror("malloc");
		exit(1);
	}
	wa->name = (char *)(wa + 1);
	strcpy(wa->name, attr);
	wa->next = 0;
	*wantattr_tailp = wa;
	wantattr_tailp = &wa->next;
}

static void
usage()
{
	fprintf(stderr,
		"usage: unet-bind [options] input.unet [output.unet]\n");
	exit(1);
}

static void
process_options(argc, argv)
	char **argv;
{
	extern char *optarg;
	register int c;

	while ((c = getopt(argc, argv, "a:cI:M:s:")) != EOF) {
		switch (c) {
		case 'a':
			add_wanted_attr(optarg);
			continue;
		case 'c':
			check_completeness++;
			continue;
		case 'I':
			add_symfile_dir(optarg);
			continue;
		case 'M':
			MCLfile = optarg;
			continue;
		case 's':
			starpoints_file = optarg;
			continue;
		default:
			usage();
		}
	}
}

main(argc, argv)
	char **argv;
{
	extern int optind;

	process_options(argc, argv);
	if (argc < optind + 1 || argc > optind + 2)
		usage();
	input_filename = argv[optind];
	output_filename = argv[optind+1];

	/* process all inputs from the MCL */
	read_MCL();
	set_default_sympath();
	read_pinouts();
	init_outcomp_from_MCL();
	/* do we have any star points? */
	if (starpoints_file)
		process_starpoints_file();
	/* read the netlist from sverp */
	process_input_unet();
	if (unbound_instances) {
		fprintf(stderr,
		"error: %s input contains unbound instances, aborting\n",
			input_filename);
		exit(1);
	}
	check_unclaimed_instances();
	generate_output();
	exit(0);
}