Permalink
Browse files

Introduce PCB code generator.

  • Loading branch information...
1 parent b37d806 commit 9075326bb7f5edd6cd32a544ddfa2dcbb5e602d1 @steveicarus committed Dec 20, 2011
Showing with 432 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 Makefile.in
  3. +2 −1 configure.in
  4. +109 −0 tgt-pcb/Makefile.in
  5. +91 −0 tgt-pcb/pcb.cc
  6. +3 −0 tgt-pcb/pcb.conf
  7. +28 −0 tgt-pcb/pcb_config.h.in
  8. +39 −0 tgt-pcb/pcb_priv.h
  9. +121 −0 tgt-pcb/scope.cc
  10. +37 −0 tgt-pcb/show_netlist.cc
View
@@ -28,6 +28,7 @@ Makefile
/_pli_types.h
config.h
+/tgt-pcb/pcb_config.h
/tgt-vvp/vvp_config.h
/tgt-vhdl/vhdl_config.h
/vpi/vpi_config.h
View
@@ -39,7 +39,7 @@ srcdir = @srcdir@
datarootdir = @datarootdir@
SUBDIRS = ivlpp vhdlpp vvp vpi libveriuser cadpli tgt-null tgt-stub tgt-vvp \
- tgt-vhdl tgt-vlog95 driver
+ tgt-vhdl tgt-vlog95 tgt-pcb driver
# Only run distclean for these directories.
NOTUSED = tgt-fpga tgt-pal tgt-verilog
View
@@ -8,6 +8,7 @@ AC_CONFIG_HEADER(vpi/vpi_config.h)
AC_CONFIG_HEADER(libveriuser/config.h)
AC_CONFIG_HEADER(tgt-vvp/vvp_config.h)
AC_CONFIG_HEADER(tgt-vhdl/vhdl_config.h)
+AC_CONFIG_HEADER(tgt-pcb/pcb_config.h)
AC_CANONICAL_HOST
dnl Checks for programs.
@@ -299,4 +300,4 @@ AC_MSG_RESULT(ok)
# XXX disable tgt-fpga for the moment
-AC_OUTPUT(Makefile ivlpp/Makefile vhdlpp/Makefile vvp/Makefile vpi/Makefile driver/Makefile driver-vpi/Makefile cadpli/Makefile libveriuser/Makefile tgt-null/Makefile tgt-stub/Makefile tgt-vvp/Makefile tgt-vhdl/Makefile tgt-fpga/Makefile tgt-verilog/Makefile tgt-pal/Makefile tgt-vlog95/Makefile)
+AC_OUTPUT(Makefile ivlpp/Makefile vhdlpp/Makefile vvp/Makefile vpi/Makefile driver/Makefile driver-vpi/Makefile cadpli/Makefile libveriuser/Makefile tgt-null/Makefile tgt-stub/Makefile tgt-vvp/Makefile tgt-vhdl/Makefile tgt-fpga/Makefile tgt-verilog/Makefile tgt-pal/Makefile tgt-vlog95/Makefile tgt-pcb/Makefile)
View
@@ -0,0 +1,109 @@
+#
+# This source code is free software; you can redistribute it
+# and/or modify it in source code form under the terms of the GNU
+# Library General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc.,
+# 59 Temple Place - Suite 330
+# Boston, MA 02111-1307, USA
+#
+SHELL = /bin/sh
+
+suffix = @install_suffix@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+srcdir = @srcdir@
+
+VPATH = $(srcdir)
+
+bindir = @bindir@
+libdir = @libdir@
+
+CC = @CC@
+CXX = @CXX@
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+ifeq (@srcdir@,.)
+INCLUDE_PATH = -I. -I..
+else
+INCLUDE_PATH = -I. -I.. -I$(srcdir) -I$(srcdir)/..
+endif
+
+CPPFLAGS = $(INCLUDE_PATH) @CPPFLAGS@ @DEFS@ @PICFLAG@
+CFLAGS = @WARNING_FLAGS@ @CFLAGS@
+LDFLAGS = @LDFLAGS@
+
+O = pcb.o scope.o show_netlist.o
+
+all: dep pcb.tgt
+
+check: all
+
+clean:
+ rm -rf *.o dep pcb.tgt
+
+distclean: clean
+ rm -f Makefile config.log
+
+cppcheck: $(O:.o=.c)
+ cppcheck --enable=all -f $(INCLUDE_PATH) $^
+
+Makefile: $(srcdir)/Makefile.in ../config.status
+ cd ..; ./config.status --file=tgt-pcb/$@
+
+dep:
+ mkdir dep
+
+%.o: %.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) @DEPENDENCY_FLAG@ -c $< -o $*.o
+ mv $*.d dep
+
+%.o: %.cc
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) @DEPENDENCY_FLAG@ -c $< -o $*.o
+ mv $*.d dep
+
+ifeq (@WIN32@,yes)
+ TGTLDFLAGS=-L.. -livl
+ TGTDEPLIBS=../libivl.a
+else
+ TGTLDFLAGS=
+ TGTDEPLIBS=
+endif
+
+pcb.tgt: $O $(TGTDEPLIBS)
+ $(CC) @shared@ -o $@ $O $(TGTLDFLAGS)
+
+install: all installdirs $(libdir)/ivl$(suffix)/pcb.tgt $(INSTALL_DOC) $(libdir)/ivl$(suffix)/pcb.conf $(libdir)/ivl$(suffix)/pcb-s.conf
+
+$(libdir)/ivl$(suffix)/pcb.tgt: ./pcb.tgt
+ $(INSTALL_PROGRAM) ./pcb.tgt "$(DESTDIR)$(libdir)/ivl$(suffix)/pcb.tgt"
+
+$(libdir)/ivl$(suffix)/pcb.conf: $(srcdir)/pcb.conf
+ $(INSTALL_DATA) $(srcdir)/pcb.conf "$(DESTDIR)$(libdir)/ivl$(suffix)/pcb.conf"
+
+$(libdir)/ivl$(suffix)/pcb-s.conf: $(srcdir)/pcb-s.conf
+ $(INSTALL_DATA) $(srcdir)/pcb-s.conf "$(DESTDIR)$(libdir)/ivl$(suffix)/pcb-s.conf"
+
+
+installdirs: $(srcdir)/../mkinstalldirs
+ $(srcdir)/../mkinstalldirs "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)/ivl$(suffix)"
+
+uninstall:
+ rm -f "$(DESTDIR)$(libdir)/ivl$(suffix)/pcb.tgt"
+ rm -f "$(DESTDIR)$(libdir)/ivl$(suffix)/pcb.conf"
+ rm -f "$(DESTDIR)$(libdir)/ivl$(suffix)/pcb-s.conf"
+
+
+-include $(patsubst %.o, dep/%.d, $O)
View
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2011 Stephen Williams (steve@icarus.com)
+ *
+ * This source code is free software; you can redistribute it
+ * and/or modify it in source code form under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/*
+ * This is a PCB target module.
+ */
+
+# include "version_base.h"
+# include "version_tag.h"
+# include "pcb_config.h"
+# include <string.h>
+# include <stdio.h>
+# include "pcb_priv.h"
+# include "ivl_target.h"
+
+static const char*version_string =
+"Icarus Verilog PCB Netlist Generator " VERSION " (" VERSION_TAG ")\n\n"
+"Copyright (c) 2011 Stephen Williams (steve@icarus.com)\n\n"
+" This program is free software; you can redistribute it and/or modify\n"
+" it under the terms of the GNU General Public License as published by\n"
+" the Free Software Foundation; either version 2 of the License, or\n"
+" (at your option) any later version.\n"
+"\n"
+" This program is distributed in the hope that it will be useful,\n"
+" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+" GNU General Public License for more details.\n"
+"\n"
+" You should have received a copy of the GNU General Public License along\n"
+" with this program; if not, write to the Free Software Foundation, Inc.,\n"
+" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n"
+;
+
+
+int target_design(ivl_design_t des)
+{
+ ivl_scope_t*root_scopes;
+ unsigned nroot;
+ unsigned idx;
+ FILE*fnet;
+ int rc = 0;
+ const char*path = ivl_design_flag(des, "-o");
+ if (path == 0) {
+ return -1;
+ }
+
+ fnet = fopen(path, "w");
+ if (fnet == 0) {
+ perror (path);
+ return -2;
+ }
+
+ ivl_design_roots(des, &root_scopes, &nroot);
+ for (idx = 0 ; idx < nroot ; idx += 1) {
+ int tmp = scan_scope(root_scopes[idx]);
+ if (tmp != 0) {
+ rc = tmp;
+ break;
+ }
+ }
+
+ show_netlist(fnet);
+
+ fclose(fnet);
+ return rc;
+}
+
+
+const char* target_query(const char*key)
+{
+ if (strcmp(key,"version") == 0)
+ return version_string;
+
+ return 0;
+}
View
@@ -0,0 +1,3 @@
+functor:cprop
+functor:nodangle
+flag:DLL=pcb.tgt
View
@@ -0,0 +1,28 @@
+#ifndef __pcb_config_H
+#define __pcb_config_H
+/*
+ * Copyright (c) 2011 Stephen Williams (steve@icarus.com)
+ *
+ * This source code is free software; you can redistribute it
+ * and/or modify it in source code form under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+# undef HAVE_STDINT_H
+# undef HAVE_INTTYPES_H
+
+# undef _LARGEFILE_SOURCE
+# undef _LARGEFILE64_SOURCE
+
+#endif /* __pcb_config_H */
View
@@ -0,0 +1,39 @@
+#ifndef __pcb_priv_H
+#define __pcb_priv_H
+/*
+ * Copyright (c) 2011 Stephen Williams (steve@icarus.com)
+ *
+ * This source code is free software; you can redistribute it
+ * and/or modify it in source code form under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+# include <string>
+# include <set>
+# include <list>
+# include <cstdio>
+# include <ivl_target.h>
+
+extern int scan_scope(ivl_scope_t scope);
+
+struct nexus_data {
+ std::string name;
+ std::set<std::string> pins;
+};
+
+extern std::list<struct nexus_data*> nexus_list;
+
+extern void show_netlist(FILE*fnet);
+
+#endif
Oops, something went wrong.

0 comments on commit 9075326

Please sign in to comment.