Skip to content

Commit

Permalink
Add support for bit select of parameters.
Browse files Browse the repository at this point in the history
 This leads to a NetESelect node and the
 vvp code generator to support that.
  • Loading branch information
steve committed Jan 28, 2002
1 parent 712080f commit 364ffc9
Show file tree
Hide file tree
Showing 14 changed files with 225 additions and 81 deletions.
6 changes: 3 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
#ident "$Id: Makefile.in,v 1.112 2002/01/25 03:25:16 steve Exp $"
#ident "$Id: Makefile.in,v 1.113 2002/01/28 00:52:41 steve Exp $"
#
#
SHELL = /bin/sh
Expand Down Expand Up @@ -117,8 +117,8 @@ elab_lval.o elab_net.o elab_anet.o elab_pexpr.o elab_scope.o \
elab_sig.o emit.o eval.o eval_rconst.o \
eval_tree.o expr_synth.o functor.o lexor.o lexor_keyword.o link_const.o \
load_module.o mangle.o netlist.o netmisc.o net_assign.o \
net_design.o net_event.o net_force.o net_link.o net_modulo.o net_proc.o \
net_scope.o net_udp.o pad_to_width.o \
net_design.o net_event.o net_expr.o net_force.o net_link.o net_modulo.o \
net_proc.o net_scope.o net_udp.o pad_to_width.o \
parse.o parse_misc.o pform.o pform_dump.o \
set_width.o \
verinum.o verireal.o target.o targets.o \
Expand Down
3 changes: 3 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ constructs.

- trireg is not supported. tri0 and tri1 are supported.

- force to nets are not supported. Force to variables, and
assign/deassign, are supported.

6.0 CREDITS

Expand All @@ -430,6 +432,7 @@ Verilog guidance, and especially testing from many people, including
Stuart Sutherland <stuart@sutherland.com>
Stephen Tell <tell@cs.unc.edu>
Stefan Theide <Stefan.Thiede@sv.sc.philips.com>
Tom Verbeure
Steve Wilson <stevew@home.com>

and others. Testers in particular include a larger community of people
Expand Down
13 changes: 12 additions & 1 deletion dup_expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: dup_expr.cc,v 1.6 2001/11/19 01:54:14 steve Exp $"
#ident "$Id: dup_expr.cc,v 1.7 2002/01/28 00:52:41 steve Exp $"
#endif

# include "config.h"
Expand All @@ -31,6 +31,12 @@ NetEScope* NetEScope::dup_expr() const
return 0;
}

NetESelect* NetESelect::dup_expr() const
{
return new NetESelect(expr_->dup_expr(), base_->dup_expr(),
expr_width());
}

NetESFunc* NetESFunc::dup_expr() const
{
NetESFunc*tmp = new NetESFunc(name_, expr_width(), nparms());
Expand Down Expand Up @@ -68,6 +74,11 @@ NetEUnary* NetEUnary::dup_expr() const

/*
* $Log: dup_expr.cc,v $
* Revision 1.7 2002/01/28 00:52:41 steve
* Add support for bit select of parameters.
* This leads to a NetESelect node and the
* vvp code generator to support that.
*
* Revision 1.6 2001/11/19 01:54:14 steve
* Port close cropping behavior from mcrgb
* Move window array reset to libmc.
Expand Down
24 changes: 23 additions & 1 deletion elab_expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: elab_expr.cc,v 1.49 2002/01/11 05:25:45 steve Exp $"
#ident "$Id: elab_expr.cc,v 1.50 2002/01/28 00:52:41 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -415,6 +415,23 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope) const
else
tmp = new NetEParam(des, scope, path_);

if (msb_ && lsb_) {
cerr << get_line() << ": error: part select of "
<< "parameter " << path_ << " in " << scope->name()
<< " is illegal." << endl;
des->errors += 1;

} else if (msb_) {
/* Handle the case where a parameter has a bit
select attached to it. Generate a NetESelect
object to select the bit as desired. */
NetExpr*mtmp = msb_->elaborate_expr(des, scope);
NetESelect*stmp = new NetESelect(tmp, mtmp, 1);
tmp->set_line(*this);
tmp = stmp;
}


tmp->set_line(*this);
return tmp;
}
Expand Down Expand Up @@ -673,6 +690,11 @@ NetEUnary* PEUnary::elaborate_expr(Design*des, NetScope*scope) const

