Permalink
Browse files

Create the vpiMemory handle type.

  • Loading branch information...
1 parent 02f8099 commit 82f3f0f741be8d5e31db2cb64742ebf6a1d5f226 steve committed Nov 10, 1999
Showing with 195 additions and 36 deletions.
  1. +5 −2 elab_expr.cc
  2. +10 −1 elaborate.cc
  3. +30 −19 t-vvm.cc
  4. +6 −1 vpi/vpi_user.h
  5. +2 −2 vvm/Makefile.in
  6. +91 −0 vvm/vpi_memory.c
  7. +28 −10 vvm/vpi_priv.h
  8. +23 −1 vvm/vvm.h
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
-#ident "$Id: elab_expr.cc,v 1.7 1999/10/18 00:02:21 steve Exp $"
+#ident "$Id: elab_expr.cc,v 1.8 1999/11/10 02:52:24 steve Exp $"
#endif
@@ -271,7 +271,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, const string&path) const
assert(lsb_ == 0);
assert(idx_ == 0);
NetExpr*i = msb_->elaborate_expr(des, path);
- if (i == 0) {
+ if (msb_ && i == 0) {
cerr << get_line() << ": error: Unable to exaborate "
"index expression `" << *msb_ << "'" << endl;
des->errors += 1;
@@ -324,6 +324,9 @@ NetExpr*PETernary::elaborate_expr(Design*des, const string&path) const
/*
* $Log: elab_expr.cc,v $
+ * Revision 1.8 1999/11/10 02:52:24 steve
+ * Create the vpiMemory handle type.
+ *
* Revision 1.7 1999/10/18 00:02:21 steve
* Catch unindexed memory reference.
*
View
@@ -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.122 1999/11/05 21:45:19 steve Exp $"
+#ident "$Id: elaborate.cc,v 1.123 1999/11/10 02:52:24 steve Exp $"
#endif
/*
@@ -1671,13 +1671,19 @@ NetProc* PCallTask::elaborate(Design*des, const string&path) const
/*
* A call to a system task involves elaborating all the parameters,
* then passing the list to the NetSTask object.
+ *XXXX
+ * There is a single special in the call to a system task. Normally,
+ * an expression cannot take an unindexed memory. However, it is
+ * possible to take a system task parameter a memory if the expression
+ * is trivial.
*/
NetProc* PCallTask::elaborate_sys(Design*des, const string&path) const
{
svector<NetExpr*>eparms (nparms());
for (unsigned idx = 0 ; idx < nparms() ; idx += 1) {
PExpr*ex = parm(idx);
+
eparms[idx] = ex? ex->elaborate_expr(des, path) : 0;
}
@@ -2329,6 +2335,9 @@ Design* elaborate(const map<string,Module*>&modules,
/*
* $Log: elaborate.cc,v $
+ * Revision 1.123 1999/11/10 02:52:24 steve
+ * Create the vpiMemory handle type.
+ *
* Revision 1.122 1999/11/05 21:45:19 steve
* Fix NetConst being set to zero width, and clean
* up elaborate_set_cmp_ for NetEBinary.
View
@@ -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.72 1999/11/06 16:00:17 steve Exp $"
+#ident "$Id: t-vvm.cc,v 1.73 1999/11/10 02:52:24 steve Exp $"
#endif
# include <iostream>
@@ -154,15 +154,7 @@ class vvm_proc_rval : public expr_scan_t {
virtual void expr_const(const NetEConst*);
virtual void expr_concat(const NetEConcat*);
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_memory(const NetEMemory*mem);
virtual void expr_signal(const NetESignal*);
virtual void expr_subsignal(const NetESubSignal*sig);
virtual void expr_ternary(const NetETernary*);
@@ -243,6 +235,13 @@ void vvm_proc_rval::expr_ident(const NetEIdent*expr)
result = mangle(expr->name());
}
+void vvm_proc_rval::expr_memory(const NetEMemory*mem)
+{
+ const string mname = mangle(mem->name());
+ mem->index()->expr_scan(this);
+ result = mname + ".get_word(" + result + ".as_unsigned())";
+}
+
void vvm_proc_rval::expr_signal(const NetESignal*expr)
{
result = mangle(expr->name()) + "_bits";
@@ -482,6 +481,7 @@ class vvm_parm_rval : public expr_scan_t {
private:
virtual void expr_const(const NetEConst*expr);
virtual void expr_ident(const NetEIdent*);
+ virtual void expr_memory(const NetEMemory*mem);
virtual void expr_signal(const NetESignal*);
private:
@@ -553,6 +553,12 @@ void vvm_parm_rval::expr_ident(const NetEIdent*expr)
}
}
+void vvm_parm_rval::expr_memory(const NetEMemory*mem)
+{
+ assert(mem->index() == 0);
+ result = string("&") + mangle(mem->name()) + ".base";
+}
+
void vvm_parm_rval::expr_signal(const NetESignal*expr)
{
string res = string("&") + mangle(expr->name()) + ".base";
@@ -717,9 +723,13 @@ void target_vvm::signal(ostream&os, const NetNet*sig)
void target_vvm::memory(ostream&os, const NetMemory*mem)
{
- os << "static vvm_bitset_t<" << mem->width() << "> " <<
- mangle(mem->name()) << "[" << mem->count() << "]; " <<
- "/* " << mem->name() << " */" << endl;
+ const string mname = mangle(mem->name());
+ os << "static vvm_memory_t<" << mem->width() << ", " <<
+ mem->count() << "> " << mname << ";"
+ " /* " << mem->name() << " */" << endl;
+ init_code << " vpip_make_memory(&" << mname << ", \"" <<
+ mem->name() << "\", " << mem->width() << ", " <<
+ mem->count() << ");" << endl;
}
void target_vvm::task_def(ostream&os, const NetTaskDef*def)
@@ -1352,9 +1362,8 @@ void target_vvm::proc_assign_mem(ostream&os, const NetAssignMem*amem)
defn << " /* " << amem->get_line() << " */" << endl;
if (mem->width() == amem->rval()->expr_width()) {
- defn << " " << mangle(mem->name())
- << "[" << index << ".as_unsigned()] = " << rval <<
- ";" << endl;
+ defn << " " << mangle(mem->name()) << ".set_word(" <<
+ index << ".as_unsigned(), " << rval << ");" << endl;
} else {
assert(mem->width() <= amem->rval()->expr_width());
@@ -1365,9 +1374,8 @@ void target_vvm::proc_assign_mem(ostream&os, const NetAssignMem*amem)
defn << " " << tmp << "[" << idx << "] = " <<
rval << "[" << idx << "];" << endl;
- defn << " " << mangle(mem->name())
- << "[" << index << ".as_unsigned()] = " << tmp << ";"
- << endl;
+ defn << " " << mangle(mem->name()) << ".set_word(" <<
+ index << ".as_unsigned(), " << tmp << ");" << endl;
}
}
@@ -1839,6 +1847,9 @@ extern const struct target tgt_vvm = {
};
/*
* $Log: t-vvm.cc,v $
+ * Revision 1.73 1999/11/10 02:52:24 steve
+ * Create the vpiMemory handle type.
+ *
* Revision 1.72 1999/11/06 16:00:17 steve
* Put number constants into a static table.
*
View
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
-#ident "$Id: vpi_user.h,v 1.6 1999/11/07 20:33:30 steve Exp $"
+#ident "$Id: vpi_user.h,v 1.7 1999/11/10 02:52:24 steve Exp $"
#endif
#ifdef __cplusplus
@@ -96,6 +96,8 @@ typedef struct t_vpi_value {
/* OBJECT CODES */
#define vpiConstant 7
#define vpiIterator 27
+#define vpiMemory 29
+#define vpiMemoryWord 30
#define vpiNet 36
#define vpiReg 48
#define vpiSysTaskCall 57
@@ -205,6 +207,9 @@ extern void (*vlog_startup_routines[])();
/*
* $Log: vpi_user.h,v $
+ * Revision 1.7 1999/11/10 02:52:24 steve
+ * Create the vpiMemory handle type.
+ *
* Revision 1.6 1999/11/07 20:33:30 steve
* Add VCD output and related system tasks.
*
View
@@ -18,7 +18,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
-#ident "$Id: Makefile.in,v 1.10 1999/10/28 21:36:00 steve Exp $"
+#ident "$Id: Makefile.in,v 1.11 1999/11/10 02:52:24 steve Exp $"
#
#
SHELL = /bin/sh
@@ -62,7 +62,7 @@ O = vvm_bit.o vvm_calltf.o vvm_event.o vvm_pevent.o \
vvm_simulation.o vvm_thread.o vpip.o
P = vpi_callback.o \
-vpi_const.o vpi_iter.o vpi_null.o \
+vpi_const.o vpi_iter.o vpi_memory.o vpi_null.o \
vpi_priv.o vpi_signal.o vpi_simulation.o vpi_systask.o vpi_time.o
libvvm.a: $O
View
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 1999 Picture Elements, Inc.
+ * Stephen Williams (steve@picturel.com)
+ *
+ * This source code is free software; you can redistribute it
+ * and/or modify it in source code form under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version. In order to redistribute the software in
+ * binary form, you will need a Picture Elements Binary Software
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * ---
+ * You should also have recieved a copy of the Picture Elements
+ * Binary Software License offer along with the source. This offer
+ * allows you to obtain the right to redistribute the software in
+ * binary (compiled) form. If you have not received it, contact
+ * Picture Elements, Inc., 777 Panoramic Way, Berkeley, CA 94704.
+ */
+#if !defined(WINNT)
+#ident "$Id: vpi_memory.c,v 1.1 1999/11/10 02:52:24 steve Exp $"
+#endif
+
+# include "vpi_priv.h"
+# include <stdlib.h>
+# include <assert.h>
+
+static int memory_get(int code, vpiHandle ref)
+{
+ struct __vpiMemory*rfp = (struct __vpiMemory*)ref;
+
+ assert(ref->vpi_type->type_code==vpiMemory);
+
+ switch (code) {
+ case vpiSize:
+ return rfp->size;
+
+ default:
+ return 0;
+ }
+}
+
+static char* memory_get_str(int code, vpiHandle ref)
+{
+ struct __vpiMemory*rfp = (struct __vpiMemory*)ref;
+
+ assert(ref->vpi_type->type_code==vpiMemory);
+
+ switch (code) {
+
+ case vpiFullName:
+ return (char*)rfp->name;
+ }
+
+ return 0;
+}
+
+static const struct __vpirt vpip_memory_rt = {
+ vpiMemory,
+ memory_get,
+ memory_get_str,
+ 0,
+ 0,
+ 0
+};
+
+vpiHandle vpip_make_memory(struct __vpiMemory*ref, const char*name,
+ unsigned wid, unsigned siz)
+{
+ ref->base.vpi_type = &vpip_memory_rt;
+ ref->name = name;
+ ref->bits = calloc(wid*siz, sizeof(enum vpip_bit_t));
+ ref->width = wid;
+ ref->size = siz;
+ return &(ref->base);
+}
+/*
+ * $Log: vpi_memory.c,v $
+ * Revision 1.1 1999/11/10 02:52:24 steve
+ * Create the vpiMemory handle type.
+ *
+ */
+
View
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
-#ident "$Id: vpi_priv.h,v 1.5 1999/11/06 16:52:16 steve Exp $"
+#ident "$Id: vpi_priv.h,v 1.6 1999/11/10 02:52:24 steve Exp $"
#endif
/*
@@ -80,15 +80,6 @@ struct __vpiCallback {
};
/*
- * This type is occasionally useful. Really! And while we're at it,
- * create a single instance of the null object. (This is all we need.)
- */
-struct __vpiNull {
- struct __vpiHandle base;
-};
-extern struct __vpiNull vpip_null;
-
-/*
* The vpiHandle for an iterator has this structure. The definition of
* the methods lives in vpi_iter.c
*/
@@ -101,6 +92,28 @@ struct __vpiIterator {
};
/*
+ * Memory is an array of bits that is accessible in N-bit chunks, with
+ * N being the width of a word.
+ */
+struct __vpiMemory {
+ struct __vpiHandle base;
+ /* The signal has a name (this points to static memory.) */
+ const char*name;
+ enum vpip_bit_t*bits;
+ unsigned width;
+ unsigned size;
+};
+
+/*
+ * This type is occasionally useful. Really! And while we're at it,
+ * create a single instance of the null object. (This is all we need.)
+ */
+struct __vpiNull {
+ struct __vpiHandle base;
+};
+extern struct __vpiNull vpip_null;
+
+/*
* This structure represents nets and registers. You can tell which by
* the type_code in the base. The bits member points to the actual
* array of bits that the environment provides. The bits must persist
@@ -173,6 +186,8 @@ extern vpiHandle vpip_make_string_const(struct __vpiStringConst*ref,
extern vpiHandle vpip_make_number_const(struct __vpiNumberConst*ref,
const enum vpip_bit_t*bits,
unsigned nbits);
+extern vpiHandle vpip_make_memory(struct __vpiMemory*ref, const char*name,
+ unsigned width, unsigned size);
extern vpiHandle vpip_make_reg(struct __vpiSignal*ref, const char*name);
extern vpiHandle vpip_make_time_var(struct __vpiTimeVar*ref,
const char*val);
@@ -239,6 +254,9 @@ extern int vpip_finished();
/*
* $Log: vpi_priv.h,v $
+ * Revision 1.6 1999/11/10 02:52:24 steve
+ * Create the vpiMemory handle type.
+ *
* Revision 1.5 1999/11/06 16:52:16 steve
* complete value retrieval for number constants.
*
Oops, something went wrong.

0 comments on commit 82f3f0f

Please sign in to comment.