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.
This commit is contained in:
Stephen Williams 2008-05-27 20:06:58 -07:00
parent 3575f68c9f
commit de7fff8ac6
8 changed files with 64 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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

33
tgt-vvp/draw_switch.c Normal file
View File

@ -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 <assert.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
# include <stdlib.h>
# include <string.h>
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;
}

View File

@ -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

View File

@ -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);