More resilient assignment to memory location.

This commit is contained in:
steve 1999-10-01 03:58:36 +00:00
parent 393c9ab108
commit e1c697a746
2 changed files with 35 additions and 6 deletions

View File

@ -244,8 +244,12 @@ current state of support for Verilog.
- Min/Typ/Max expressions: Example: a = (1 : 6 : 14);
- Non-scalar memories, i.e. other than registers.
Example: reg [1:0] b [2:0];
- Memories work, but only in procedural code.
reg [1:0] b [2:0], bar;
wire [1:0] foo;
always foo = b[i]; // sorry
always @(i) bar = b[i]; // OK
- `timescale directive
@ -262,7 +266,8 @@ current state of support for Verilog.
- fork/join is not supported in vvm runtime
- structural arithmetic operators are in general not supported.
- structural arithmetic operators are in general not
supported. Procedural expressions are OK.
assign foo = a + b; // sorry
always @(a or b) foo = a + b; // OK

View File

@ -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.54 1999/10/01 03:15:00 steve Exp $"
#ident "$Id: t-vvm.cc,v 1.55 1999/10/01 03:58:37 steve Exp $"
#endif
# include <iostream>
@ -1166,6 +1166,11 @@ void target_vvm::proc_assign(ostream&os, const NetAssign*net)
}
}
/*
* Generate an assignment to a memory location. This causes the index
* expression to be evaluated (run-time) and the index used as the
* location to store the value.
*/
void target_vvm::proc_assign_mem(ostream&os, const NetAssignMem*amem)
{
string index = emit_proc_rval(defn, 8, amem->index());
@ -1173,8 +1178,24 @@ void target_vvm::proc_assign_mem(ostream&os, const NetAssignMem*amem)
const NetMemory*mem = amem->memory();
defn << " /* " << amem->get_line() << " */" << endl;
defn << " " << mangle(mem->name())
<< "[" << index << ".as_unsigned()] = " << rval << ";" << endl;
if (mem->width() == amem->rval()->expr_width()) {
defn << " " << mangle(mem->name())
<< "[" << index << ".as_unsigned()] = " << rval <<
";" << endl;
} else {
assert(mem->width() <= amem->rval()->expr_width());
string tmp = make_temp();
defn << " vvm_bitset_t<" << mem->width() << ">" <<
tmp << ";" << endl;
for (unsigned idx = 0 ; idx < mem->width() ; idx += 1)
defn << " " << tmp << "[" << idx << "] = " <<
rval << "[" << idx << "];" << endl;
defn << " " << mangle(mem->name())
<< "[" << index << ".as_unsigned()] = " << tmp << ";"
<< endl;
}
}
void target_vvm::proc_assign_nb(ostream&os, const NetAssignNB*net)
@ -1648,6 +1669,9 @@ extern const struct target tgt_vvm = {
};
/*
* $Log: t-vvm.cc,v $
* Revision 1.55 1999/10/01 03:58:37 steve
* More resilient assignment to memory location.
*
* Revision 1.54 1999/10/01 03:15:00 steve
* Rewrite vvm output to separateclass declarations
* from method definitions. This is required to allow