/*
* $Log: elab_expr.cc,v $
* Revision 1.50 2002/01/28 00:52:41 steve
* Add support for bit select of parameters.
* This leads to a NetESelect node and the
* vvp code generator to support that.
*
* Revision 1.49 2002/01/11 05:25:45 steve
* The stime system function is 32bits.
*
Expand Down
13 changes: 12 additions & 1 deletion elab_pexpr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: elab_pexpr.cc,v 1.12 2001/12/03 04:47:14 steve Exp $"
#ident "$Id: elab_pexpr.cc,v 1.13 2002/01/28 00:52:41 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -152,6 +152,12 @@ NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const
return 0;
}

if (msb_ || lsb_ || idx_) {
cerr << get_line() << ": error: Cannot bit/part select "
"bits of parameters." << endl;
des->errors += 1;
}

NetExpr*res = new NetEParam(des, pscope, hname_t(name));
assert(res);
delete name;
Expand Down Expand Up @@ -218,6 +224,11 @@ NetExpr*PEUnary::elaborate_pexpr (Design*des, NetScope*scope) const

/*
* $Log: elab_pexpr.cc,v $
* Revision 1.13 2002/01/28 00:52:41 steve
* Add support for bit select of parameters.
* This leads to a NetESelect node and the
* vvp code generator to support that.
*
* Revision 1.12 2001/12/03 04:47:14 steve
* Parser and pform use hierarchical names as hname_t
* objects instead of encoded strings.
Expand Down
12 changes: 11 additions & 1 deletion emit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: emit.cc,v 1.64 2002/01/19 19:02:08 steve Exp $"
#ident "$Id: emit.cc,v 1.65 2002/01/28 00:52:41 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -434,6 +434,11 @@ void NetEScope::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_scope(this);
}

void NetESelect::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_select(this);
}

void NetESFunc::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_sfunc(this);
Expand Down Expand Up @@ -477,6 +482,11 @@ bool emit(const Design*des, const char*type)

/*
* $Log: emit.cc,v $
* Revision 1.65 2002/01/28 00:52:41 steve
* Add support for bit select of parameters.
* This leads to a NetESelect node and the
* vvp code generator to support that.
*
* Revision 1.64 2002/01/19 19:02:08 steve
* Pass back target errors processing conditionals.
*
Expand Down
8 changes: 7 additions & 1 deletion ivl_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: ivl_target.h,v 1.91 2002/01/03 04:19:01 steve Exp $"
#ident "$Id: ivl_target.h,v 1.92 2002/01/28 00:52:41 steve Exp $"
#endif

#ifdef __cplusplus
Expand Down Expand Up @@ -164,6 +164,7 @@ typedef enum ivl_expr_type_e {
IVL_EX_MEMORY,
IVL_EX_NUMBER,
IVL_EX_SCOPE,
IVL_EX_SELECT,
IVL_EX_SFUNC,
IVL_EX_SIGNAL,
IVL_EX_STRING,
Expand Down Expand Up @@ -977,6 +978,11 @@ _END_DECL

/*
* $Log: ivl_target.h,v $
* Revision 1.92 2002/01/28 00:52:41 steve
* Add support for bit select of parameters.
* This leads to a NetESelect node and the
* vvp code generator to support that.
*
* Revision 1.91 2002/01/03 04:19:01 steve
* Add structural modulus support down to vvp.
*
Expand Down
35 changes: 33 additions & 2 deletions netlist.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __netlist_H
#define __netlist_H
/*
* Copyright (c) 1998-2000 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2002 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
Expand All @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netlist.h,v 1.230 2002/01/22 01:40:04 steve Exp $"
#ident "$Id: netlist.h,v 1.231 2002/01/28 00:52:41 steve Exp $"
#endif

/*
Expand Down Expand Up @@ -2308,6 +2308,32 @@ class NetEParam : public NetExpr {
};


/*
* This expression node supports bit/part selects from general
* expressions. The sub-expression is self-sized, and has bits
* selected from it. The base is the expression that identifies the
* lsb of the expression, and the wid is the width of the part select,
* or 1 for a bit select.
*/
class NetESelect : public NetExpr {

public:
NetESelect(NetExpr*exp, NetExpr*base, unsigned wid);
~NetESelect();

const NetExpr*sub_expr() const;
const NetExpr*select() const;

virtual bool set_width(unsigned w);
virtual bool has_width() const;
virtual void expr_scan(struct expr_scan_t*) const;
virtual NetESelect* dup_expr() const;

private:
NetExpr*expr_;
NetExpr*base_;
};

