From de7fff8ac69400880156e528428a6cbef74d2782 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Tue, 27 May 2008 20:06:58 -0700 Subject: [PATCH] Elaborate tran devices (switches) This takes the support for switch modeling to the code generator. Add error messages in the vvp code generator for lack of support. --- ivl.def | 6 ++++-- ivl_target.h | 3 +++ t-dll-api.cc | 10 ++++++++++ t-dll.cc | 3 +++ tgt-vvp/Makefile.in | 2 +- tgt-vvp/draw_switch.c | 33 +++++++++++++++++++++++++++++++++ tgt-vvp/vvp_priv.h | 5 +++++ tgt-vvp/vvp_scope.c | 5 +++++ 8 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 tgt-vvp/draw_switch.c diff --git a/ivl.def b/ivl.def index 48b798910..7d0751006 100644 --- a/ivl.def +++ b/ivl.def @@ -222,10 +222,12 @@ ivl_switch_a ivl_switch_b ivl_switch_basename ivl_switch_enable +ivl_switch_file +ivl_switch_lineno ivl_switch_scope ivl_switch_type -ivl_switch_attr_cnt; -ivl_switch_attr_val; +ivl_switch_attr_cnt +ivl_switch_attr_val ivl_udp_init ivl_udp_name diff --git a/ivl_target.h b/ivl_target.h index a39366a18..7f09116ea 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -1879,6 +1879,9 @@ extern ivl_nexus_t ivl_switch_enable(ivl_switch_t net); extern unsigned ivl_switch_attr_cnt(ivl_switch_t net); extern ivl_attribute_t ivl_switch_attr_val(ivl_switch_t net, unsigned idx); +extern const char* ivl_switch_file(ivl_switch_t net); +extern unsigned ivl_switch_lineno(ivl_switch_t net); + #if defined(__MINGW32__) || defined (__CYGWIN32__) # define DLLEXPORT __declspec(dllexport) #else diff --git a/t-dll-api.cc b/t-dll-api.cc index aa2733854..cbfbf7e84 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -2181,3 +2181,13 @@ extern "C" ivl_nexus_t ivl_switch_enable(ivl_switch_t net) { return net->pins[2]; } + +extern "C" const char* ivl_switch_file(ivl_switch_t net) +{ + return net->file; +} + +extern "C" unsigned ivl_switch_lineno(ivl_switch_t net) +{ + return net->lineno; +} diff --git a/t-dll.cc b/t-dll.cc index 15cc19eac..2fd382f29 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -1063,6 +1063,9 @@ bool dll_target::tran(const NetTran*net) obj->pins[2] = 0; } + obj->file = net->get_file(); + obj->lineno = net->get_lineno(); + switch_attributes(obj, net); scope_add_switch(obj->scope, obj); diff --git a/tgt-vvp/Makefile.in b/tgt-vvp/Makefile.in index c9b6b5098..79664e616 100644 --- a/tgt-vvp/Makefile.in +++ b/tgt-vvp/Makefile.in @@ -51,7 +51,7 @@ dep: $(CC) $(CPPFLAGS) $(CFLAGS) -MD -c $< -o $*.o mv $*.d dep -O = vvp.o draw_mux.o draw_ufunc.o draw_vpi.o eval_bool.o eval_expr.o \ +O = vvp.o draw_mux.o draw_switch.o draw_ufunc.o draw_vpi.o eval_bool.o eval_expr.o \ eval_real.o modpath.o vector.o \ vvp_process.o vvp_scope.o diff --git a/tgt-vvp/draw_switch.c b/tgt-vvp/draw_switch.c new file mode 100644 index 000000000..0cbc88e3d --- /dev/null +++ b/tgt-vvp/draw_switch.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2008 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 "vvp_priv.h" +# include +#ifdef HAVE_MALLOC_H +# include +#endif +# include +# include + +void draw_switch_in_scope(ivl_switch_t sw) +{ + fprintf(stderr, "%s:%u: sorry: vvp target does not support switch modeling.\n", + ivl_switch_file(sw), ivl_switch_lineno(sw)); + vvp_errors += 1; +} diff --git a/tgt-vvp/vvp_priv.h b/tgt-vvp/vvp_priv.h index 53c31618e..ffb2f12d3 100644 --- a/tgt-vvp/vvp_priv.h +++ b/tgt-vvp/vvp_priv.h @@ -104,6 +104,11 @@ extern struct vector_info draw_vpi_func_call(ivl_expr_t exp, unsigned wid); extern int draw_vpi_rfunc_call(ivl_expr_t exp); +/* + * Switches (tran) + */ +extern void draw_switch_in_scope(ivl_switch_t sw); + /* * Given a nexus, draw a string that represents the functor output * that feeds the nexus. This function can be used to get the input to diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index 7900c30fb..9499efe4d 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -2569,6 +2569,11 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent) draw_lpm_in_scope(lpm); } + for (idx = 0 ; idx < ivl_scope_switches(net) ; idx += 1) { + ivl_switch_t sw = ivl_scope_switch(net, idx); + draw_switch_in_scope(sw); + } + if (ivl_scope_type(net) == IVL_SCT_TASK) draw_task_definition(net);