Support more operators, especially logical.
This commit is contained in:
parent
5ee3a41d2a
commit
b7f833dd71
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: design_dump.cc,v 1.15 1999/03/01 03:27:53 steve Exp $"
|
||||
#ident "$Id: design_dump.cc,v 1.16 1999/03/15 02:43:32 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -427,12 +427,18 @@ void NetEBinary::dump(ostream&o) const
|
|||
default:
|
||||
o << op_;
|
||||
break;
|
||||
case 'a':
|
||||
o << "&&";
|
||||
break;
|
||||
case 'e':
|
||||
o << "==";
|
||||
break;
|
||||
case 'n':
|
||||
o << "!=";
|
||||
break;
|
||||
case 'o':
|
||||
o << "||";
|
||||
break;
|
||||
}
|
||||
o << "(";
|
||||
right_->dump(o);
|
||||
|
|
@ -515,6 +521,9 @@ void Design::dump(ostream&o) const
|
|||
|
||||
/*
|
||||
* $Log: design_dump.cc,v $
|
||||
* Revision 1.16 1999/03/15 02:43:32 steve
|
||||
* Support more operators, especially logical.
|
||||
*
|
||||
* Revision 1.15 1999/03/01 03:27:53 steve
|
||||
* Prevent the duplicate allocation of ESignal objects.
|
||||
*
|
||||
|
|
|
|||
19
elaborate.cc
19
elaborate.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: elaborate.cc,v 1.17 1999/03/01 03:27:53 steve Exp $"
|
||||
#ident "$Id: elaborate.cc,v 1.18 1999/03/15 02:43:32 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -510,6 +510,19 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path) const
|
|||
des->add_node(gate);
|
||||
break;
|
||||
|
||||
case 'n': // !=
|
||||
assert(lsig->pin_count() == 1);
|
||||
assert(rsig->pin_count() == 1);
|
||||
gate = new NetLogic(des->local_symbol(path), 3, NetLogic::XOR);
|
||||
connect(gate->pin(1), lsig->pin(0));
|
||||
connect(gate->pin(2), rsig->pin(0));
|
||||
osig = new NetNet(des->local_symbol(path), NetNet::WIRE);
|
||||
osig->local_flag(true);
|
||||
connect(gate->pin(0), osig->pin(0));
|
||||
des->add_signal(osig);
|
||||
des->add_node(gate);
|
||||
break;
|
||||
|
||||
default:
|
||||
cerr << "Unhandled BINARY '" << op_ << "'" << endl;
|
||||
osig = 0;
|
||||
|
|
@ -699,6 +712,7 @@ NetProc* PAssign::elaborate(Design*des, const string&path) const
|
|||
assert(rval);
|
||||
|
||||
NetAssign*cur = new NetAssign(reg, rval);
|
||||
cur->set_line(*this);
|
||||
des->add_node(cur);
|
||||
|
||||
return cur;
|
||||
|
|
@ -963,6 +977,9 @@ Design* elaborate(const map<string,Module*>&modules,
|
|||
|
||||
/*
|
||||
* $Log: elaborate.cc,v $
|
||||
* Revision 1.18 1999/03/15 02:43:32 steve
|
||||
* Support more operators, especially logical.
|
||||
*
|
||||
* Revision 1.17 1999/03/01 03:27:53 steve
|
||||
* Prevent the duplicate allocation of ESignal objects.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: lexor.lex,v 1.9 1999/02/21 17:01:57 steve Exp $"
|
||||
#ident "$Id: lexor.lex,v 1.10 1999/03/15 02:43:32 steve Exp $"
|
||||
#endif
|
||||
|
||||
//# define YYSTYPE lexval
|
||||
|
|
@ -69,6 +69,8 @@ static verinum*make_sized_hex(const char*txt);
|
|||
"!=" { return K_NE; }
|
||||
"===" { return K_CEQ; }
|
||||
"!==" { return K_CNE; }
|
||||
"||" { return K_LOR; }
|
||||
"&&" { return K_LAND; }
|
||||
|
||||
[;:\[\],()#=.@&!<|^~+*/-] { return yytext[0]; }
|
||||
|
||||
|
|
|
|||
12
netlist.cc
12
netlist.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: netlist.cc,v 1.18 1999/03/01 03:27:53 steve Exp $"
|
||||
#ident "$Id: netlist.cc,v 1.19 1999/03/15 02:43:32 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <cassert>
|
||||
|
|
@ -444,7 +444,12 @@ void NetEBinary::set_width(unsigned w)
|
|||
case 'e':
|
||||
assert(w == 1);
|
||||
expr_width(w);
|
||||
break;;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
assert(w == 1);
|
||||
expr_width(w);
|
||||
break;
|
||||
|
||||
/* The default rule is that the operands of the binary
|
||||
operator might as well use the same width as the
|
||||
|
|
@ -956,6 +961,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))
|
|||
|
||||
/*
|
||||
* $Log: netlist.cc,v $
|
||||
* Revision 1.19 1999/03/15 02:43:32 steve
|
||||
* Support more operators, especially logical.
|
||||
*
|
||||
* Revision 1.18 1999/03/01 03:27:53 steve
|
||||
* Prevent the duplicate allocation of ESignal objects.
|
||||
*
|
||||
|
|
|
|||
45
netlist.h
45
netlist.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: netlist.h,v 1.21 1999/03/01 03:27:53 steve Exp $"
|
||||
#ident "$Id: netlist.h,v 1.22 1999/03/15 02:43:32 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -558,11 +558,15 @@ class NetProc {
|
|||
NetProc*next_;
|
||||
};
|
||||
|
||||
/* This is a procedural assignment. The lval is a register, and the
|
||||
assignment happens when the code is executed by the design. The
|
||||
node part of the NetAssign has as many pins as the width of the
|
||||
lvalue object. */
|
||||
class NetAssign : public NetProc, public NetNode {
|
||||
/*
|
||||
* This is a procedural assignment. The lval is a register, and the
|
||||
* assignment happens when the code is executed by the design. The
|
||||
* node part of the NetAssign has as many pins as the width of the
|
||||
* lvalue object and represents the elaborated lvalue. Thus, this
|
||||
* appears as a procedural statement AND a structural node. The
|
||||
* LineInfo is the location of the assignment statement in the source.
|
||||
*/
|
||||
class NetAssign : public NetProc, public NetNode, public LineInfo {
|
||||
public:
|
||||
explicit NetAssign(NetNet*lv, NetExpr*rv);
|
||||
~NetAssign();
|
||||
|
|
@ -793,7 +797,23 @@ class NetProcTop : public LineInfo {
|
|||
NetProcTop*next_;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* This class represents a binary operator, with the left and right
|
||||
* operands and a single character for the operator. The operator
|
||||
* values are:
|
||||
*
|
||||
* ^ -- Bit-wise exclusive OR
|
||||
* + -- Arithmetic add
|
||||
* - -- Arighmetic minus
|
||||
* & -- Bit-wise AND
|
||||
* | -- Bit-wise OR
|
||||
* e -- Logical equality (==)
|
||||
* E -- Case equality (===)
|
||||
* n -- Logical inequality (!=)
|
||||
* N -- Case inequality (!==)
|
||||
* a -- Logical AND (&&)
|
||||
* o -- Logical OR (||)
|
||||
*/
|
||||
class NetEBinary : public NetExpr {
|
||||
|
||||
public:
|
||||
|
|
@ -833,6 +853,14 @@ class NetEConst : public NetExpr {
|
|||
verinum value_;
|
||||
};
|
||||
|
||||
/*
|
||||
* This class represents a unaru operator, with the single operand
|
||||
* and a single character for the operator. The operator values are:
|
||||
*
|
||||
* ~ -- Bit-wise negation
|
||||
* ! -- Logical negation
|
||||
* & -- Reduction AND
|
||||
*/
|
||||
class NetEUnary : public NetExpr {
|
||||
|
||||
public:
|
||||
|
|
@ -1020,6 +1048,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
|
|||
|
||||
/*
|
||||
* $Log: netlist.h,v $
|
||||
* Revision 1.22 1999/03/15 02:43:32 steve
|
||||
* Support more operators, especially logical.
|
||||
*
|
||||
* Revision 1.21 1999/03/01 03:27:53 steve
|
||||
* Prevent the duplicate allocation of ESignal objects.
|
||||
*
|
||||
|
|
|
|||
18
parse.y
18
parse.y
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: parse.y,v 1.14 1999/02/21 17:01:57 steve Exp $"
|
||||
#ident "$Id: parse.y,v 1.15 1999/03/15 02:43:32 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -60,6 +60,7 @@ extern void lex_end_table();
|
|||
%token <text> IDENTIFIER SYSTEM_IDENTIFIER STRING
|
||||
%token <number> NUMBER
|
||||
%token K_LE K_GE K_EQ K_NE K_CEQ K_CNE
|
||||
%token K_LOR K_LAND
|
||||
%token K_always K_and K_assign K_begin K_buf K_bufif0 K_bufif1 K_case
|
||||
%token K_casex K_casez K_cmos K_deassign K_default K_defparam K_disable
|
||||
%token K_edge K_else K_end K_endcase K_endfunction K_endmodule
|
||||
|
|
@ -116,6 +117,9 @@ extern void lex_end_table();
|
|||
%left K_EQ K_NE K_CEQ K_CNE
|
||||
%left '&'
|
||||
%left '^'
|
||||
%left '|'
|
||||
%left K_LAND
|
||||
%left K_LOR
|
||||
|
||||
%%
|
||||
|
||||
|
|
@ -229,6 +233,9 @@ expression
|
|||
| '&' expression %prec UNARY_PREC
|
||||
{ $$ = new PEUnary('&', $2);
|
||||
}
|
||||
| '!' expression %prec UNARY_PREC
|
||||
{ $$ = new PEUnary('!', $2);
|
||||
}
|
||||
| expression '^' expression
|
||||
{ $$ = new PEBinary('^', $1, $3);
|
||||
}
|
||||
|
|
@ -241,6 +248,9 @@ expression
|
|||
| expression '&' expression
|
||||
{ $$ = new PEBinary('&', $1, $3);
|
||||
}
|
||||
| expression '|' expression
|
||||
{ $$ = new PEBinary('|', $1, $3);
|
||||
}
|
||||
| expression K_EQ expression
|
||||
{ $$ = new PEBinary('e', $1, $3);
|
||||
}
|
||||
|
|
@ -253,6 +263,12 @@ expression
|
|||
| expression K_CNE expression
|
||||
{ $$ = new PEBinary('N', $1, $3);
|
||||
}
|
||||
| expression K_LOR expression
|
||||
{ $$ = new PEBinary('o', $1, $3);
|
||||
}
|
||||
| expression K_LAND expression
|
||||
{ $$ = new PEBinary('a', $1, $3);
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
|
|
|
|||
20
t-vvm.cc
20
t-vvm.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: t-vvm.cc,v 1.13 1999/02/22 03:01:12 steve Exp $"
|
||||
#ident "$Id: t-vvm.cc,v 1.14 1999/03/15 02:43:32 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <iostream>
|
||||
|
|
@ -144,6 +144,10 @@ void vvm_proc_rval::expr_unary(const NetEUnary*expr)
|
|||
os_ << "vvm_unop_not(" << result << ");"
|
||||
<< endl;
|
||||
break;
|
||||
case '!':
|
||||
os_ << "vvm_unop_lnot(" << result << ");"
|
||||
<< endl;
|
||||
break;
|
||||
default:
|
||||
cerr << "vvm: Unhandled unary op `" << expr->op() << "'"
|
||||
<< endl;
|
||||
|
|
@ -174,6 +178,10 @@ void vvm_proc_rval::expr_binary(const NetEBinary*expr)
|
|||
os_ << setw(indent_) << "" << result << " = vvm_binop_ne("
|
||||
<< lres << "," << rres << ");" << endl;
|
||||
break;
|
||||
case 'o':
|
||||
os_ << setw(indent_) << "" << result << " = vvm_binop_lor("
|
||||
<< lres << "," << rres << ");" << endl;
|
||||
break;
|
||||
case '+':
|
||||
os_ << setw(indent_) << "" << result << " = vvm_binop_plus("
|
||||
<< lres << "," << rres << ");" << endl;
|
||||
|
|
@ -186,6 +194,10 @@ void vvm_proc_rval::expr_binary(const NetEBinary*expr)
|
|||
os_ << setw(indent_) << "" << result << " = vvm_binop_and("
|
||||
<< lres << "," << rres << ");" << endl;
|
||||
break;
|
||||
case '|':
|
||||
os_ << setw(indent_) << "" << result << " = vvm_binop_or("
|
||||
<< lres << "," << rres << ");" << endl;
|
||||
break;
|
||||
default:
|
||||
cerr << "vvm: Unhandled binary op `" << expr->op() << "': "
|
||||
<< *expr << endl;
|
||||
|
|
@ -585,7 +597,8 @@ void target_vvm::proc_assign(ostream&os, const NetAssign*net)
|
|||
net->find_lval_range(lval, msb, lsb);
|
||||
|
||||
if ((lsb == 0) && (msb == (lval->pin_count()-1))) {
|
||||
os << " // " << lval->name() << " = ";
|
||||
os << " // " << net->get_line() << ": "
|
||||
<< lval->name() << " = ";
|
||||
net->rval()->dump(os);
|
||||
os << endl;
|
||||
} else {
|
||||
|
|
@ -870,6 +883,9 @@ extern const struct target tgt_vvm = {
|
|||
};
|
||||
/*
|
||||
* $Log: t-vvm.cc,v $
|
||||
* Revision 1.14 1999/03/15 02:43:32 steve
|
||||
* Support more operators, especially logical.
|
||||
*
|
||||
* Revision 1.13 1999/02/22 03:01:12 steve
|
||||
* Handle default case.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue