diff ueda/sverp/misc.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 7b4f78fcca08
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ueda/sverp/misc.c	Mon Jul 20 00:24:37 2015 +0000
@@ -0,0 +1,48 @@
+/*
+ * ueda-sverp miscellaneous functions
+ */
+
+#include <stdio.h>
+#include <strings.h>
+#include "struct.h"
+
+extern struct module_def *glob_module_list, *top_module_def;
+extern char *top_module_expl;
+
+struct module_def *
+find_module_by_name(namesought)
+	register char *namesought;
+{
+	register struct module_def *m;
+
+	for (m = glob_module_list; m; m = m->next)
+		if (!strcmp(m->name, namesought))
+			break;
+	return(m);
+}
+
+process_explicit_topmod()
+{
+	register struct module_def *mod;
+
+	mod = find_module_by_name(top_module_expl);
+	if (!mod) {
+		fprintf(stderr, "error: module \"%s\" (-t option) not found\n",
+			top_module_expl);
+		exit(1);
+	}
+	if (mod->is_primitive) {
+		fprintf(stderr,
+			"error: module %s selected with -t is a primitive\n",
+			top_module_expl);
+		exit(1);
+	}
+	if (mod->nports) {
+		fprintf(stderr,
+	"error: module %s (-t option) has ports and thus cannot be top\n",
+			top_module_expl);
+		exit(1);
+	}
+	/* all checks passed */
+	top_module_def = mod;
+}