Permalink
Browse files

Add more file/line and scope information to the ivl interface, etc.

This patch adds/fixes the following:

  Adds file/line information to a UDP definition.

  Prints an error message if a UDP is passed signals wider than 1 bit.
  A UDP should supports a range, but the compiler currently does not.

  Add scope information for constants.

  Fix the Icarus extension UDP table entry element 'h' to use h.

  The ivl_udp_init() value is a char not unsigned.

  Add FILE_NAME() for a bunch more of the ivl interface objects.
  • Loading branch information...
1 parent 131a3d8 commit 427aef8cc48d6a9c555e5cc6022553b618c1f52d @caryr caryr committed with steveicarus Feb 7, 2011
Showing with 137 additions and 48 deletions.
  1. +3 −2 PUdp.h
  2. +16 −2 elaborate.cc
  3. +3 −0 ivl.def
  4. +8 −2 ivl_target.h
  5. +2 −0 netlist.h
  6. +1 −1 parse.y
  7. +2 −0 pform.cc
  8. +18 −3 t-dll-api.cc
  9. +12 −8 t-dll-expr.cc
  10. +1 −0 t-dll-proc.cc
  11. +37 −17 t-dll.cc
  12. +31 −10 t-dll.h
  13. +3 −3 tgt-stub/stub.c
