changeset 12:51893347bc42

unet-bind implementation started
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sat, 01 Aug 2015 23:33:05 +0000
parents 73abf2c13884
children 1f3283f8e482
files .hgignore ueda/sverp-bind/Makefile ueda/sverp-bind/main.c ueda/sverp-bind/outcomp.c
diffstat 4 files changed, 170 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat Aug 01 22:38:00 2015 +0000
+++ b/.hgignore	Sat Aug 01 23:33:05 2015 +0000
@@ -6,5 +6,6 @@
 ^ueda/mclutils/mkbom$
 ^ueda/mclutils/shortbom$
 ^ueda/sverp/ueda-sverp$
+^ueda/sverp-bind/unet-bind$
 ^ueda/utils/cutelements$
 ^ueda/utils/instfileelem$
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ueda/sverp-bind/Makefile	Sat Aug 01 23:33:05 2015 +0000
@@ -0,0 +1,17 @@
+CC=	gcc
+CFLAGS=	-O2
+OBJS=	main.o outcomp.o
+LIBS=	../libueda/libueda.a
+PROG=	unet-bind
+BINDIR=	/usr/local/bin
+
+all:	${PROG}
+
+${PROG}:	${OBJS} ${LIBS}
+	${CC} -o $@ ${OBJS} ${LIBS}
+
+install:
+	install -c -o bin -g bin -m 755 ${PROG} ${BINDIR}
+
+clean:
+	rm -f *.[ao] a.out core errs ${PROG}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ueda/sverp-bind/main.c	Sat Aug 01 23:33:05 2015 +0000
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
+
+extern char *MCLfile;
+
+char *input_filename, *output_filename;
+
+static void
+usage()
+{
+	fprintf(stderr, "usage: unet-bind 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, "I:M:")) != EOF) {
+		switch (c) {
+		case 'I':
+			add_symfile_dir(optarg);
+			continue;
+		case 'M':
+			MCLfile = optarg;
+			break;
+		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();
+
+	/* remaining functionality remains to be implemented */
+	exit(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ueda/sverp-bind/outcomp.c	Sat Aug 01 23:33:05 2015 +0000
@@ -0,0 +1,94 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include "../libueda/mcl.h"
+#include "../libueda/xga.h"
+#include "struct.h"
+
+extern struct component components[];
+extern int ncomponents;
+
+extern char *get_comp_attr();
+extern struct grid_pkg_desc *read_grid_pkg_file();
+
+struct outcomp *netlist_comps;
+
+static int
+try_numpins(oc)
+	register struct outcomp *oc;
+{
+	char *npins_attr;
+	register int n;
+
+	npins_attr = get_comp_attr(oc->mclcomp, "npins");
+	if (!npins_attr)
+		return(0);
+	n = atoi(npins_attr);
+	if (n <= 0) {
+		fprintf(stderr, "component %s: invalid npins attribute\n",
+			oc->name);
+		exit(1);
+	}
+	oc->npins = n;
+	return(1);
+}
+
+static int
+try_gridpkg(oc)
+	register struct outcomp *oc;
+{
+	char *attr;
+	register struct grid_pkg_desc *desc;
+
+	attr = get_comp_attr(oc->mclcomp, "grid_pkg");
+	if (!attr)
+		return(0);
+	desc = read_grid_pkg_file(attr);
+	oc->grid_pkg = desc;
+	oc->npins = desc->nrows * desc->ncolumns;
+	return(1);
+}
+
+static void
+init_one_outcomp(oc)
+	register struct outcomp *oc;
+{
+	register struct pinconn **conn_array;
+
+	oc->name = oc->mclcomp->name;
+	try_numpins(oc);
+	if (!oc->npins)
+		try_gridpkg(oc);
+	if (!oc->npins) {
+		fprintf(stderr,
+			"error: %s has neither npins nor grid_pkg attribute\n",
+			oc->name);
+		exit(1);
+	}
+	conn_array = (struct pinconn **) malloc(sizeof(struct pinconn *) *
+						oc->npins);
+	if (!conn_array) {
+		perror("malloc");
+		exit(1);
+	}
+	bzero(conn_array, sizeof(struct pinconn *) * oc->npins);
+	oc->conn_array = conn_array;
+}
+
+init_outcomp_from_MCL()
+{
+	register int i;
+
+	netlist_comps = (struct outcomp *)
+				malloc(sizeof(struct outcomp) * ncomponents);
+	if (!netlist_comps) {
+		perror("malloc");
+		exit(1);
+	}
+	bzero(netlist_comps, sizeof(struct outcomp) * ncomponents);
+	for (i = 0; i < ncomponents; i++) {
+		netlist_comps[i].mclcomp = components + i;
+		init_one_outcomp(netlist_comps + i);
+	}
+}