Add support for signed reg variables,

simulate in t-vvm signed comparisons.
This commit is contained in:
steve 2000-12-11 00:31:43 +00:00
parent 084a464cf1
commit 5dbea64759
13 changed files with 273 additions and 38 deletions

View File

@ -17,14 +17,14 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include "PWire.h" # include "PWire.h"
# include <assert.h> # include <assert.h>
PWire::PWire(const string&n, NetNet::Type t, NetNet::PortType pt) 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)
{ {
} }
@ -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) void PWire::set_range(PExpr*m, PExpr*l)
{ {
msb_ = svector<PExpr*>(msb_,m); msb_ = svector<PExpr*>(msb_,m);
@ -100,6 +110,10 @@ void PWire::set_memory_idx(PExpr*ldx, PExpr*rdx)
/* /*
* $Log: PWire.cc,v $ * $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 * Revision 1.3 2000/02/23 02:56:54 steve
* Macintosh compilers do not support ident. * Macintosh compilers do not support ident.
* *

10
PWire.h
View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include "netlist.h" # include "netlist.h"
@ -49,6 +49,9 @@ class PWire : public LineInfo {
NetNet::PortType get_port_type() const; NetNet::PortType get_port_type() const;
bool set_port_type(NetNet::PortType); bool set_port_type(NetNet::PortType);
void set_signed(bool flag);
bool get_signed() const;
void set_range(PExpr*msb, PExpr*lsb); void set_range(PExpr*msb, PExpr*lsb);
void set_memory_idx(PExpr*ldx, PExpr*rdx); void set_memory_idx(PExpr*ldx, PExpr*rdx);
@ -64,6 +67,7 @@ class PWire : public LineInfo {
string name_; string name_;
NetNet::Type type_; NetNet::Type type_;
NetNet::PortType port_type_; NetNet::PortType port_type_;
bool signed_;
// These members hold expressions for the bit width of the // These members hold expressions for the bit width of the
// wire. If they do not exist, the wire is 1 bit wide. // wire. If they do not exist, the wire is 1 bit wide.
@ -82,6 +86,10 @@ class PWire : public LineInfo {
/* /*
* $Log: PWire.h,v $ * $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 * Revision 1.8 2000/05/02 16:27:38 steve
* Move signal elaboration to a seperate pass. * Move signal elaboration to a seperate pass.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
/* /*
@ -73,6 +73,8 @@ void NetNet::dump_net(ostream&o, unsigned ind) const
pin_count() << "]"; pin_count() << "]";
if (local_flag_) if (local_flag_)
o << " (local)"; o << " (local)";
if (signed_)
o << " signed";
o << " (eref=" << get_eref() << ")"; o << " (eref=" << get_eref() << ")";
if (scope()) if (scope())
o << " scope=" << scope()->name(); o << " scope=" << scope()->name();
@ -996,6 +998,10 @@ void Design::dump(ostream&o) const
/* /*
* $Log: design_dump.cc,v $ * $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 * Revision 1.106 2000/12/10 06:41:59 steve
* Support delays on continuous assignment from idents. (PR#40) * Support delays on continuous assignment from idents. (PR#40)
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include "Module.h" # include "Module.h"
@ -341,12 +341,17 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
NetNet*sig = new NetNet(scope, path + "." +basename, wtype, msb, lsb); NetNet*sig = new NetNet(scope, path + "." +basename, wtype, msb, lsb);
sig->set_line(*this); sig->set_line(*this);
sig->port_type(port_type_); sig->port_type(port_type_);
sig->set_signed(get_signed());
sig->set_attributes(attributes); sig->set_attributes(attributes);
} }
} }
/* /*
* $Log: elab_sig.cc,v $ * $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 * Revision 1.6 2000/12/04 17:37:04 steve
* Add Attrib class for holding NetObj attributes. * Add Attrib class for holding NetObj attributes.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include <cassert> # include <cassert>
@ -303,7 +303,7 @@ NetNode* NetNode::next_node()
NetNet::NetNet(NetScope*s, const string&n, Type t, unsigned npins) NetNet::NetNet(NetScope*s, const string&n, Type t, unsigned npins)
: NetObj(s, n, npins), sig_next_(0), sig_prev_(0), : 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) local_flag_(false), eref_count_(0)
{ {
assert(s); assert(s);
@ -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) 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), : NetObj(s, n, ((ms>ls)?ms-ls:ls-ms) + 1), sig_next_(0),
sig_prev_(0), type_(t), sig_prev_(0), type_(t),
port_type_(NOT_A_PORT), msb_(ms), lsb_(ls), local_flag_(false), port_type_(NOT_A_PORT), signed_(false), msb_(ms), lsb_(ls),
eref_count_(0) local_flag_(false), eref_count_(0)
{ {
assert(s); assert(s);
@ -394,6 +394,16 @@ void NetNet::port_type(NetNet::PortType t)
port_type_ = t; port_type_ = t;
} }
bool NetNet::get_signed() const
{
return signed_;
}
void NetNet::set_signed(bool flag)
{
signed_ = flag;
}
long NetNet::lsb() const long NetNet::lsb() const
{ {
return lsb_; return lsb_;
@ -2163,6 +2173,11 @@ string NetESignal::name() const
return net_->name(); return net_->name();
} }
bool NetESignal::has_sign() const
{
return net_->get_signed();
}
unsigned NetESignal::pin_count() const unsigned NetESignal::pin_count() const
{ {
return net_->pin_count(); return net_->pin_count();
@ -2465,6 +2480,10 @@ bool NetUDP::sequ_glob_(string input, char output)
/* /*
* $Log: netlist.cc,v $ * $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 * Revision 1.150 2000/12/05 06:29:33 steve
* Make signal attributes available to ivl_target API. * Make signal attributes available to ivl_target API.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
/* /*
@ -334,6 +334,11 @@ class NetNet : public NetObj, public LineInfo {
PortType port_type() const; PortType port_type() const;
void port_type(PortType t); 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 /* These methods return the msb and lsb indices for the most
significant and least significant bits. These are signed significant and least significant bits. These are signed
longs, and may be different from pin numbers. For example, longs, and may be different from pin numbers. For example,
@ -366,6 +371,7 @@ class NetNet : public NetObj, public LineInfo {
private: private:
Type type_; Type type_;
PortType port_type_; PortType port_type_;
bool signed_;
long msb_, lsb_; long msb_, lsb_;
@ -2477,6 +2483,10 @@ class NetESignal : public NetExpr {
NetESignal(NetNet*n); NetESignal(NetNet*n);
~NetESignal(); ~NetESignal();
// a NetESignal expression is signed if the NetNet that it
// refers to is signed.
bool has_sign() const;
string name() const; string name() const;
virtual bool set_width(unsigned); virtual bool set_width(unsigned);
@ -2825,6 +2835,10 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $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 * Revision 1.185 2000/12/05 06:29:33 steve
* Make signal attributes available to ivl_target API. * Make signal attributes available to ivl_target API.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include "parse_misc.h" # include "parse_misc.h"
@ -195,13 +195,12 @@ source_file
rule has presumably set up the scope. */ rule has presumably set up the scope. */
block_item_decl block_item_decl
: K_reg range register_variable_list ';' : K_reg range register_variable_list ';'
{ pform_set_net_range($3, $2); { pform_set_net_range($3, $2, false);
} }
| K_reg register_variable_list ';' | K_reg register_variable_list ';'
{ delete $2; } { delete $2; }
| K_reg K_signed range register_variable_list ';' | K_reg K_signed range register_variable_list ';'
{ pform_set_net_range($4, $3); { pform_set_net_range($4, $3, true);
yyerror(@2, "sorry: signed reg not supported.");
} }
| K_reg K_signed register_variable_list ';' | K_reg K_signed register_variable_list ';'
{ delete $3; { delete $3;

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include "compiler.h" # include "compiler.h"
@ -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, * only called by the parser within the scope of the net declaration,
* and the name that I receive only has the tail component. * 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);
assert(range->count() == 2); assert(range->count() == 2);
@ -342,9 +344,12 @@ static void pform_set_net_range(const char*name, const svector<PExpr*>*range)
assert((*range)[0]); assert((*range)[0]);
assert((*range)[1]); assert((*range)[1]);
cur->set_range((*range)[0], (*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); assert(range->count() == 2);
@ -352,7 +357,7 @@ void pform_set_net_range(list<char*>*names, svector<PExpr*>*range)
; cur != names->end() ; cur != names->end()
; cur ++ ) { ; cur ++ ) {
char*txt = *cur; char*txt = *cur;
pform_set_net_range(txt, range); pform_set_net_range(txt, range, signed_flag);
free(txt); free(txt);
} }
@ -676,7 +681,7 @@ void pform_makewire(const vlltype&li,
char*txt = *cur; char*txt = *cur;
pform_makewire(li, txt, type); pform_makewire(li, txt, type);
if (range) if (range)
pform_set_net_range(txt, range); pform_set_net_range(txt, range, false);
free(txt); free(txt);
} }
@ -878,7 +883,7 @@ void pform_set_port_type(list<char*>*names,
char*txt = *cur; char*txt = *cur;
pform_set_port_type(txt, pt); pform_set_port_type(txt, pt);
if (range) if (range)
pform_set_net_range(txt, range); pform_set_net_range(txt, range, false);
free(txt); free(txt);
} }
@ -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)), cur->set_range(new PENumber(new verinum(INTEGER_WIDTH-1, INTEGER_WIDTH)),
new PENumber(new verinum(0UL, INTEGER_WIDTH))); new PENumber(new verinum(0UL, INTEGER_WIDTH)));
cur->set_signed(true);
} }
void pform_set_reg_integer(list<char*>*names) void pform_set_reg_integer(list<char*>*names)
@ -1002,6 +1008,10 @@ int pform_parse(const char*path, map<string,Module*>&modules,
/* /*
* $Log: pform.cc,v $ * $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 * Revision 1.67 2000/11/30 17:31:42 steve
* Change LineInfo to store const C strings. * Change LineInfo to store const C strings.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include "netlist.h" # include "netlist.h"
@ -137,7 +137,7 @@ extern void pform_make_reginit(const struct vlltype&li,
const string&name, PExpr*expr); const string&name, PExpr*expr);
extern void pform_set_port_type(list<char*>*names, svector<PExpr*>*, extern void pform_set_port_type(list<char*>*names, svector<PExpr*>*,
NetNet::PortType); 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_idx(const string&name, PExpr*l, PExpr*r);
extern void pform_set_reg_integer(list<char*>*names); extern void pform_set_reg_integer(list<char*>*names);
extern void pform_set_reg_time(list<char*>*names); extern void pform_set_reg_time(list<char*>*names);
@ -202,6 +202,10 @@ extern void pform_dump(ostream&out, Module*mod);
/* /*
* $Log: pform.h,v $ * $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 * Revision 1.44 2000/11/30 17:31:42 steve
* Change LineInfo to store const C strings. * Change LineInfo to store const C strings.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: pform_dump.cc,v 1.64 2000/12/10 22:01:36 steve Exp $" #ident "$Id: pform_dump.cc,v 1.65 2000/12/11 00:31:43 steve Exp $"
#endif #endif
/* /*
@ -219,6 +219,10 @@ void PWire::dump(ostream&out) const
break; break;
} }
if (signed_) {
out << " signed";
}
assert(msb_.count() == lsb_.count()); assert(msb_.count() == lsb_.count());
for (unsigned idx = 0 ; idx < msb_.count() ; idx += 1) { for (unsigned idx = 0 ; idx < msb_.count() ; idx += 1) {
assert(msb_[idx]); assert(msb_[idx]);
@ -806,6 +810,10 @@ void PUdp::dump(ostream&out) const
/* /*
* $Log: pform_dump.cc,v $ * $Log: pform_dump.cc,v $
* Revision 1.65 2000/12/11 00:31:43 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.64 2000/12/10 22:01:36 steve * Revision 1.64 2000/12/10 22:01:36 steve
* Support decimal constants in behavioral delays. * Support decimal constants in behavioral delays.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-vvm.cc,v 1.188 2000/12/10 06:41:59 steve Exp $" #ident "$Id: t-vvm.cc,v 1.189 2000/12/11 00:31:43 steve Exp $"
#endif #endif
# include <iostream> # include <iostream>
@ -706,16 +706,26 @@ void vvm_proc_rval::expr_binary(const NetEBinary*expr)
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case 'G': // >= case 'G': // >=
tgt_->defn << " " << result << "[0] = vvm_binop_ge(" if (expr->left()->has_sign() && expr->right()->has_sign()) {
<< lres << "," << rres << ");" << endl; tgt_->defn << " " << result << "[0] = vvm_binop_ge_s("
<< lres << "," << rres << ");" << endl;
} else {
tgt_->defn << " " << result << "[0] = vvm_binop_ge("
<< lres << "," << rres << ");" << endl;
}
break; break;
case 'l': // left shift(<<) case 'l': // left shift(<<)
tgt_->defn << " " << "vvm_binop_shiftl(" << result tgt_->defn << " " << "vvm_binop_shiftl(" << result
<< ", " << lres << "," << rres << ");" << endl; << ", " << lres << "," << rres << ");" << endl;
break; break;
case 'L': // <= case 'L': // <=
tgt_->defn << " " << result << "[0] = vvm_binop_le(" if (expr->left()->has_sign() && expr->right()->has_sign()) {
<< lres << "," << rres << ");" << endl; tgt_->defn << " " << result << "[0] = vvm_binop_le_s("
<< lres << "," << rres << ");" << endl;
} else {
tgt_->defn << " " << result << "[0] = vvm_binop_le("
<< lres << "," << rres << ");" << endl;
}
break; break;
case 'N': // !== case 'N': // !==
tgt_->defn << " " << result << "[0] = vvm_binop_nee(" tgt_->defn << " " << result << "[0] = vvm_binop_nee("
@ -726,12 +736,22 @@ void vvm_proc_rval::expr_binary(const NetEBinary*expr)
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case '<': case '<':
tgt_->defn << " " << result << "[0] = vvm_binop_lt(" if (expr->left()->has_sign() && expr->right()->has_sign()) {
<< lres << "," << rres << ");" << endl; tgt_->defn << " " << result << "[0] = vvm_binop_lt_s("
<< lres << "," << rres << ");" << endl;
} else {
tgt_->defn << " " << result << "[0] = vvm_binop_lt("
<< lres << "," << rres << ");" << endl;
}
break; break;
case '>': case '>':
tgt_->defn << " " << result << "[0] = vvm_binop_gt(" if (expr->left()->has_sign() && expr->right()->has_sign()) {
<< lres << "," << rres << ");" << endl; tgt_->defn << " " << result << "[0] = vvm_binop_gt_s("
<< lres << "," << rres << ");" << endl;
} else {
tgt_->defn << " " << result << "[0] = vvm_binop_gt("
<< lres << "," << rres << ");" << endl;
}
break; break;
case 'o': // logical or (||) case 'o': // logical or (||)
tgt_->defn << " " << result << "[0] = vvm_binop_lor(" tgt_->defn << " " << result << "[0] = vvm_binop_lor("
@ -3370,6 +3390,10 @@ extern const struct target tgt_vvm = {
}; };
/* /*
* $Log: t-vvm.cc,v $ * $Log: t-vvm.cc,v $
* Revision 1.189 2000/12/11 00:31:43 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.188 2000/12/10 06:41:59 steve * Revision 1.188 2000/12/10 06:41:59 steve
* Support delays on continuous assignment from idents. (PR#40) * Support delays on continuous assignment from idents. (PR#40)
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvm_func.cc,v 1.12 2000/07/06 18:12:28 steve Exp $" #ident "$Id: vvm_func.cc,v 1.13 2000/12/11 00:31:44 steve Exp $"
#endif #endif
# include "vvm_func.h" # include "vvm_func.h"
@ -385,6 +385,34 @@ vpip_bit_t vvm_binop_lt(const vvm_bitset_t&l, const vvm_bitset_t&r)
return result; return result;
} }
/*
* This is the < operator that applies to signed operands.
*/
vpip_bit_t vvm_binop_lt_s(const vvm_bitset_t&l, const vvm_bitset_t&r)
{
vpip_bit_t l_pad = l.get_bit(l.get_width()-1);
vpip_bit_t r_pad = r.get_bit(r.get_width()-1);
/* If l>=0 and r>=0, return $unsigned(l) < $unsigned(r) */
if (B_IS0(l_pad) && B_IS0(r_pad))
return vvm_binop_lt(l, r);
/* If l < 0 and r < 0, return $unsigned(r) < $unsigned(l) */
if (B_IS1(l_pad) && B_IS1(r_pad))
return vvm_binop_lt(r, l);
/* If l >= 0 and r < 0, return false; */
if (B_IS0(l_pad) && B_IS1(r_pad))
return St0;
/* if l < 0 and r >= 0, return true; */
if (B_IS1(l_pad) && B_IS0(r_pad))
return St1;
/* Otherwise, one or the other side is unknown. Return X. */
return StX;
}
vpip_bit_t vvm_binop_le(const vvm_bitset_t&l, const vvm_bitset_t&r) vpip_bit_t vvm_binop_le(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
vpip_bit_t result = St1; vpip_bit_t result = St1;
@ -406,6 +434,34 @@ vpip_bit_t vvm_binop_le(const vvm_bitset_t&l, const vvm_bitset_t&r)
return result; return result;
} }
/*
* This is the <= operator that applies to signed operands.
*/
vpip_bit_t vvm_binop_le_s(const vvm_bitset_t&l, const vvm_bitset_t&r)
{
vpip_bit_t l_pad = l.get_bit(l.get_width()-1);
vpip_bit_t r_pad = r.get_bit(r.get_width()-1);
/* If l>=0 and r>=0, return $unsigned(l) <= $unsigned(r) */
if (B_IS0(l_pad) && B_IS0(r_pad))
return vvm_binop_le(l, r);
/* If l < 0 and r < 0, return $unsigned(r) <= $unsigned(l) */
if (B_IS1(l_pad) && B_IS1(r_pad))
return vvm_binop_le(r, l);
/* If l >= 0 and r < 0, return false; */
if (B_IS0(l_pad) && B_IS1(r_pad))
return St0;
/* if l < 0 and r >= 0, return true; */
if (B_IS1(l_pad) && B_IS0(r_pad))
return St1;
/* Otherwise, one or the other side is unknown. Return X. */
return StX;
}
vpip_bit_t vvm_binop_gt(const vvm_bitset_t&l, const vvm_bitset_t&r) vpip_bit_t vvm_binop_gt(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
vpip_bit_t result = St0; vpip_bit_t result = St0;
@ -430,6 +486,34 @@ vpip_bit_t vvm_binop_gt(const vvm_bitset_t&l, const vvm_bitset_t&r)
return result; return result;
} }
/*
* This is the > operator that applies to signed operands.
*/
vpip_bit_t vvm_binop_gt_s(const vvm_bitset_t&l, const vvm_bitset_t&r)
{
vpip_bit_t l_pad = l.get_bit(l.get_width()-1);
vpip_bit_t r_pad = r.get_bit(r.get_width()-1);
/* If l>=0 and r>=0, return $unsigned(l) > $unsigned(r) */
if (B_IS0(l_pad) && B_IS0(r_pad))
return vvm_binop_gt(l, r);
/* If l < 0 and r < 0, return $unsigned(r) > $unsigned(l) */
if (B_IS1(l_pad) && B_IS1(r_pad))
return vvm_binop_gt(r, l);
/* If l >= 0 and r < 0, return true; */
if (B_IS0(l_pad) && B_IS1(r_pad))
return St1;
/* if l < 0 and r >= 0, return false; */
if (B_IS1(l_pad) && B_IS0(r_pad))
return St0;
/* Otherwise, one or the other side is unknown. Return X. */
return StX;
}
vpip_bit_t vvm_binop_ge(const vvm_bitset_t&l, const vvm_bitset_t&r) vpip_bit_t vvm_binop_ge(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
vpip_bit_t result = St1; vpip_bit_t result = St1;
@ -453,6 +537,34 @@ vpip_bit_t vvm_binop_ge(const vvm_bitset_t&l, const vvm_bitset_t&r)
return result; return result;
} }
/*
* This is the >= operator that applies to signed operands.
*/
vpip_bit_t vvm_binop_ge_s(const vvm_bitset_t&l, const vvm_bitset_t&r)
{
vpip_bit_t l_pad = l.get_bit(l.get_width()-1);
vpip_bit_t r_pad = r.get_bit(r.get_width()-1);
/* If l>=0 and r>=0, return $unsigned(l) >= $unsigned(r) */
if (B_IS0(l_pad) && B_IS0(r_pad))
return vvm_binop_ge(l, r);
/* If l < 0 and r < 0, return $unsigned(r) >= $unsigned(l) */
if (B_IS1(l_pad) && B_IS1(r_pad))
return vvm_binop_ge(r, l);
/* If l >= 0 and r < 0, return true; */
if (B_IS0(l_pad) && B_IS1(r_pad))
return St1;
/* if l < 0 and r >= 0, return false; */
if (B_IS1(l_pad) && B_IS0(r_pad))
return St0;
/* Otherwise, one or the other side is unknown. Return X. */
return StX;
}
vpip_bit_t vvm_binop_land(const vvm_bitset_t&l, const vvm_bitset_t&r) vpip_bit_t vvm_binop_land(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
vpip_bit_t res1 = vvm_unop_or(l); vpip_bit_t res1 = vvm_unop_or(l);
@ -495,6 +607,10 @@ void vvm_ternary(vvm_bitset_t&v, vpip_bit_t c,
/* /*
* $Log: vvm_func.cc,v $ * $Log: vvm_func.cc,v $
* Revision 1.13 2000/12/11 00:31:44 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.12 2000/07/06 18:12:28 steve * Revision 1.12 2000/07/06 18:12:28 steve
* unop_not can take out width same as in width. * unop_not can take out width same as in width.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvm_func.h,v 1.29 2000/05/19 04:22:56 steve Exp $" #ident "$Id: vvm_func.h,v 1.30 2000/12/11 00:31:44 steve Exp $"
#endif #endif
# include "vvm.h" # include "vvm.h"
@ -184,17 +184,21 @@ extern vpip_bit_t vvm_binop_xeq(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_zeq(const vvm_bitset_t&l, const vvm_bitset_t&r); extern vpip_bit_t vvm_binop_zeq(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_lt(const vvm_bitset_t&l, const vvm_bitset_t&r);
/* /*
* The <= operator takes operands of natural width and returns a * The _s variants are signed versions. That is, it assumes the
* single bit. The result is V1 if l <= r, otherwise V0; * operands are signed values and does the comparison on that basis.
*/ */
extern vpip_bit_t vvm_binop_lt(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_lt_s(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_le(const vvm_bitset_t&l, const vvm_bitset_t&r); extern vpip_bit_t vvm_binop_le(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_le_s(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_gt(const vvm_bitset_t&l, const vvm_bitset_t&r); extern vpip_bit_t vvm_binop_gt(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_gt_s(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_ge(const vvm_bitset_t&l, const vvm_bitset_t&r); extern vpip_bit_t vvm_binop_ge(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_ge_s(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_land(const vvm_bitset_t&l, const vvm_bitset_t&r); extern vpip_bit_t vvm_binop_land(const vvm_bitset_t&l, const vvm_bitset_t&r);
@ -206,6 +210,10 @@ extern void vvm_ternary(vvm_bitset_t&v, vpip_bit_t c,
/* /*
* $Log: vvm_func.h,v $ * $Log: vvm_func.h,v $
* Revision 1.30 2000/12/11 00:31:44 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.29 2000/05/19 04:22:56 steve * Revision 1.29 2000/05/19 04:22:56 steve
* Add the integer modulus function. * Add the integer modulus function.
* *