diff --git a/autoconf.sh b/autoconf.sh index 1ace2dc34..a92a6fa65 100644 --- a/autoconf.sh +++ b/autoconf.sh @@ -9,7 +9,7 @@ echo "Autoconf in root..." autoconf -f -for dir in vpip vpi vvp tgt-vvp tgt-fpga tgt-stub libveriuser cadpli +for dir in vpip vpi vvp tgt-vvp tgt-fpga tgt-stub tgt-vhdl libveriuser cadpli do echo "Autoconf in $dir..." ( cd ./$dir ; autoconf -f --include=.. ) diff --git a/configure.in b/configure.in index 46529fbe9..1a975b173 100644 --- a/configure.in +++ b/configure.in @@ -122,6 +122,6 @@ AX_C_UNDERSCORES_TRAILING AX_CPP_IDENT # XXX disable tgt-fpga for the moment -AC_CONFIG_SUBDIRS(vvp vpi tgt-stub tgt-null tgt-vvp libveriuser cadpli) +AC_CONFIG_SUBDIRS(vvp vpi tgt-stub tgt-null tgt-vvp tgt-vhdl libveriuser cadpli) -AC_OUTPUT(Makefile ivlpp/Makefile driver/Makefile driver-vpi/Makefile tgt-null/Makefile tgt-verilog/Makefile tgt-pal/Makefile) +AC_OUTPUT(Makefile ivlpp/Makefile driver/Makefile driver-vpi/Makefile tgt-null/Makefile tgt-verilog/Makefile tgt-pal/Makefile tgt-vhdl/Makefile) diff --git a/tgt-vhdl/Makefile.in b/tgt-vhdl/Makefile.in new file mode 100644 index 000000000..7f5ffe2fd --- /dev/null +++ b/tgt-vhdl/Makefile.in @@ -0,0 +1,91 @@ +# +# 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 + +VERSION = 0.0 + +prefix = @prefix@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +srcdir = @srcdir@ + +VPATH = $(srcdir) + +bindir = @bindir@ +libdir = @libdir@ +includedir = $(prefix)/include + +CXX = @CXX@ +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +CPPFLAGS = @ident_support@ -I. -I$(srcdir)/.. @CPPFLAGS@ @DEFS@ @PICFLAG@ +CXXFLAGS = -Wall @CXXFLAGS@ +LDFLAGS = @LDFLAGS@ + +all: dep vhdl.tgt vhdl.conf + +dep: + mkdir dep + +%.o: %.cc + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -c $< -o $*.o + mv $*.d dep + +O = vhdl.o vhdl_element.o + +ifeq (@WIN32@,yes) + TGTLDFLAGS=-L.. -livl + TGTDEPLIBS=../libivl.a +else + TGTLDFLAGS= + TGTDEPLIBS= +endif + +vhdl.tgt: $O $(TGTDEPLIBS) + $(CXX) @shared@ -o $@ $O $(TGTLDFLAGS) + +Makefile: Makefile.in config.status + ./config.status + +clean: + rm -rf $(O) dep vhdl.tgt + +distclean: clean + rm -f Makefile config.status config.log config.cache vhdl_config.h + +check: all + +install: all installdirs $(libdir)/ivl/vhdl.tgt $(libdir)/ivl/vhdl.conf + +$(libdir)/ivl/vhdl.tgt: ./vhdl.tgt + $(INSTALL_PROGRAM) ./vhdl.tgt $(libdir)/ivl/vhdl.tgt + +$(libdir)/ivl/vhdl.conf: vhdl.conf + $(INSTALL_DATA) $< $(libdir)/ivl/vhdl.conf + +installdirs: ../mkinstalldirs + $(srcdir)/../mkinstalldirs $(libdir)/ivl + +uninstall: + rm -f $(libdir)/ivl/vhdl.tgt $(libdir)/ivl/vhdl.conf + + +-include $(patsubst %.o, dep/%.d, $O) diff --git a/tgt-vhdl/configure.in b/tgt-vhdl/configure.in new file mode 100644 index 000000000..3223b50e8 --- /dev/null +++ b/tgt-vhdl/configure.in @@ -0,0 +1,30 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(vhdl.cc) +AC_CONFIG_HEADER(vhdl_config.h) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_CXX + +AC_PROG_INSTALL + +AC_CANONICAL_HOST +# $host + +# Combined check for Microsoft-related bogosities; sets WIN32 if found +AX_WIN32 + +AC_CHECK_HEADERS(malloc.h stdint.h inttypes.h) + +# may modify CPPFLAGS and CFLAGS +AX_CPP_PRECOMP + +# Compiler option for position independent code, needed when making shared objects. +AX_C_PICFLAG + +# linker options when building a shared library +AX_LD_SHAREDLIB_OPTS + +AX_CPP_IDENT + +AC_OUTPUT(Makefile) diff --git a/tgt-vhdl/vhdl.cc b/tgt-vhdl/vhdl.cc new file mode 100644 index 000000000..bd9b0e052 --- /dev/null +++ b/tgt-vhdl/vhdl.cc @@ -0,0 +1,50 @@ +/* + * VHDL code generator for Icarus Verilog. + * + * Copyright (C) 2008 Nick Gasson (nick@nickg.me.uk) + * + * This program is free software; you can redistribute it and/or modify + * it 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "vhdl_target.h" +#include "vhdl_element.hh" + +#include +#include + +extern "C" int target_design(ivl_design_t des) +{ + ivl_scope_t *roots; + unsigned int nroots; + ivl_design_roots(des, &roots, &nroots); + + const char *ofname = ivl_design_flag(des, "-o"); + std::ofstream outfile(ofname); + + for (unsigned int i = 0; i < nroots; i++) { + ivl_scope_t scope = roots[i]; + const char *scope_name = ivl_scope_basename(scope); + + // Dummy output to test regression script + vhdl_entity test_ent(scope_name); + vhdl_arch test_arch(scope_name); + test_ent.emit(outfile); + test_arch.emit(outfile); + } + + outfile.close(); + + return 0; +} diff --git a/tgt-vhdl/vhdl.conf b/tgt-vhdl/vhdl.conf new file mode 100644 index 000000000..b96c4c05e --- /dev/null +++ b/tgt-vhdl/vhdl.conf @@ -0,0 +1,4 @@ +functor:cprop +functor:nodangle +-t:dll +flag:DLL=vhdl.tgt diff --git a/tgt-vhdl/vhdl_config.h.in b/tgt-vhdl/vhdl_config.h.in new file mode 100644 index 000000000..23193ebc2 --- /dev/null +++ b/tgt-vhdl/vhdl_config.h.in @@ -0,0 +1,49 @@ +/* vhdl_config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MALLOC_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS diff --git a/tgt-vhdl/vhdl_element.cc b/tgt-vhdl/vhdl_element.cc new file mode 100644 index 000000000..4f703672f --- /dev/null +++ b/tgt-vhdl/vhdl_element.cc @@ -0,0 +1,56 @@ +/* + * VHDL abstract syntax elements. + * + * Copyright (C) 2008 Nick Gasson (nick@nickg.me.uk) + * + * This program is free software; you can redistribute it and/or modify + * it 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "vhdl_element.hh" + + +//////// ENTITY //////// + +vhdl_entity::vhdl_entity(const char *name) + : name_(name) +{ + +} + +void vhdl_entity::emit(std::ofstream &of) +{ + of << "entity " << name_ << " is" << std::endl; + // ...ports... + of << "end entity; " << std::endl; +} + + +//////// ARCHITECTURE //////// + +vhdl_arch::vhdl_arch(const char *entity, const char *name) + : name_(name), entity_(entity) +{ + +} + +void vhdl_arch::emit(std::ofstream &of) +{ + of << "architecture " << name_ << " of " << entity_; + of << " is" << std::endl; + // ...declarations... + of << "begin" << std::endl; + // ...statements... + of << "end architecture;" << std::endl; +} diff --git a/tgt-vhdl/vhdl_element.hh b/tgt-vhdl/vhdl_element.hh new file mode 100644 index 000000000..0cf19768f --- /dev/null +++ b/tgt-vhdl/vhdl_element.hh @@ -0,0 +1,49 @@ +/* + * VHDL abstract syntax elements. + * + * Copyright (C) 2008 Nick Gasson (nick@nickg.me.uk) + * + * This program is free software; you can redistribute it and/or modify + * it 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef INC_VHDL_ELEMENT_HH +#define INC_VHDL_ELEMENT_HH + +#include + +class vhdl_element { +public: + virtual void emit(std::ofstream &of) = 0; +}; + +class vhdl_entity : public vhdl_element { +public: + vhdl_entity(const char *name); + + void emit(std::ofstream &of); +private: + const char *name_; +}; + +class vhdl_arch : public vhdl_element { +public: + vhdl_arch(const char *entity, const char *name="Behavioural"); + + void emit(std::ofstream &of); +private: + const char *name_, *entity_; +}; + +#endif diff --git a/tgt-vhdl/vhdl_target.h b/tgt-vhdl/vhdl_target.h new file mode 100644 index 000000000..e40591fca --- /dev/null +++ b/tgt-vhdl/vhdl_target.h @@ -0,0 +1,8 @@ +#ifndef INC_VHDL_TARGET_H +#define INC_VHDL_TARGET_H + +#include "vhdl_config.h" +#include "ivl_target.h" + +#endif /* #ifndef INC_VHDL_TARGET_H */ +