Skip to content

Commit

Permalink
Add support for signed reg variables,
Browse files Browse the repository at this point in the history
 simulate in t-vvm signed comparisons.
  • Loading branch information
steve committed Dec 11, 2000
1 parent 084a464 commit 5dbea64
Show file tree
Hide file tree
Showing 13 changed files with 273 additions and 38 deletions.
18 changes: 16 additions & 2 deletions PWire.cc
Expand Up @@ -17,14 +17,14 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: PWire.cc,v 1.3 2000/02/23 02:56:54 steve Exp $"
#ident "$Id: PWire.cc,v 1.4 2000/12/11 00:31:43 steve Exp $"
#endif

# include "PWire.h"
# include <assert.h>

PWire::PWire(const string&n, NetNet::Type t, NetNet::PortType pt)
: name_(n), type_(t), port_type_(pt), lidx_(0), ridx_(0)
: name_(n), type_(t), port_type_(pt), signed_(false), lidx_(0), ridx_(0)
{
}

Expand Down Expand Up @@ -83,6 +83,16 @@ bool PWire::set_port_type(NetNet::PortType pt)
}
}

void PWire::set_signed(bool flag)
{
signed_ = flag;
}

bool PWire::get_signed() const
{
return signed_;
}

void PWire::set_range(PExpr*m, PExpr*l)
{
msb_ = svector<PExpr*>(msb_,m);
Expand All @@ -100,6 +110,10 @@ void PWire::set_memory_idx(PExpr*ldx, PExpr*rdx)

/*
* $Log: PWire.cc,v $
* Revision 1.4 2000/12/11 00:31:43 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.3 2000/02/23 02:56:54 steve
* Macintosh compilers do not support ident.
*
Expand Down
10 changes: 9 additions & 1 deletion PWire.h
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: PWire.h,v 1.8 2000/05/02 16:27:38 steve Exp $"
#ident "$Id: PWire.h,v 1.9 2000/12/11 00:31:43 steve Exp $"
#endif

# include "netlist.h"
Expand Down Expand Up @@ -49,6 +49,9 @@ class PWire : public LineInfo {
NetNet::PortType get_port_type() const;
bool set_port_type(NetNet::PortType);

void set_signed(bool flag);
bool get_signed() const;

void set_range(PExpr*msb, PExpr*lsb);

void set_memory_idx(PExpr*ldx, PExpr*rdx);
Expand All @@ -64,6 +67,7 @@ class PWire : public LineInfo {
string name_;
NetNet::Type type_;
NetNet::PortType port_type_;
bool signed_;

// These members hold expressions for the bit width of the
// wire. If they do not exist, the wire is 1 bit wide.
Expand All @@ -82,6 +86,10 @@ class PWire : public LineInfo {

/*
* $Log: PWire.h,v $
* Revision 1.9 2000/12/11 00:31:43 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.8 2000/05/02 16:27:38 steve
* Move signal elaboration to a seperate pass.
*
Expand Down
8 changes: 7 additions & 1 deletion design_dump.cc
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: design_dump.cc,v 1.106 2000/12/10 06:41:59 steve Exp $"
#ident "$Id: design_dump.cc,v 1.107 2000/12/11 00:31:43 steve Exp $"
#endif

/*
Expand Down Expand Up @@ -73,6 +73,8 @@ void NetNet::dump_net(ostream&o, unsigned ind) const
pin_count() << "]";
if (local_flag_)
o << " (local)";
if (signed_)
o << " signed";
o << " (eref=" << get_eref() << ")";
if (scope())
o << " scope=" << scope()->name();
Expand Down Expand Up @@ -996,6 +998,10 @@ void Design::dump(ostream&o) const

/*
* $Log: design_dump.cc,v $
* Revision 1.107 2000/12/11 00:31:43 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.106 2000/12/10 06:41:59 steve
* Support delays on continuous assignment from idents. (PR#40)
*
Expand Down
7 changes: 6 additions & 1 deletion elab_sig.cc
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_sig.cc,v 1.6 2000/12/04 17:37:04 steve Exp $"
#ident "$Id: elab_sig.cc,v 1.7 2000/12/11 00:31:43 steve Exp $"
#endif

# include "Module.h"
Expand Down Expand Up @@ -341,12 +341,17 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
NetNet*sig = new NetNet(scope, path + "." +basename, wtype, msb, lsb);
sig->set_line(*this);
sig->port_type(port_type_);
sig->set_signed(get_signed());
sig->set_attributes(attributes);
}
}

/*
* $Log: elab_sig.cc,v $
* Revision 1.7 2000/12/11 00:31:43 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.6 2000/12/04 17:37:04 steve
* Add Attrib class for holding NetObj attributes.
*
Expand Down
27 changes: 23 additions & 4 deletions netlist.cc
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: netlist.cc,v 1.150 2000/12/05 06:29:33 steve Exp $"
#ident "$Id: netlist.cc,v 1.151 2000/12/11 00:31:43 steve Exp $"
#endif

# include <cassert>
Expand Down Expand Up @@ -303,7 +303,7 @@ NetNode* NetNode::next_node()

NetNet::NetNet(NetScope*s, const string&n, Type t, unsigned npins)
: NetObj(s, n, npins), sig_next_(0), sig_prev_(0),
type_(t), port_type_(NOT_A_PORT), msb_(npins-1), lsb_(0),
type_(t), port_type_(NOT_A_PORT), signed_(false), msb_(npins-1), lsb_(0),
local_flag_(false), eref_count_(0)
{
assert(s);
Expand Down Expand Up @@ -336,8 +336,8 @@ NetNet::NetNet(NetScope*s, const string&n, Type t, unsigned npins)
NetNet::NetNet(NetScope*s, const string&n, Type t, long ms, long ls)
: NetObj(s, n, ((ms>ls)?ms-ls:ls-ms) + 1), sig_next_(0),
sig_prev_(0), type_(t),
port_type_(NOT_A_PORT), msb_(ms), lsb_(ls), local_flag_(false),
eref_count_(0)
port_type_(NOT_A_PORT), signed_(false), msb_(ms), lsb_(ls),
local_flag_(false), eref_count_(0)
{
assert(s);

Expand Down Expand Up @@ -394,6 +394,16 @@ void NetNet::port_type(NetNet::PortType t)
port_type_ = t;
}

bool NetNet::get_signed() const
{
return signed_;
}

void NetNet::set_signed(bool flag)
{
signed_ = flag;
}

long NetNet::lsb() const
{
return lsb_;
Expand Down Expand Up @@ -2163,6 +2173,11 @@ string NetESignal::name() const
return net_->name();
}

bool NetESignal::has_sign() const
{
return net_->get_signed();
}

unsigned NetESignal::pin_count() const
{
return net_->pin_count();
Expand Down Expand Up @@ -2465,6 +2480,10 @@ bool NetUDP::sequ_glob_(string input, char output)

/*
* $Log: netlist.cc,v $
* Revision 1.151 2000/12/11 00:31:43 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.150 2000/12/05 06:29:33 steve
* Make signal attributes available to ivl_target API.
*
Expand Down
16 changes: 15 additions & 1 deletion netlist.h
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: netlist.h,v 1.185 2000/12/05 06:29:33 steve Exp $"
#ident "$Id: netlist.h,v 1.186 2000/12/11 00:31:43 steve Exp $"
#endif

/*
Expand Down Expand Up @@ -334,6 +334,11 @@ class NetNet : public NetObj, public LineInfo {
PortType port_type() const;
void port_type(PortType t);

/* If a NetNet is signed, then its value is to be treated as
signed. Otherwise, it is unsigned. */
bool get_signed() const;
void set_signed(bool);

/* These methods return the msb and lsb indices for the most
significant and least significant bits. These are signed
longs, and may be different from pin numbers. For example,
Expand Down Expand Up @@ -366,6 +371,7 @@ class NetNet : public NetObj, public LineInfo {
private:
Type type_;
PortType port_type_;
bool signed_;

long msb_, lsb_;

Expand Down Expand Up @@ -2477,6 +2483,10 @@ class NetESignal : public NetExpr {
NetESignal(NetNet*n);
~NetESignal();

// a NetESignal expression is signed if the NetNet that it
// refers to is signed.
bool has_sign() const;

string name() const;
virtual bool set_width(unsigned);

Expand Down Expand Up @@ -2825,6 +2835,10 @@ extern ostream& operator << (ostream&, NetNet::Type);

/*
* $Log: netlist.h,v $
* Revision 1.186 2000/12/11 00:31:43 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.185 2000/12/05 06:29:33 steve
* Make signal attributes available to ivl_target API.
*
Expand Down
7 changes: 3 additions & 4 deletions parse.y
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: parse.y,v 1.112 2000/12/10 22:01:36 steve Exp $"
#ident "$Id: parse.y,v 1.113 2000/12/11 00:31:43 steve Exp $"
#endif

# include "parse_misc.h"
Expand Down Expand Up @@ -195,13 +195,12 @@ source_file
rule has presumably set up the scope. */
block_item_decl
: K_reg range register_variable_list ';'
{ pform_set_net_range($3, $2);
{ pform_set_net_range($3, $2, false);
}
| K_reg register_variable_list ';'
{ delete $2; }
| K_reg K_signed range register_variable_list ';'
{ pform_set_net_range($4, $3);
yyerror(@2, "sorry: signed reg not supported.");
{ pform_set_net_range($4, $3, true);
}
| K_reg K_signed register_variable_list ';'
{ delete $3;
Expand Down
22 changes: 16 additions & 6 deletions pform.cc
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: pform.cc,v 1.67 2000/11/30 17:31:42 steve Exp $"
#ident "$Id: pform.cc,v 1.68 2000/12/11 00:31:43 steve Exp $"
#endif

# include "compiler.h"
Expand Down Expand Up @@ -328,7 +328,9 @@ void pform_make_udp(const char*name, list<string>*parms,
* only called by the parser within the scope of the net declaration,
* and the name that I receive only has the tail component.
*/
static void pform_set_net_range(const char*name, const svector<PExpr*>*range)
static void pform_set_net_range(const char*name,
const svector<PExpr*>*range,
bool signed_flag)
{
assert(range);
assert(range->count() == 2);
Expand All @@ -342,17 +344,20 @@ static void pform_set_net_range(const char*name, const svector<PExpr*>*range)
assert((*range)[0]);
assert((*range)[1]);
cur->set_range((*range)[0], (*range)[1]);
cur->set_signed(signed_flag);
}

void pform_set_net_range(list<char*>*names, svector<PExpr*>*range)
void pform_set_net_range(list<char*>*names,
svector<PExpr*>*range,
bool signed_flag)
{
assert(range->count() == 2);

for (list<char*>::iterator cur = names->begin()
; cur != names->end()
; cur ++ ) {
char*txt = *cur;
pform_set_net_range(txt, range);
pform_set_net_range(txt, range, signed_flag);
free(txt);
}

Expand Down Expand Up @@ -676,7 +681,7 @@ void pform_makewire(const vlltype&li,
char*txt = *cur;
pform_makewire(li, txt, type);
if (range)
pform_set_net_range(txt, range);
pform_set_net_range(txt, range, false);
free(txt);
}

Expand Down Expand Up @@ -878,7 +883,7 @@ void pform_set_port_type(list<char*>*names,
char*txt = *cur;
pform_set_port_type(txt, pt);
if (range)
pform_set_net_range(txt, range);
pform_set_net_range(txt, range, false);
free(txt);
}

Expand All @@ -902,6 +907,7 @@ static void pform_set_reg_integer(const char*nm)

cur->set_range(new PENumber(new verinum(INTEGER_WIDTH-1, INTEGER_WIDTH)),
new PENumber(new verinum(0UL, INTEGER_WIDTH)));
cur->set_signed(true);
}

void pform_set_reg_integer(list<char*>*names)
Expand Down Expand Up @@ -1002,6 +1008,10 @@ int pform_parse(const char*path, map<string,Module*>&modules,

/*
* $Log: pform.cc,v $
* Revision 1.68 2000/12/11 00:31:43 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.67 2000/11/30 17:31:42 steve
* Change LineInfo to store const C strings.
*
Expand Down
8 changes: 6 additions & 2 deletions pform.h
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: pform.h,v 1.44 2000/11/30 17:31:42 steve Exp $"
#ident "$Id: pform.h,v 1.45 2000/12/11 00:31:43 steve Exp $"
#endif

# include "netlist.h"
Expand Down Expand Up @@ -137,7 +137,7 @@ extern void pform_make_reginit(const struct vlltype&li,
const string&name, PExpr*expr);
extern void pform_set_port_type(list<char*>*names, svector<PExpr*>*,
NetNet::PortType);
extern void pform_set_net_range(list<char*>*names, svector<PExpr*>*);
extern void pform_set_net_range(list<char*>*names, svector<PExpr*>*, bool);
extern void pform_set_reg_idx(const string&name, PExpr*l, PExpr*r);
extern void pform_set_reg_integer(list<char*>*names);
extern void pform_set_reg_time(list<char*>*names);
Expand Down Expand Up @@ -202,6 +202,10 @@ extern void pform_dump(ostream&out, Module*mod);

/*
* $Log: pform.h,v $
* Revision 1.45 2000/12/11 00:31:43 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.44 2000/11/30 17:31:42 steve
* Change LineInfo to store const C strings.
*
Expand Down

0 comments on commit 5dbea64

Please sign in to comment.