Remove all remain vvm_bitset_t return values,

and disallow vvm_bitset_t copying.
This commit is contained in:
steve 2000-03-25 02:43:56 +00:00
parent c790ccca5a
commit dcaea50b8f
5 changed files with 222 additions and 264 deletions

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.123 2000/03/24 03:47:01 steve Exp $" #ident "$Id: t-vvm.cc,v 1.124 2000/03/25 02:43:56 steve Exp $"
#endif #endif
# include <iostream> # include <iostream>
@ -258,12 +258,21 @@ void vvm_proc_rval::expr_ident(const NetEIdent*expr)
result = mangle(expr->name()); result = mangle(expr->name());
} }
/*
* a bitset rval that is a memory reference.
*/
void vvm_proc_rval::expr_memory(const NetEMemory*mem) void vvm_proc_rval::expr_memory(const NetEMemory*mem)
{ {
const string tname = make_temp();
os_ << setw(indent_) << "" << "vvm_bitset_t<"
<< mem->expr_width() << "> " << tname << ";" << endl;
const string mname = mangle(mem->name()); const string mname = mangle(mem->name());
assert(mem->index()); assert(mem->index());
mem->index()->expr_scan(this); mem->index()->expr_scan(this);
result = mname + ".get_word(" + result + ".as_unsigned())"; os_ << setw(indent_) << "" << mname << ".get_word(" <<
result<<".as_unsigned(), " << tname << ");";
result = tname;
} }
void vvm_proc_rval::expr_signal(const NetESignal*expr) void vvm_proc_rval::expr_signal(const NetESignal*expr)
@ -329,8 +338,13 @@ void vvm_proc_rval::expr_ufunc(const NetEUFunc*expr)
the parameter port register. */ the parameter port register. */
for (unsigned idx = 0 ; idx < pcnt ; idx += 1) { for (unsigned idx = 0 ; idx < pcnt ; idx += 1) {
expr->parm(idx)->expr_scan(this); expr->parm(idx)->expr_scan(this);
os_ << " " << mangle(def->port(idx+1)->name()) << string bname = mangle(def->port(idx+1)->name());
"_bits = " << result << ";" << endl; for (unsigned bit = 0 ;
bit < expr->parm(idx)->expr_width() ; bit += 1) {
os_ << " " << bname << "_bits["<<bit<<"] = " <<
result << "["<<bit<<"];" << endl;
}
} }
/* Make the function call. */ /* Make the function call. */
@ -341,7 +355,12 @@ void vvm_proc_rval::expr_ufunc(const NetEUFunc*expr)
string rbits = mangle(expr->result()->name()) + "_bits"; string rbits = mangle(expr->result()->name()) + "_bits";
os_ << " vvm_bitset_t<" << expr->expr_width() << "> " << os_ << " vvm_bitset_t<" << expr->expr_width() << "> " <<
result << " = " << rbits << ";" << endl; result << ";" << endl;
for (unsigned idx = 0 ; idx < expr->expr_width() ; idx += 1) {
os_ << " " << result<<"["<<idx<<"] = " <<
rbits<<"["<<idx<<"];" << endl;
}
} }
void vvm_proc_rval::expr_unary(const NetEUnary*expr) void vvm_proc_rval::expr_unary(const NetEUnary*expr)
@ -354,7 +373,8 @@ void vvm_proc_rval::expr_unary(const NetEUnary*expr)
switch (expr->op()) { switch (expr->op()) {
case '~': case '~':
os_ << "vvm_unop_not(" << tname << "," << result << ");" << endl; os_ << " vvm_unop_not(" << tname << "," << result <<
");" << endl;
break; break;
case '&': case '&':
os_ << " " << tname << "[0] " os_ << " " << tname << "[0] "
@ -410,19 +430,19 @@ void vvm_proc_rval::expr_binary(const NetEBinary*expr)
expr->expr_width() << ">" << result << ";" << endl; expr->expr_width() << ">" << result << ";" << endl;
switch (expr->op()) { switch (expr->op()) {
case 'a': // logical and (&&) case 'a': // logical and (&&)
os_ << setw(indent_) << "" << result << " = vvm_binop_land(" os_ << setw(indent_) << "" << result << "[0] = vvm_binop_land("
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case 'E': // === case 'E': // ===
os_ << setw(indent_) << "" << result << " = vvm_binop_eeq(" os_ << setw(indent_) << "" << result << "[0] = vvm_binop_eeq("
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case 'e': // == case 'e': // ==
os_ << setw(indent_) << "" << result << " = vvm_binop_eq(" os_ << setw(indent_) << "" << result << "[0] = vvm_binop_eq("
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case 'G': // >= case 'G': // >=
os_ << setw(indent_) << "" << result << " = vvm_binop_ge(" os_ << setw(indent_) << "" << result << "[0] = vvm_binop_ge("
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case 'l': // left shift(<<) case 'l': // left shift(<<)
@ -430,27 +450,27 @@ void vvm_proc_rval::expr_binary(const NetEBinary*expr)
<< ", " << lres << "," << rres << ");" << endl; << ", " << lres << "," << rres << ");" << endl;
break; break;
case 'L': // <= case 'L': // <=
os_ << setw(indent_) << "" << result << " = vvm_binop_le(" os_ << setw(indent_) << "" << result << "[0] = vvm_binop_le("
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case 'N': // !== case 'N': // !==
os_ << setw(indent_) << "" << result << " = vvm_binop_nee(" os_ << setw(indent_) << "" << result << "[0] = vvm_binop_nee("
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case 'n': case 'n':
os_ << setw(indent_) << "" << result << " = vvm_binop_ne(" os_ << setw(indent_) << "" << result << "[0] = vvm_binop_ne("
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case '<': case '<':
os_ << setw(indent_) << "" << result << " = vvm_binop_lt(" os_ << setw(indent_) << "" << result << "[0] = vvm_binop_lt("
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case '>': case '>':
os_ << setw(indent_) << "" << result << " = vvm_binop_gt(" os_ << setw(indent_) << "" << result << "[0] = vvm_binop_gt("
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case 'o': // logical or (||) case 'o': // logical or (||)
os_ << setw(indent_) << "" << result << " = vvm_binop_lor(" os_ << setw(indent_) << "" << result << "[0] = vvm_binop_lor("
<< lres << "," << rres << ");" << endl; << lres << "," << rres << ");" << endl;
break; break;
case 'r': // right shift(>>) case 'r': // right shift(>>)
@ -1897,7 +1917,7 @@ void target_vvm::proc_case(ostream&os, const NetCase*net)
string guard = emit_proc_rval(defn, 8, net->expr(idx)); string guard = emit_proc_rval(defn, 8, net->expr(idx));
defn << " if (B_IS1(" << test_func << "(" << guard << "," defn << " if (B_IS1(" << test_func << "(" << guard << ","
<< expr << ")[0])) {" << endl; << expr << "))) {" << endl;
defn << " step_ = &" << thread_class_ << defn << " step_ = &" << thread_class_ <<
"::step_" << thread_step_ << "_;" << endl; "::step_" << thread_step_ << "_;" << endl;
defn << " return true;" << endl; defn << " return true;" << endl;
@ -2009,7 +2029,7 @@ void target_vvm::proc_case_fun(ostream&os, const NetCase*net)
string guard = emit_proc_rval(defn, 6, net->expr(idx)); string guard = emit_proc_rval(defn, 6, net->expr(idx));
defn << " if (B_IS1(" << test_func << "(" << defn << " if (B_IS1(" << test_func << "(" <<
guard << "," << expr << ")[0])) {" << endl; guard << "," << expr << "))) {" << endl;
if (net->stat(idx)) if (net->stat(idx))
net->stat(idx)->emit_proc(os, this); net->stat(idx)->emit_proc(os, this);
defn << " break; }" << endl; defn << " break; }" << endl;
@ -2275,7 +2295,7 @@ void target_vvm::proc_event(ostream&os, const NetPEvent*proc)
/* POSITIVE is for the wait construct, and needs to be handled /* POSITIVE is for the wait construct, and needs to be handled
specially. The structure of the generated code is: specially. The structure of the generated code is:
if (event.get()==V1) { if (event.get(0)==V1) {
return true; return true;
} else { } else {
event.wait(this); event.wait(this);
@ -2295,7 +2315,7 @@ void target_vvm::proc_event(ostream&os, const NetPEvent*proc)
svector<const NetNEvent*>*list = proc->back_list(); svector<const NetNEvent*>*list = proc->back_list();
if ((list->count()==1) && ((*list)[0]->type() == NetNEvent::POSITIVE)) { if ((list->count()==1) && ((*list)[0]->type() == NetNEvent::POSITIVE)) {
defn << " if (B_IS1(" << mangle((*list)[0]->name()) << defn << " if (B_IS1(" << mangle((*list)[0]->name()) <<
".get()[0])) {" << endl; ".get(0))) {" << endl;
defn << " return true;" << endl; defn << " return true;" << endl;
defn << " } else {" << endl; defn << " } else {" << endl;
defn << " " << mangle(proc->name()) << defn << " " << mangle(proc->name()) <<
@ -2367,6 +2387,10 @@ extern const struct target tgt_vvm = {
}; };
/* /*
* $Log: t-vvm.cc,v $ * $Log: t-vvm.cc,v $
* Revision 1.124 2000/03/25 02:43:56 steve
* Remove all remain vvm_bitset_t return values,
* and disallow vvm_bitset_t copying.
*
* Revision 1.123 2000/03/24 03:47:01 steve * Revision 1.123 2000/03/24 03:47:01 steve
* Update vvm_ram_dq to nexus style. * Update vvm_ram_dq to nexus style.
* *

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.3 2000/03/24 02:43:37 steve Exp $" #ident "$Id: vvm_func.cc,v 1.4 2000/03/25 02:43:56 steve Exp $"
#endif #endif
# include "vvm_func.h" # include "vvm_func.h"
@ -77,27 +77,22 @@ vpip_bit_t vvm_unop_xnor(const vvm_bits_t&r)
return B_NOT(v); return B_NOT(v);
} }
vvm_bitset_t<1> vvm_binop_eq(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_eq(const vvm_bits_t&l, const vvm_bits_t&r)
{ {
vvm_bitset_t<1> result;
result[0] = St1;
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
const unsigned rwid = r.get_width(); const unsigned rwid = r.get_width();
if (lwid <= rwid) { if (lwid <= rwid) {
for (unsigned idx = 0 ; idx < lwid ; idx += 1) { for (unsigned idx = 0 ; idx < lwid ; idx += 1) {
if (B_ISXZ(l.get_bit(idx))) { if (B_ISXZ(l.get_bit(idx)))
result[0] = StX; return StX;
return result;
} if (B_ISXZ(r.get_bit(idx)))
if (B_ISXZ(r.get_bit(idx))) { return StX;
result[0] = StX;
return result; if (! B_EQ(l.get_bit(idx), r.get_bit(idx)))
} return St0;
if (! B_EQ(l.get_bit(idx), r.get_bit(idx))) {
result[0] = St0;
return result;
}
} }
for (unsigned idx = lwid ; idx < rwid ; idx += 1) { for (unsigned idx = lwid ; idx < rwid ; idx += 1) {
@ -105,106 +100,83 @@ vvm_bitset_t<1> vvm_binop_eq(const vvm_bits_t&l, const vvm_bits_t&r)
if (B_IS0(r.get_bit(idx))) if (B_IS0(r.get_bit(idx)))
continue; continue;
if (B_IS1(r.get_bit(idx))) { if (B_IS1(r.get_bit(idx)))
result[0] = St0; return St0;
return result;
return StX;
} }
result[0] = StX; return St1;
return result;
}
return result;
} else { } else {
for (unsigned idx = 0 ; idx < rwid ; idx += 1) { for (unsigned idx = 0 ; idx < rwid ; idx += 1) {
if (B_ISXZ(l.get_bit(idx))) { if (B_ISXZ(l.get_bit(idx)))
result[0] = StX; return StX;
return result;
} if (B_ISXZ(r.get_bit(idx)))
if (B_ISXZ(r.get_bit(idx))) { return StX;
result[0] = StX;
return result; if (! B_EQ(l.get_bit(idx), r.get_bit(idx)))
} return St0;
if (! B_EQ(l.get_bit(idx), r.get_bit(idx))) {
result[0] = St0;
return result;
}
} }
for (unsigned idx = rwid ; idx < lwid ; idx += 1) { for (unsigned idx = rwid ; idx < lwid ; idx += 1) {
if (B_IS0(l.get_bit(idx))) if (B_IS0(l.get_bit(idx)))
continue; continue;
if (B_IS1(l.get_bit(idx))) { if (B_IS1(l.get_bit(idx)))
result[0] = St0; return St0;
return result;
return StX;
} }
result[0] = StX; return St1;
return result;
}
return result;
} }
} }
vvm_bitset_t<1> vvm_binop_ne(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_ne(const vvm_bits_t&l, const vvm_bits_t&r)
{ {
vvm_bitset_t<1> result = vvm_binop_eq(l,r); vpip_bit_t result = vvm_binop_eq(l,r);
result[0] = B_NOT(result[0]); return B_NOT(result);
return result;
} }
vvm_bitset_t<1> vvm_binop_eeq(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_eeq(const vvm_bits_t&l, const vvm_bits_t&r)
{ {
vvm_bitset_t<1> result;
result[0] = St1;
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
const unsigned rwid = r.get_width(); const unsigned rwid = r.get_width();
if (lwid <= rwid) { if (lwid <= rwid) {
for (unsigned idx = 0 ; idx < lwid ; idx += 1) for (unsigned idx = 0 ; idx < lwid ; idx += 1)
if (! B_EQ(l.get_bit(idx), r.get_bit(idx))) { if (! B_EQ(l.get_bit(idx), r.get_bit(idx)))
result[0] = St0; return St0;
return result;
}
for (unsigned idx = lwid ; idx < rwid ; idx += 1) for (unsigned idx = lwid ; idx < rwid ; idx += 1)
if (! B_IS0(r.get_bit(idx))) { if (! B_IS0(r.get_bit(idx)))
result[0] = St0; return St0;
return result;
}
} else { } else {
for (unsigned idx = 0 ; idx < rwid ; idx += 1) for (unsigned idx = 0 ; idx < rwid ; idx += 1)
if (! B_EQ(l.get_bit(idx), r.get_bit(idx))) { if (! B_EQ(l.get_bit(idx), r.get_bit(idx)))
result[0] = St0; return St0;
return result;
}
for (unsigned idx = rwid ; idx < lwid ; idx += 1) for (unsigned idx = rwid ; idx < lwid ; idx += 1)
if (! B_IS0(l.get_bit(idx))) { if (! B_IS0(l.get_bit(idx)))
result[0] = St0; return St0;
return result;
}
} }
return result; return St1;
} }
vvm_bitset_t<1> vvm_binop_nee(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_nee(const vvm_bits_t&l, const vvm_bits_t&r)
{ {
vvm_bitset_t<1> result = vvm_binop_eeq(l,r); vpip_bit_t result = vvm_binop_eeq(l,r);
result[0] = B_NOT(result[0]); return B_NOT(result);
return result;
} }
vvm_bitset_t<1> vvm_binop_xeq(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_xeq(const vvm_bits_t&l, const vvm_bits_t&r)
{ {
vvm_bitset_t<1> result;
result[0] = St1;
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
const unsigned rwid = r.get_width(); const unsigned rwid = r.get_width();
@ -214,18 +186,15 @@ vvm_bitset_t<1> vvm_binop_xeq(const vvm_bits_t&l, const vvm_bits_t&r)
continue; continue;
if (B_ISXZ(r.get_bit(idx))) if (B_ISXZ(r.get_bit(idx)))
continue; continue;
if (! B_EQ(l.get_bit(idx), r.get_bit(idx))) { if (! B_EQ(l.get_bit(idx), r.get_bit(idx)))
result[0] = St0; return St0;
return result;
}
} }
for (unsigned idx = lwid ; idx < rwid ; idx += 1) { for (unsigned idx = lwid ; idx < rwid ; idx += 1) {
if (B_ISXZ(r.get_bit(idx))) if (B_ISXZ(r.get_bit(idx)))
continue; continue;
if (! B_IS0(r.get_bit(idx))) { if (! B_IS0(r.get_bit(idx)))
result[0] = St0; return St0;
return result;
}
} }
} else { } else {
@ -234,28 +203,23 @@ vvm_bitset_t<1> vvm_binop_xeq(const vvm_bits_t&l, const vvm_bits_t&r)
continue; continue;
if (B_ISXZ(r.get_bit(idx))) if (B_ISXZ(r.get_bit(idx)))
continue; continue;
if (! B_EQ(l.get_bit(idx), r.get_bit(idx))) { if (! B_EQ(l.get_bit(idx), r.get_bit(idx)))
result[0] = St0; return St0;
return result;
}
} }
for (unsigned idx = rwid ; idx < lwid ; idx += 1) { for (unsigned idx = rwid ; idx < lwid ; idx += 1) {
if (B_ISXZ(l.get_bit(idx))) if (B_ISXZ(l.get_bit(idx)))
continue; continue;
if (! B_IS0(l.get_bit(idx))) { if (! B_IS0(l.get_bit(idx)))
result[0] = St0; return St0;
return result;
}
} }
} }
return result; return St1;
} }
vvm_bitset_t<1> vvm_binop_zeq(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_zeq(const vvm_bits_t&l, const vvm_bits_t&r)
{ {
vvm_bitset_t<1> result;
result[0] = St1;
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
const unsigned rwid = r.get_width(); const unsigned rwid = r.get_width();
@ -263,180 +227,149 @@ vvm_bitset_t<1> vvm_binop_zeq(const vvm_bits_t&l, const vvm_bits_t&r)
for (unsigned idx = 0 ; idx < lwid ; idx += 1) { for (unsigned idx = 0 ; idx < lwid ; idx += 1) {
if (B_ISZ(l.get_bit(idx)) || B_ISZ(r.get_bit(idx))) if (B_ISZ(l.get_bit(idx)) || B_ISZ(r.get_bit(idx)))
continue; continue;
if (! B_EQ(l.get_bit(idx), r.get_bit(idx))) { if (! B_EQ(l.get_bit(idx), r.get_bit(idx)))
result[0] = St0; return St0;
return result;
}
} }
for (unsigned idx = lwid ; idx < rwid ; idx += 1) { for (unsigned idx = lwid ; idx < rwid ; idx += 1) {
if (B_ISZ(r.get_bit(idx))) if (B_ISZ(r.get_bit(idx)))
continue; continue;
if (! B_IS0(r.get_bit(idx))) { if (! B_IS0(r.get_bit(idx)))
result[0] = St0; return St0;
return result;
}
} }
} else { } else {
for (unsigned idx = 0 ; idx < rwid ; idx += 1) { for (unsigned idx = 0 ; idx < rwid ; idx += 1) {
if (B_ISZ(l.get_bit(idx)) || B_ISZ(r.get_bit(idx))) if (B_ISZ(l.get_bit(idx)) || B_ISZ(r.get_bit(idx)))
continue; continue;
if (! B_EQ(l.get_bit(idx), r.get_bit(idx))) { if (! B_EQ(l.get_bit(idx), r.get_bit(idx)))
result[0] = St0; return St0;
return result;
}
} }
for (unsigned idx = rwid ; idx < lwid ; idx += 1) { for (unsigned idx = rwid ; idx < lwid ; idx += 1) {
if (B_ISZ(l.get_bit(idx))) if (B_ISZ(l.get_bit(idx)))
continue; continue;
if (! B_IS0(l.get_bit(idx))) { if (! B_IS0(l.get_bit(idx)))
result[0] = St0; return St0;
return result;
}
} }
} }
return result; return St1;
} }
vvm_bitset_t<1> vvm_binop_lt(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_lt(const vvm_bits_t&l, const vvm_bits_t&r)
{ {
vvm_bitset_t<1> result; vpip_bit_t result;
result[0] = St0; result = St0;
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
const unsigned rwid = r.get_width(); const unsigned rwid = r.get_width();
const unsigned common = (lwid < rwid)? lwid : rwid; const unsigned common = (lwid < rwid)? lwid : rwid;
for (unsigned idx = 0 ; idx < common ; idx += 1) for (unsigned idx = 0 ; idx < common ; idx += 1)
result[0] = less_with_cascade(l.get_bit(idx), result = less_with_cascade(l.get_bit(idx), r.get_bit(idx), result);
r.get_bit(idx),
result[0]);
if (lwid > rwid) { if (lwid > rwid) {
for (unsigned idx = rwid ; idx < lwid ; idx += 1) for (unsigned idx = rwid ; idx < lwid ; idx += 1)
result[0] = less_with_cascade(l.get_bit(idx), result = less_with_cascade(l.get_bit(idx), St0, result);
St0,
result[0]);
} else { } else {
for (unsigned idx = lwid ; idx < rwid ; idx += 1) for (unsigned idx = lwid ; idx < rwid ; idx += 1)
result[0] = less_with_cascade(St0, result = less_with_cascade(St0, r.get_bit(idx), result);
r.get_bit(idx),
result[0]);
} }
return result; return result;
} }
vvm_bitset_t<1> vvm_binop_le(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_le(const vvm_bits_t&l, const vvm_bits_t&r)
{ {
vvm_bitset_t<1> result; vpip_bit_t result = St1;
result[0] = St1;
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
const unsigned rwid = r.get_width(); const unsigned rwid = r.get_width();
const unsigned common = (lwid < rwid)? lwid : rwid; const unsigned common = (lwid < rwid)? lwid : rwid;
for (unsigned idx = 0 ; idx < common ; idx += 1) for (unsigned idx = 0 ; idx < common ; idx += 1)
result[0] = less_with_cascade(l.get_bit(idx), result = less_with_cascade(l.get_bit(idx), r.get_bit(idx), result);
r.get_bit(idx),
result[0]);
if (lwid > rwid) { if (lwid > rwid) {
for (unsigned idx = rwid ; idx < lwid ; idx += 1) for (unsigned idx = rwid ; idx < lwid ; idx += 1)
result[0] = less_with_cascade(l.get_bit(idx), result = less_with_cascade(l.get_bit(idx), St0, result);
St0,
result[0]);
} else { } else {
for (unsigned idx = lwid ; idx < rwid ; idx += 1) for (unsigned idx = lwid ; idx < rwid ; idx += 1)
result[0] = less_with_cascade(St0, result = less_with_cascade(St0, r.get_bit(idx), result);
r.get_bit(idx),
result[0]);
} }
return result; return result;
} }
vvm_bitset_t<1> vvm_binop_gt(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_gt(const vvm_bits_t&l, const vvm_bits_t&r)
{ {
vvm_bitset_t<1> result; vpip_bit_t result = St0;
result[0] = St0;
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
const unsigned rwid = r.get_width(); const unsigned rwid = r.get_width();
const unsigned common = (lwid < rwid)? lwid : rwid; const unsigned common = (lwid < rwid)? lwid : rwid;
for (unsigned idx = 0 ; idx < common ; idx += 1) for (unsigned idx = 0 ; idx < common ; idx += 1)
result[0] = greater_with_cascade(l.get_bit(idx), result = greater_with_cascade(l.get_bit(idx),
r.get_bit(idx), r.get_bit(idx),
result[0]); result);
if (lwid > rwid) { if (lwid > rwid) {
for (unsigned idx = rwid ; idx < lwid ; idx += 1) for (unsigned idx = rwid ; idx < lwid ; idx += 1)
result[0] = greater_with_cascade(l.get_bit(idx), result = greater_with_cascade(l.get_bit(idx), St0, result);
St0,
result[0]);
} else { } else {
for (unsigned idx = lwid ; idx < rwid ; idx += 1) for (unsigned idx = lwid ; idx < rwid ; idx += 1)
result[0] = greater_with_cascade(St0, result = greater_with_cascade(St0, r.get_bit(idx), result);
r.get_bit(idx),
result[0]);
} }
return result; return result;
} }
vvm_bitset_t<1> vvm_binop_ge(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_ge(const vvm_bits_t&l, const vvm_bits_t&r)
{ {
vvm_bitset_t<1> result; vpip_bit_t result = St1;
result[0] = St1;
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
const unsigned rwid = r.get_width(); const unsigned rwid = r.get_width();
const unsigned common = (lwid < rwid)? lwid : rwid; const unsigned common = (lwid < rwid)? lwid : rwid;
for (unsigned idx = 0 ; idx < common ; idx += 1) for (unsigned idx = 0 ; idx < common ; idx += 1)
result[0] = greater_with_cascade(l.get_bit(idx), result = greater_with_cascade(l.get_bit(idx),
r.get_bit(idx), r.get_bit(idx), result);
result[0]);
if (lwid > rwid) { if (lwid > rwid) {
for (unsigned idx = rwid ; idx < lwid ; idx += 1) for (unsigned idx = rwid ; idx < lwid ; idx += 1)
result[0] = greater_with_cascade(l.get_bit(idx), result = greater_with_cascade(l.get_bit(idx), St0, result);
St0,
result[0]);
} else { } else {
for (unsigned idx = lwid ; idx < rwid ; idx += 1) for (unsigned idx = lwid ; idx < rwid ; idx += 1)
result[0] = greater_with_cascade(St0, result = greater_with_cascade(St0, r.get_bit(idx), result);
r.get_bit(idx),
result[0]);
} }
return result; return result;
} }
vvm_bitset_t<1> vvm_binop_land(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_land(const vvm_bits_t&l, const vvm_bits_t&r)
{ {
vvm_bitset_t<1> res1; vpip_bit_t res1 = vvm_unop_or(l);
res1[0] = vvm_unop_or(l); vpip_bit_t res2 = vvm_unop_or(r);
vvm_bitset_t<1> res2; return B_AND(res1, res2);
res2[0] = vvm_unop_or(r);
res1[0] = B_AND(res1[0], res2[0]);
return res1;
} }
vvm_bitset_t<1> vvm_binop_lor(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_lor(const vvm_bits_t&l, const vvm_bits_t&r)
{ {
vvm_bitset_t<1> res1; vpip_bit_t res1 = vvm_unop_or(l);
res1[0] = vvm_unop_or(l); vpip_bit_t res2 = vvm_unop_or(r);
vvm_bitset_t<1> res2; return B_OR(res1, res2);
res2[0] = vvm_unop_or(r);
res1[0] = B_OR(res1[0], res2[0]);
return res1;
} }
/* /*
* $Log: vvm_func.cc,v $ * $Log: vvm_func.cc,v $
* Revision 1.4 2000/03/25 02:43:56 steve
* Remove all remain vvm_bitset_t return values,
* and disallow vvm_bitset_t copying.
*
* Revision 1.3 2000/03/24 02:43:37 steve * Revision 1.3 2000/03/24 02:43:37 steve
* vvm_unop and vvm_binop pass result by reference * vvm_unop and vvm_binop pass result by reference
* instead of returning a value. * instead of returning a value.

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.24 2000/03/24 02:43:37 steve Exp $" #ident "$Id: vvm_func.h,v 1.25 2000/03/25 02:43:57 steve Exp $"
#endif #endif
# include "vvm.h" # include "vvm.h"
@ -212,45 +212,45 @@ void vvm_binop_shiftr(vvm_bitset_t<WIDTH>&v,
* extended with zeros. Also, if there is Vx or Vz anywhere in either * extended with zeros. Also, if there is Vx or Vz anywhere in either
* vectors, the result is Vx. * vectors, the result is Vx.
*/ */
extern vvm_bitset_t<1> vvm_binop_eq(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_eq(const vvm_bits_t&l, const vvm_bits_t&r);
extern vvm_bitset_t<1> vvm_binop_ne(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_ne(const vvm_bits_t&l, const vvm_bits_t&r);
/* /*
* This function return true if all the bits are the same. Even x and * This function return true if all the bits are the same. Even x and
* z bites are compared for equality. * z bites are compared for equality.
*/ */
extern vvm_bitset_t<1> vvm_binop_eeq(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_eeq(const vvm_bits_t&l, const vvm_bits_t&r);
extern vvm_bitset_t<1> vvm_binop_nee(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_nee(const vvm_bits_t&l, const vvm_bits_t&r);
/* /*
* This function return true if all the bits are the same. The x and z * This function return true if all the bits are the same. The x and z
* bits are don't care, s don't make the result false. * bits are don't care, s don't make the result false.
*/ */
extern vvm_bitset_t<1> vvm_binop_xeq(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_xeq(const vvm_bits_t&l, const vvm_bits_t&r);
/* /*
* This function return true if all the bits are the same. The z * This function return true if all the bits are the same. The z
* bits are don't care, so don't make the result false. * bits are don't care, so don't make the result false.
*/ */
extern vvm_bitset_t<1> vvm_binop_zeq(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_zeq(const vvm_bits_t&l, const vvm_bits_t&r);
extern vvm_bitset_t<1> vvm_binop_lt(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_lt(const vvm_bits_t&l, const vvm_bits_t&r);
/* /*
* The <= operator takes operands of natural width and returns a * The <= operator takes operands of natural width and returns a
* single bit. The result is V1 if l <= r, otherwise V0; * single bit. The result is V1 if l <= r, otherwise V0;
*/ */
extern vvm_bitset_t<1> vvm_binop_le(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_le(const vvm_bits_t&l, const vvm_bits_t&r);
extern vvm_bitset_t<1> vvm_binop_gt(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_gt(const vvm_bits_t&l, const vvm_bits_t&r);
extern vvm_bitset_t<1> vvm_binop_ge(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_ge(const vvm_bits_t&l, const vvm_bits_t&r);
extern vvm_bitset_t<1> vvm_binop_land(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_land(const vvm_bits_t&l, const vvm_bits_t&r);
extern vvm_bitset_t<1> vvm_binop_lor(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_lor(const vvm_bits_t&l, const vvm_bits_t&r);
template <unsigned W> template <unsigned W>
void vvm_ternary(vvm_bitset_t<W>&v, vpip_bit_t c, void vvm_ternary(vvm_bitset_t<W>&v, vpip_bit_t c,
@ -278,6 +278,10 @@ void vvm_ternary(vvm_bitset_t<W>&v, vpip_bit_t c,
/* /*
* $Log: vvm_func.h,v $ * $Log: vvm_func.h,v $
* Revision 1.25 2000/03/25 02:43:57 steve
* Remove all remain vvm_bitset_t return values,
* and disallow vvm_bitset_t copying.
*
* Revision 1.24 2000/03/24 02:43:37 steve * Revision 1.24 2000/03/24 02:43:37 steve
* vvm_unop and vvm_binop pass result by reference * vvm_unop and vvm_binop pass result by reference
* instead of returning a value. * instead of returning a value.

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_gates.h,v 1.50 2000/03/24 03:47:01 steve Exp $" #ident "$Id: vvm_gates.h,v 1.51 2000/03/25 02:43:57 steve Exp $"
#endif #endif
# include "vvm.h" # include "vvm.h"
@ -488,7 +488,8 @@ class vvm_ram_dq : protected vvm_ram_callback, public vvm_nexus::recvr_t {
} }
void send_out_() void send_out_()
{ vvm_bitset_t<WIDTH>ov = mem_->get_word(addr_val_); { vvm_bitset_t<WIDTH>ov;
mem_->get_word(addr_val_, ov);
for (unsigned bit = 0 ; bit < WIDTH ; bit += 1) { for (unsigned bit = 0 ; bit < WIDTH ; bit += 1) {
vvm_out_event*ev = new vvm_out_event(ov[bit], out_+bit); vvm_out_event*ev = new vvm_out_event(ov[bit], out_+bit);
ev->schedule(); ev->schedule();
@ -754,7 +755,7 @@ template <unsigned WIDTH> class vvm_pevent : public vvm_nexus::recvr_t {
value_[idx] = HiZ; value_[idx] = HiZ;
} }
vvm_bitset_t<WIDTH> get() const { return value_; } vpip_bit_t get(unsigned idx) const { return value_[idx]; }
void init_P(int idx, vpip_bit_t val) void init_P(int idx, vpip_bit_t val)
{ assert(idx < WIDTH); { assert(idx < WIDTH);
@ -794,6 +795,10 @@ template <unsigned WIDTH> class vvm_pevent : public vvm_nexus::recvr_t {
/* /*
* $Log: vvm_gates.h,v $ * $Log: vvm_gates.h,v $
* Revision 1.51 2000/03/25 02:43:57 steve
* Remove all remain vvm_bitset_t return values,
* and disallow vvm_bitset_t copying.
*
* Revision 1.50 2000/03/24 03:47:01 steve * Revision 1.50 2000/03/24 03:47:01 steve
* Update vvm_ram_dq to nexus style. * Update vvm_ram_dq to nexus style.
* *

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_signal.h,v 1.4 2000/03/24 02:43:37 steve Exp $" #ident "$Id: vvm_signal.h,v 1.5 2000/03/25 02:43:57 steve Exp $"
#endif #endif
# include "vvm.h" # include "vvm.h"
@ -38,23 +38,6 @@ template <unsigned WIDTH> class vvm_bitset_t : public vvm_bits_t {
{ for (unsigned idx = 0 ; idx < WIDTH ; idx += 1) { for (unsigned idx = 0 ; idx < WIDTH ; idx += 1)
bits[idx] = HiZ; bits[idx] = HiZ;
} }
#if 0
vvm_bitset_t(const vvm_bits_t&that)
{ unsigned wid = WIDTH;
if (that.get_width() < WIDTH)
wid = that.get_width();
for (unsigned idx = 0 ; idx < wid ; idx += 1)
bits[idx] = that.get_bit(idx);
for (unsigned idx = wid ; idx < WIDTH ; idx += 1)
bits[idx] = St0;
}
#endif
#if 0
vvm_bitset_t(const vvm_bitset_t<WIDTH>&that)
{ for (unsigned idx = 0; idx < WIDTH; idx += 1)
bits[idx] = that.bits[idx];
}
#endif
vpip_bit_t operator[] (unsigned idx) const { return bits[idx]; } vpip_bit_t operator[] (unsigned idx) const { return bits[idx]; }
vpip_bit_t&operator[] (unsigned idx) { return bits[idx]; } vpip_bit_t&operator[] (unsigned idx) { return bits[idx]; }
@ -64,6 +47,10 @@ template <unsigned WIDTH> class vvm_bitset_t : public vvm_bits_t {
public: public:
vpip_bit_t bits[WIDTH]; vpip_bit_t bits[WIDTH];
private: // not implemented
vvm_bitset_t(const vvm_bitset_t<WIDTH>&);
vvm_bitset_t<WIDTH>& operator= (const vvm_bitset_t<WIDTH>&);
}; };
/* /*
@ -117,13 +104,11 @@ class vvm_memory_t : public __vpiMemory {
call_list_(addr); call_list_(addr);
} }
vvm_bitset_t<WIDTH> get_word(unsigned addr) const void get_word(unsigned addr, vvm_bitset_t<WIDTH>&val) const
{ vvm_bitset_t<WIDTH> val; { unsigned base = WIDTH * addr;
unsigned base = WIDTH * addr;
assert(addr < size); assert(addr < size);
for (unsigned idx = 0 ; idx < WIDTH ; idx += 1) for (unsigned idx = 0 ; idx < WIDTH ; idx += 1)
val[idx] = bits[base+idx]; val[idx] = bits[base+idx];
return val;
} }
void set_callback(vvm_ram_callback*ram) void set_callback(vvm_ram_callback*ram)
@ -135,7 +120,10 @@ class vvm_memory_t : public __vpiMemory {
public: public:
assign_nb(vvm_memory_t<WIDTH,SIZE>&m, unsigned i, assign_nb(vvm_memory_t<WIDTH,SIZE>&m, unsigned i,
const vvm_bitset_t<WIDTH>&v) const vvm_bitset_t<WIDTH>&v)
: mem_(m), index_(i), val_(v) { } : mem_(m), index_(i)
{ for (unsigned idx = 0 ; idx < WIDTH ; idx += 1)
val_[idx] = v[idx];
}
void event_function() { mem_.set_word(index_, val_); } void event_function() { mem_.set_word(index_, val_); }
@ -156,6 +144,10 @@ class vvm_memory_t : public __vpiMemory {
/* /*
* $Log: vvm_signal.h,v $ * $Log: vvm_signal.h,v $
* Revision 1.5 2000/03/25 02:43:57 steve
* Remove all remain vvm_bitset_t return values,
* and disallow vvm_bitset_t copying.
*
* Revision 1.4 2000/03/24 02:43:37 steve * Revision 1.4 2000/03/24 02:43:37 steve
* vvm_unop and vvm_binop pass result by reference * vvm_unop and vvm_binop pass result by reference
* instead of returning a value. * instead of returning a value.