View
5 PUdp.h
@@ -1,7 +1,7 @@
#ifndef __PUdp_H
#define __PUdp_H
/*
- * Copyright (c) 1998-2004 Stephen Williams (steve@picturel.com)
+ * Copyright (c) 1998-2011 Stephen Williams (steve@picturel.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
@@ -20,6 +20,7 @@
*/
# include <map>
+# include "LineInfo.h"
# include "StringHeap.h"
# include "svector.h"
# include "verinum.h"
@@ -47,7 +48,7 @@ class PExpr;
* If the UDP is sequential, the "initial" member is taken to be the
* initial value assigned in the source, or 'x' if none is given.
*/
-class PUdp {
+class PUdp : public LineInfo {
public:
explicit PUdp(perm_string n, unsigned nports);
View
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2010 Stephen Williams (steve@icarus.com)
+ * Copyright (c) 1998-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
@@ -1867,6 +1867,13 @@ void PGModule::elaborate_udp_(Design*des, PUdp*udp, NetScope*scope) const
} else {
connect(sig->pin(0), net->pin(0));
}
+ if (sig->vector_width() != 1) {
+ cerr << get_fileline() << ": error: "
+ << "Output port expression " << *pins[0]
+ << " is too wide (" << sig->vector_width()
+ << ") expected 1." << endl;
+ des->errors += 1;
+ }
}
/* Run through the pins, making netlists for the pin
@@ -1879,7 +1886,7 @@ void PGModule::elaborate_udp_(Design*des, PUdp*udp, NetScope*scope) const
NetExpr*expr_tmp = elab_and_eval(des, scope, pins[idx], 1, 1);
if (expr_tmp == 0) {
cerr << "internal error: Expression too complicated "
- "for elaboration:" << pins[idx] << endl;
+ "for elaboration:" << *pins[idx] << endl;
continue;
}
NetNet*sig = expr_tmp->synthesize(des, scope, expr_tmp);
@@ -1889,6 +1896,13 @@ void PGModule::elaborate_udp_(Design*des, PUdp*udp, NetScope*scope) const
delete expr_tmp;
connect(sig->pin(0), net->pin(idx));
+ if (sig->vector_width() != 1) {
+ cerr << get_fileline() << ": error: "
+ << "Input port expression " << *pins[idx]
+ << " is too wide (" << sig->vector_width()
+ << ") expected 1." << endl;
+ des->errors += 1;
+ }
}
// All done. Add the object to the design.
View
@@ -19,6 +19,7 @@ ivl_const_delay
ivl_const_file
ivl_const_lineno
ivl_const_real
+ivl_const_scope
ivl_const_signed
ivl_const_type
ivl_const_width
@@ -281,6 +282,8 @@ ivl_switch_type
ivl_switch_width
ivl_udp_init
+ivl_udp_file
+ivl_udp_lineno
ivl_udp_name
ivl_udp_nin
ivl_udp_row
View
@@ -561,6 +561,9 @@ extern ivl_discipline_t ivl_design_discipline(ivl_design_t des, unsigned idx);
* ivl_const_nex
* Return the ivl_nexus_t of the output for the constant.
*
+ * ivl_const_scope
+ * Return the scope this constant was defined in.
+
* ivl_const_signed
* Return true (!0) if the constant is a signed value, 0 otherwise.
*
@@ -587,6 +590,7 @@ extern ivl_variable_type_t ivl_const_type(ivl_net_const_t net);
extern const char* ivl_const_bits(ivl_net_const_t net);
extern ivl_expr_t ivl_const_delay(ivl_net_const_t net, unsigned transition);
extern ivl_nexus_t ivl_const_nex(ivl_net_const_t net);
+extern ivl_scope_t ivl_const_scope(ivl_net_const_t net);
extern int ivl_const_signed(ivl_net_const_t net);
extern unsigned ivl_const_width(ivl_net_const_t net);
extern double ivl_const_real(ivl_net_const_t net);
@@ -1025,13 +1029,15 @@ extern ivl_attribute_t ivl_logic_attr_val(ivl_net_logic_t net, unsigned idx);
extern int ivl_udp_sequ(ivl_udp_t net);
extern unsigned ivl_udp_nin(ivl_udp_t net);
-extern unsigned ivl_udp_init(ivl_udp_t net);
+extern char ivl_udp_init(ivl_udp_t net);
extern const char* ivl_udp_row(ivl_udp_t net, unsigned idx);
extern unsigned ivl_udp_rows(ivl_udp_t net);
extern const char* ivl_udp_name(ivl_udp_t net);
+extern const char* ivl_udp_file(ivl_udp_t net);
+extern unsigned ivl_udp_lineno(ivl_udp_t net);
extern const char* ivl_lpm_file(ivl_lpm_t net);
-extern unsigned ivl_lpm_lineno(ivl_lpm_t net);
+extern unsigned ivl_lpm_lineno(ivl_lpm_t net);
/* LPM
* These functions support access to the properties of LPM
View
@@ -2165,6 +2165,8 @@ class NetUDP : public NetNode {
unsigned nin() const { return pin_count()-1; }
bool is_sequential() const { return udp->sequential; }
perm_string udp_name() const { return udp->name_; }
+ perm_string udp_file() const { return udp->get_file(); }
+ unsigned udp_lineno() const { return udp->get_lineno(); }
char get_initial() const;
private:
View
@@ -4803,7 +4803,7 @@ udp_input_sym
| 'f' { $$ = 'f'; }
| 'F' { $$ = 'F'; }
| 'l' { $$ = 'l'; }
- | 'h' { $$ = 'H'; }
+ | 'h' { $$ = 'h'; }
| 'B' { $$ = 'B'; }
| 'r' { $$ = 'r'; }
| 'R' { $$ = 'R'; }
View
@@ -1312,6 +1312,7 @@ void pform_make_udp(perm_string name, list<perm_string>*parms,
} else {
PUdp*udp = new PUdp(name, parms->size());
+ FILE_NAME(udp, file, lineno);
// Detect sequential udp.
if (pins[0]->get_wire_type() == NetNet::REG)
@@ -1392,6 +1393,7 @@ void pform_make_udp(perm_string name, bool synchronous_flag,
} else {
PUdp*udp = new PUdp(name, pins.count());
+ FILE_NAME(udp, file, lineno);
// Detect sequential udp.
udp->sequential = synchronous_flag;
View
@@ -211,6 +211,12 @@ extern "C" double ivl_const_real(ivl_net_const_t net)
return net->b.real_value;
}
+extern "C" ivl_scope_t ivl_const_scope(ivl_net_const_t net)
+{
+ assert(net);
+ return net->scope;
+}
+
extern "C" int ivl_const_signed(ivl_net_const_t net)
{
assert(net);
@@ -838,12 +844,12 @@ extern "C" int ivl_udp_sequ(ivl_udp_t net)
return net->sequ;
}
-extern "C" unsigned ivl_udp_nin(ivl_udp_t net)
+extern "C" unsigned ivl_udp_nin(ivl_udp_t net)
{
return net->nin;
}
-extern "C" unsigned ivl_udp_init(ivl_udp_t net)
+extern "C" char ivl_udp_init(ivl_udp_t net)
{
return net->init;
}
@@ -867,6 +873,16 @@ extern "C" const char* ivl_udp_name(ivl_udp_t net)
return net->name;
}
+extern "C" const char* ivl_udp_file(ivl_udp_t net)
+{
+ return net->file.str();
+}
+
+extern "C" unsigned ivl_udp_lineno(ivl_udp_t net)
+{
+ return net->lineno;
+}
+
extern "C" const char* ivl_lpm_basename(ivl_lpm_t net)
{
return net->name;
@@ -1010,7 +1026,6 @@ extern "C" ivl_nexus_t ivl_lpm_enable(ivl_lpm_t net)
}
}
-/* The file name and line number are only set for system functions! */
extern "C" const char* ivl_lpm_file(ivl_lpm_t net)
{
return net->file.str();
View
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000-2010 Stephen Williams (steve@icarus.com)
+ * Copyright (c) 2000-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
@@ -158,11 +158,10 @@ void dll_target::expr_access_func(const NetEAccess*net)
expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
expr_->type_ = IVL_EX_BACCESS;
expr_->value_ = IVL_VT_REAL;
- expr_->file = net->get_file();
- expr_->lineno = net->get_lineno();
expr_->width_ = 1;
expr_->signed_= 1;
expr_->sized_ = 1;
+ FILE_NAME(expr_, net);
expr_->u_.branch_.branch = net->get_branch()->target_obj();
expr_->u_.branch_.nature = net->get_nature();
@@ -186,6 +185,7 @@ void dll_target::expr_binary(const NetEBinary*net)
expr_->width_= net->expr_width();
expr_->signed_ = net->has_sign()? 1 : 0;
expr_->sized_= 1;
+ FILE_NAME(expr_, net);
expr_->u_.binary_.op_ = net->op();
expr_->u_.binary_.lef_ = left;
@@ -204,6 +204,7 @@ void dll_target::expr_concat(const NetEConcat*net)
cur->width_ = net->expr_width();
cur->signed_ = net->has_sign() ? 1 : 0;
cur->sized_ = 1;
+ FILE_NAME(cur, net);
cur->u_.concat_.rept = net->repeat();
cur->u_.concat_.parms = net->nparms();
@@ -336,6 +337,7 @@ void dll_target::expr_scope(const NetEScope*net)
expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
expr_->type_ = IVL_EX_SCOPE;
+ FILE_NAME(expr_, net);
expr_->value_= IVL_VT_VOID;
expr_->u_.scope_.scope = lookup_scope_(net->scope());
}
@@ -347,6 +349,7 @@ void dll_target::expr_netenum(const NetENetenum*net)
expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
expr_->type_ = IVL_EX_ENUMTYPE;
+ FILE_NAME(expr_, net);
expr_->value_= IVL_VT_VOID;
expr_->u_.enumtype_.type = net->netenum();
}
@@ -365,13 +368,13 @@ void dll_target::expr_select(const NetESelect*net)
ivl_expr_t rght = expr_;
expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
- FILE_NAME(expr_, net);
expr_->type_ = IVL_EX_SELECT;
expr_->value_= IVL_VT_VECTOR;
expr_->width_= net->expr_width();
expr_->signed_ = net->has_sign()? 1 : 0;
expr_->sized_= 1;
+ FILE_NAME(expr_, net);
expr_->u_.binary_.lef_ = left;
expr_->u_.binary_.rig_ = rght;
@@ -389,6 +392,7 @@ void dll_target::expr_sfunc(const NetESFunc*net)
expr->width_= net->expr_width();
expr->signed_ = net->has_sign()? 1 : 0;
expr->sized_= 1;
+ FILE_NAME(expr, net);
/* system function names are lex_strings strings. */
expr->u_.sfunc_.name_ = net->name();
@@ -414,11 +418,11 @@ void dll_target::expr_ternary(const NetETernary*net)
ivl_expr_t expr = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
expr->type_ = IVL_EX_TERNARY;
- FILE_NAME(expr, net);
expr->value_= net->expr_type();
expr->width_ = net->expr_width();
expr->signed_ = net->has_sign()? 1 : 0;
expr->sized_ = 1;
+ FILE_NAME(expr, net);
net->cond_expr()->expr_scan(this);
assert(expr_);
@@ -456,11 +460,10 @@ void dll_target::expr_signal(const NetESignal*net)
expr_->type_ = IVL_EX_SIGNAL;
expr_->value_= net->expr_type();
- expr_->file = net->get_file();
- expr_->lineno= net->get_lineno();
expr_->width_= net->expr_width();
expr_->signed_ = net->has_sign()? 1 : 0;
expr_->sized_= 1;
+ FILE_NAME(expr_, net);
expr_->u_.signal_.word = word_expr;
expr_->u_.signal_.sig = sig;
@@ -483,11 +486,11 @@ void dll_target::expr_ufunc(const NetEUFunc*net)
ivl_expr_t expr = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
expr->type_ = IVL_EX_UFUNC;
- FILE_NAME(expr, net);
expr->value_= net->expr_type();
expr->width_= net->expr_width();
expr->signed_ = net->has_sign()? 1 : 0;
expr->sized_= 1;
+ FILE_NAME(expr, net);
expr->u_.ufunc_.def = lookup_scope_(net->func());
assert(expr->u_.ufunc_.def->type_ == IVL_SCT_FUNCTION);
@@ -522,6 +525,7 @@ void dll_target::expr_unary(const NetEUnary*net)
expr_->width_ = net->expr_width();
expr_->signed_ = net->has_sign()? 1 : 0;
expr_->sized_ = 1;
+ FILE_NAME(expr_, net);
expr_->u_.unary_.op_ = net->op();
expr_->u_.unary_.sub_ = sub;
}
View
@@ -600,6 +600,7 @@ bool dll_target::proc_force(const NetForce*net)
assert(stmt_cur_);
assert(stmt_cur_->type_ == IVL_ST_NONE);
+ FILE_NAME(stmt_cur_, net);
stmt_cur_->type_ = IVL_ST_FORCE;
Oops, something went wrong.

0 comments on commit 427aef8

Please sign in to comment.