Add to vvm proceedural memory references.

This commit is contained in:
steve 1999-04-22 04:56:58 +00:00
parent 5895d3c98d
commit d3350c9b27
3 changed files with 65 additions and 14 deletions

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) #if !defined(WINNT)
#ident "$Id: netlist.h,v 1.23 1999/04/19 01:59:36 steve Exp $" #ident "$Id: netlist.h,v 1.24 1999/04/22 04:56:58 steve Exp $"
#endif #endif
/* /*
@ -283,6 +283,20 @@ class NetMemory {
const string&name() const { return name_; } const string&name() const { return name_; }
unsigned width() const { return width_; } unsigned width() const { return width_; }
unsigned count() const
{ if (idxh_ < idxl_)
return idxl_ - idxh_ + 1;
else
return idxh_ - idxl_ + 1;
}
unsigned index_to_address(long idx) const
{ if (idxh_ < idxl_)
return idx - idxh_;
else
return idx - idxl_;
}
void set_attributes(const map<string,string>&a); void set_attributes(const map<string,string>&a);
void dump(ostream&o, unsigned lm) const; void dump(ostream&o, unsigned lm) const;
@ -920,6 +934,9 @@ class NetEMemory : public NetExpr {
NetEMemory(NetMemory*mem, NetExpr*idx); NetEMemory(NetMemory*mem, NetExpr*idx);
virtual ~NetEMemory(); virtual ~NetEMemory();
const string& name () const { return mem_->name(); }
const NetExpr* index() const { return idx_.ref(); }
virtual void set_width(unsigned); virtual void set_width(unsigned);
virtual void expr_scan(struct expr_scan_t*) const; virtual void expr_scan(struct expr_scan_t*) const;
virtual void dump(ostream&) const; virtual void dump(ostream&) const;
@ -1086,6 +1103,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.24 1999/04/22 04:56:58 steve
* Add to vvm proceedural memory references.
*
* Revision 1.23 1999/04/19 01:59:36 steve * Revision 1.23 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases. * Add memories to the parse and elaboration phases.
* *

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) #if !defined(WINNT)
#ident "$Id: t-vvm.cc,v 1.15 1999/04/19 01:59:37 steve Exp $" #ident "$Id: t-vvm.cc,v 1.16 1999/04/22 04:56:58 steve Exp $"
#endif #endif
# include <iostream> # include <iostream>
@ -91,6 +91,15 @@ class vvm_proc_rval : public expr_scan_t {
private: private:
virtual void expr_const(const NetEConst*); virtual void expr_const(const NetEConst*);
virtual void expr_ident(const NetEIdent*); virtual void expr_ident(const NetEIdent*);
virtual void expr_memory(const NetEMemory*mem)
{
mem->index()->expr_scan(this);
string idx = make_temp();
os_ << setw(indent_) << "" << "const unsigned " <<
idx << " = " << result << ".as_unsigned();" <<
endl;
result = mangle(mem->name()) + "[" + idx + "]";
}
virtual void expr_signal(const NetESignal*); virtual void expr_signal(const NetESignal*);
virtual void expr_unary(const NetEUnary*); virtual void expr_unary(const NetEUnary*);
virtual void expr_binary(const NetEBinary*); virtual void expr_binary(const NetEBinary*);
@ -224,15 +233,7 @@ class vvm_parm_rval : public expr_scan_t {
string result; string result;
private: private:
virtual void expr_const(const NetEConst*); virtual void expr_const(const NetEConst*expr)
virtual void expr_ident(const NetEIdent*);
virtual void expr_signal(const NetESignal*);
private:
ostream&os_;
};
void vvm_parm_rval::expr_const(const NetEConst*expr)
{ {
if (expr->value().is_string()) { if (expr->value().is_string()) {
result = "\""; result = "\"";
@ -241,6 +242,14 @@ void vvm_parm_rval::expr_const(const NetEConst*expr)
} }
} }
virtual void expr_ident(const NetEIdent*);
virtual void expr_signal(const NetESignal*);
private:
ostream&os_;
};
void vvm_parm_rval::expr_ident(const NetEIdent*expr) void vvm_parm_rval::expr_ident(const NetEIdent*expr)
{ {
if (expr->name() == "$time") { if (expr->name() == "$time") {
@ -336,7 +345,8 @@ void target_vvm::signal(ostream&os, const NetNet*sig)
void target_vvm::memory(ostream&os, const NetMemory*mem) void target_vvm::memory(ostream&os, const NetMemory*mem)
{ {
os << "static vvm_bitset_t<" << mem->width() << "> " << os << "static vvm_bitset_t<" << mem->width() << "> " <<
mangle(mem->name()) << "[" << "];" << endl; mangle(mem->name()) << "[" << mem->count() << "]; " <<
"/* " << mem->name() << " */" << endl;
} }
/* /*
@ -618,6 +628,7 @@ void target_vvm::proc_assign(ostream&os, const NetAssign*net)
for (unsigned idx = 0 ; idx < net->pin_count() ; idx += 1) { for (unsigned idx = 0 ; idx < net->pin_count() ; idx += 1) {
const NetObj*cur; const NetObj*cur;
unsigned pin; unsigned pin;
for (net->pin(idx).next_link(cur, pin) for (net->pin(idx).next_link(cur, pin)
; net->pin(idx) != cur->pin(pin) ; net->pin(idx) != cur->pin(pin)
; cur->pin(pin).next_link(cur, pin)) { ; cur->pin(pin).next_link(cur, pin)) {
@ -890,6 +901,9 @@ extern const struct target tgt_vvm = {
}; };
/* /*
* $Log: t-vvm.cc,v $ * $Log: t-vvm.cc,v $
* Revision 1.16 1999/04/22 04:56:58 steve
* Add to vvm proceedural memory references.
*
* Revision 1.15 1999/04/19 01:59:37 steve * Revision 1.15 1999/04/19 01:59:37 steve
* Add memories to the parse and elaboration phases. * Add memories to the parse and elaboration phases.
* *

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) #if !defined(WINNT)
#ident "$Id: vvm.h,v 1.5 1999/03/16 04:43:46 steve Exp $" #ident "$Id: vvm.h,v 1.6 1999/04/22 04:56:58 steve Exp $"
#endif #endif
# include <vector> # include <vector>
@ -117,6 +117,15 @@ template <unsigned WIDTH> class vvm_bitset_t : public vvm_bits_t {
return true; return true;
} }
unsigned as_unsigned() const
{ unsigned result = 0;
for (unsigned idx = WIDTH ; idx > 0 ; idx -= 1) {
result <<= 1;
if (bits_[idx-1]) result |= 1;
}
return result;
}
private: private:
vvm_bit_t bits_[WIDTH]; vvm_bit_t bits_[WIDTH];
}; };
@ -243,12 +252,20 @@ template <unsigned WIDTH> class vvm_signal_t : public vvm_monitor_t {
trigger(sim); trigger(sim);
} }
void set(vvm_simulation*sim, const vvm_bitset_t<WIDTH>&val)
{ for (unsigned idx = 0 ; idx < WIDTH ; idx += 1)
set(sim, idx, val[idx]);
}
private: private:
vvm_bitset_t<WIDTH>*bits_; vvm_bitset_t<WIDTH>*bits_;
}; };
/* /*
* $Log: vvm.h,v $ * $Log: vvm.h,v $
* Revision 1.6 1999/04/22 04:56:58 steve
* Add to vvm proceedural memory references.
*
* Revision 1.5 1999/03/16 04:43:46 steve * Revision 1.5 1999/03/16 04:43:46 steve
* Add some logical operators. * Add some logical operators.
* *