Cary R.'s additional system functions, real value error messages, etc.

I've changed the find_entity() error messages to asserts since
this should be fixed by the previous patch.
This commit is contained in:
Nick Gasson 2008-09-06 12:06:01 +01:00
parent a34348bb35
commit 6fe7583784
6 changed files with 83 additions and 11 deletions

View File

@ -40,7 +40,7 @@ CPPFLAGS = @ident_support@ -I. -I$(srcdir)/.. @CPPFLAGS@ @DEFS@ @PICFLAG@
CXXFLAGS = -Wall @CXXFLAGS@ CXXFLAGS = -Wall @CXXFLAGS@
LDFLAGS = @LDFLAGS@ LDFLAGS = @LDFLAGS@
all: dep vhdl.tgt vhdl.conf all: dep vhdl.tgt vhdl.conf vhdl-s.conf
dep: dep:
mkdir dep mkdir dep
@ -74,7 +74,8 @@ distclean: clean
check: all check: all
install: all installdirs $(libdir)/ivl/vhdl.tgt $(libdir)/ivl/vhdl.conf install: all installdirs $(libdir)/ivl/vhdl.tgt $(libdir)/ivl/vhdl.conf \
$(libdir)/ivl/vhdl-s.conf
$(libdir)/ivl/vhdl.tgt: ./vhdl.tgt $(libdir)/ivl/vhdl.tgt: ./vhdl.tgt
$(INSTALL_PROGRAM) ./vhdl.tgt $(DESTDIR)$(libdir)/ivl/vhdl.tgt $(INSTALL_PROGRAM) ./vhdl.tgt $(DESTDIR)$(libdir)/ivl/vhdl.tgt
@ -82,6 +83,9 @@ $(libdir)/ivl/vhdl.tgt: ./vhdl.tgt
$(libdir)/ivl/vhdl.conf: vhdl.conf $(libdir)/ivl/vhdl.conf: vhdl.conf
$(INSTALL_DATA) $< $(DESTDIR)$(libdir)/ivl/vhdl.conf $(INSTALL_DATA) $< $(DESTDIR)$(libdir)/ivl/vhdl.conf
$(libdir)/ivl/vhdl-s.conf: vhdl-s.conf
$(INSTALL_DATA) $< $(DESTDIR)$(libdir)/ivl/vhdl-s.conf
installdirs: ../mkinstalldirs installdirs: ../mkinstalldirs
$(srcdir)/../mkinstalldirs $(DESTDIR)$(libdir)/ivl $(srcdir)/../mkinstalldirs $(DESTDIR)$(libdir)/ivl

View File