/*
* This class is a special (and magical) expression node type that
* represents scope names. These can only be found as parameters to
Expand Down Expand Up @@ -2865,6 +2891,11 @@ extern ostream& operator << (ostream&, NetNet::Type);

/*
* $Log: netlist.h,v $
* Revision 1.231 2002/01/28 00:52:41 steve
* Add support for bit select of parameters.
* This leads to a NetESelect node and the
* vvp code generator to support that.
*
* Revision 1.230 2002/01/22 01:40:04 steve
* Precalculate constant results of memory index expressions.
*
Expand Down
9 changes: 8 additions & 1 deletion t-dll-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll-api.cc,v 1.74 2002/01/03 04:19:01 steve Exp $"
#ident "$Id: t-dll-api.cc,v 1.75 2002/01/28 00:52:41 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -272,6 +272,7 @@ extern "C" ivl_expr_t ivl_expr_oper1(ivl_expr_t net)
assert(net);
switch (net->type_) {
case IVL_EX_BINARY:
case IVL_EX_SELECT:
return net->u_.binary_.lef_;

case IVL_EX_BITSEL:
Expand All @@ -298,6 +299,7 @@ extern "C" ivl_expr_t ivl_expr_oper2(ivl_expr_t net)
assert(net);
switch (net->type_) {
case IVL_EX_BINARY:
case IVL_EX_SELECT:
return net->u_.binary_.rig_;

case IVL_EX_TERNARY:
Expand Down Expand Up @@ -1450,6 +1452,11 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)

/*
* $Log: t-dll-api.cc,v $
* Revision 1.75 2002/01/28 00:52:41 steve
* Add support for bit select of parameters.
* This leads to a NetESelect node and the
* vvp code generator to support that.
*
* Revision 1.74 2002/01/03 04:19:01 steve
* Add structural modulus support down to vvp.
*
Expand Down
29 changes: 28 additions & 1 deletion t-dll-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) & !defined(macintosh)
#ident "$Id: t-dll-expr.cc,v 1.21 2001/12/31 00:08:14 steve Exp $"
#ident "$Id: t-dll-expr.cc,v 1.22 2002/01/28 00:52:41 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -161,6 +161,28 @@ void dll_target::expr_scope(const NetEScope*net)
expr_->u_.scope_.scope = lookup_scope_(net->scope());
}

void dll_target::expr_select(const NetESelect*net)
{
assert(expr_ == 0);

net->sub_expr()->expr_scan(this);
ivl_expr_t left = expr_;

expr_ = 0;
net->select()->expr_scan(this);
ivl_expr_t rght = expr_;

expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
assert(expr_);

expr_->type_ = IVL_EX_SELECT;
expr_->width_= net->expr_width();
expr_->signed_ = net->has_sign()? 1 : 0;

expr_->u_.binary_.lef_ = left;
expr_->u_.binary_.rig_ = rght;
}

void dll_target::expr_sfunc(const NetESFunc*net)
{
assert(expr_ == 0);
Expand Down Expand Up @@ -347,6 +369,11 @@ void dll_target::expr_unary(const NetEUnary*net)

/*
* $Log: t-dll-expr.cc,v $
* Revision 1.22 2002/01/28 00:52:41 steve
* Add support for bit select of parameters.
* This leads to a NetESelect node and the
* vvp code generator to support that.
*
* Revision 1.21 2001/12/31 00:08:14 steve
* Support $signed cast of expressions.
*
Expand Down
8 changes: 7 additions & 1 deletion t-dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll.h,v 1.74 2002/01/19 19:02:08 steve Exp $"
#ident "$Id: t-dll.h,v 1.75 2002/01/28 00:52:41 steve Exp $"
#endif

# include "target.h"
Expand Down Expand Up @@ -131,6 +131,7 @@ struct dll_target : public target_t, public expr_scan_t {
void expr_memory(const NetEMemory*);
void expr_const(const NetEConst*);
void expr_scope(const NetEScope*);
void expr_select(const NetESelect*);
void expr_sfunc(const NetESFunc*);
void expr_subsignal(const NetEBitSel*);
void expr_ternary(const NetETernary*);
Expand Down Expand Up @@ -590,6 +591,11 @@ struct ivl_statement_s {

/*
* $Log: t-dll.h,v $
* Revision 1.75 2002/01/28 00:52:41 steve
* Add support for bit select of parameters.
* This leads to a NetESelect node and the
* vvp code generator to support that.
*
* Revision 1.74 2002/01/19 19:02:08 steve
* Pass back target errors processing conditionals.
*
Expand Down
Loading

0 comments on commit 364ffc9

Please sign in to comment.