@ -505,8 +505,42 @@ static vhdl_expr *translate_concat(ivl_expr_t e)
vhdl_expr *translate_sfunc_time(ivl_expr_t e) vhdl_expr *translate_sfunc_time(ivl_expr_t e)
{ {
cerr << "warning: no translation for time (returning 0)" << endl; cerr << "warning: no translation for $time (returning 0)" << endl;
return new vhdl_const_int(0); vhdl_expr *result = new vhdl_const_int(0);
result->set_comment("$time not supported, returned 0 instead!");
return result;
}
vhdl_expr *translate_sfunc_stime(ivl_expr_t e)
{
cerr << "warning: no translation for $stime (returning 0)" << endl;
vhdl_expr *result = new vhdl_const_int(0);
result->set_comment("$stime not supported, returned 0 instead!");
return result;
}
vhdl_expr *translate_sfunc_simtime(ivl_expr_t e)
{
cerr << "warning: no translation for $simtime (returning 0)" << endl;
vhdl_expr *result = new vhdl_const_int(0);
result->set_comment("$simtime not supported, returned 0 instead!");
return result;
}
vhdl_expr *translate_sfunc_random(ivl_expr_t e)
{
cerr << "warning: no translation for $random (returning 0)" << endl;
vhdl_expr *result = new vhdl_const_int(0);
result->set_comment("$random not supported, returned 0 instead!");
return result;
}
vhdl_expr *translate_sfunc_fopen(ivl_expr_t e)
{
cerr << "warning: no translation for $fopen (returning 0)" << endl;
vhdl_expr *result = new vhdl_const_int(0);
result->set_comment("$fopen not supported, returned 0 instead!");
return result;
} }
vhdl_expr *translate_sfunc(ivl_expr_t e) vhdl_expr *translate_sfunc(ivl_expr_t e)
@ -514,6 +548,14 @@ vhdl_expr *translate_sfunc(ivl_expr_t e)
const char *name = ivl_expr_name(e); const char *name = ivl_expr_name(e);
if (strcmp(name, "$time") == 0) if (strcmp(name, "$time") == 0)
return translate_sfunc_time(e); return translate_sfunc_time(e);
else if (strcmp(name, "$stime") == 0)
return translate_sfunc_stime(e);
else if (strcmp(name, "$simtime") == 0)
return translate_sfunc_simtime(e);
else if (strcmp(name, "$random") == 0)
return translate_sfunc_random(e);
else if (strcmp(name, "$fopen") == 0)
return translate_sfunc_random(e);
else { else {
error("No translation for system function %s", name); error("No translation for system function %s", name);
return NULL; return NULL;
@ -551,6 +593,10 @@ vhdl_expr *translate_expr(ivl_expr_t e)
return translate_concat(e); return translate_concat(e);
case IVL_EX_SFUNC: case IVL_EX_SFUNC:
return translate_sfunc(e); return translate_sfunc(e);
case IVL_EX_REALNUM:
error("No VHDL translation for real expression at %s:%d",
ivl_expr_file(e), ivl_expr_lineno(e));
return NULL;
default: default:
error("No VHDL translation for expression at %s:%d (type = %d)", error("No VHDL translation for expression at %s:%d (type = %d)",
ivl_expr_file(e), ivl_expr_lineno(e), type); ivl_expr_file(e), ivl_expr_lineno(e), type);

View File

@ -157,9 +157,10 @@ void draw_nexus(ivl_nexus_t nexus)
ivl_net_const_t con; ivl_net_const_t con;
if ((log = ivl_nexus_ptr_log(nexus_ptr))) { if ((log = ivl_nexus_ptr_log(nexus_ptr))) {
ivl_scope_t log_scope = ivl_logic_scope(log); ivl_scope_t log_scope = ivl_logic_scope(log);
vhdl_scope *vhdl_scope = vhdl_entity *ent = find_entity(ivl_scope_name(log_scope));
find_entity(ivl_scope_name(log_scope))->get_arch()->get_scope(); assert(ent);
vhdl_scope *vhdl_scope = ent->get_arch()->get_scope();
if (visible_nexus(priv, vhdl_scope)) { if (visible_nexus(priv, vhdl_scope)) {
// Already seen this signal in vhdl_scope // Already seen this signal in vhdl_scope
} }
@ -177,9 +178,10 @@ void draw_nexus(ivl_nexus_t nexus)
} }
else if ((lpm = ivl_nexus_ptr_lpm(nexus_ptr))) { else if ((lpm = ivl_nexus_ptr_lpm(nexus_ptr))) {
ivl_scope_t lpm_scope = ivl_lpm_scope(lpm); ivl_scope_t lpm_scope = ivl_lpm_scope(lpm);
vhdl_scope *vhdl_scope = vhdl_entity *ent = find_entity(ivl_scope_name(lpm_scope));
find_entity(ivl_scope_name(lpm_scope))->get_arch()->get_scope(); assert(ent);
vhdl_scope *vhdl_scope = ent->get_arch()->get_scope();
if (visible_nexus(priv, vhdl_scope)) { if (visible_nexus(priv, vhdl_scope)) {
// Already seen this signal in vhdl_scope // Already seen this signal in vhdl_scope
} }
@ -196,6 +198,11 @@ void draw_nexus(ivl_nexus_t nexus)
} }
} }
else if ((con = ivl_nexus_ptr_con(nexus_ptr))) { else if ((con = ivl_nexus_ptr_con(nexus_ptr))) {
if (ivl_const_type(con) == IVL_VT_REAL) {
error("No VHDL translation for real constant (%g)",
ivl_const_real(con));
continue;
}
if (ivl_const_width(con) == 1) if (ivl_const_width(con) == 1)
priv->const_driver = new vhdl_const_bit(ivl_const_bits(con)[0]); priv->const_driver = new vhdl_const_bit(ivl_const_bits(con)[0]);
else else

View File

@ -69,7 +69,13 @@ static int draw_stask(vhdl_procedural *proc, stmt_container *container,
else if (strcmp(name, "$finish") == 0) else if (strcmp(name, "$finish") == 0)
return draw_stask_finish(proc, container, stmt); return draw_stask_finish(proc, container, stmt);
else { else {
error("No VHDL translation for system task %s", name); vhdl_seq_stmt *result = new vhdl_null_stmt();
ostringstream ss;
ss << "Unsupported system task " << name << " omitted here ("
<< ivl_stmt_file(stmt) << ":" << ivl_stmt_lineno(stmt) << ")";
result->set_comment(ss.str());
container->add_stmt(result);
cerr << "Warning: no VHDL translation for system task " << name << endl;
return 0; return 0;
} }
} }

7
tgt-vhdl/vhdl-s.conf Normal file
View File

@ -0,0 +1,7 @@
functor:synth2
functor:synth
functor:syn-rules
functor:cprop
functor:nodangle
-t:dll
flag:DLL=vhdl.tgt

View File

@ -512,6 +512,7 @@ void vhdl_const_string::emit(std::ostream &of, int level) const
void vhdl_null_stmt::emit(std::ostream &of, int level) const void vhdl_null_stmt::emit(std::ostream &of, int level) const
{ {
of << "null;"; of << "null;";
emit_comment(of, level, true);
} }
void vhdl_fcall::emit(std::ostream &of, int level) const void vhdl_fcall::emit(std::ostream &of, int level) const
@ -584,6 +585,7 @@ void vhdl_const_bit::emit(std::ostream &of, int level) const
void vhdl_const_int::emit(std::ostream &of, int level) const void vhdl_const_int::emit(std::ostream &of, int level) const
{ {
of << value_; of << value_;
// We need to find a way to display a comment, since $time, etc. add one.
} }
void vhdl_const_bool::emit(std::ostream &of, int level) const void vhdl_const_bool::emit(std::ostream &of, int level) const