vvp: Implement partial writes to 2-state arrays
Writes to 2-state arrays currently only support full writes. If the write is a partial write it will trigger an assert. E.g. ``` int a[3:0] int i = -1; a[i+:8] = 8'h0; // Triggers assert ``` Add support for partial writes by doing a read-modify-write in the same way as for 4-state arrays. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
9a50956f5e
commit
2346cc8b69
19
vvp/array.cc
19
vvp/array.cc
|
|
@ -602,10 +602,21 @@ void __vpiArray::set_word(unsigned address, unsigned part_off, const vvp_vector4
|
|||
|
||||
if (vals) {
|
||||
assert(nets == 0);
|
||||
// FIXME: For now, assume no part select of word?
|
||||
assert(part_off==0);
|
||||
assert(val.size() == vals_width);
|
||||
vals->set_word(address, val);
|
||||
if (part_off != 0 || val.size() != vals_width) {
|
||||
vvp_vector4_t tmp;
|
||||
vals->get_word(address, tmp);
|
||||
if ((part_off + val.size()) > tmp.size()) {
|
||||
cerr << "part_off=" << part_off
|
||||
<< " val.size()=" << val.size()
|
||||
<< " vals[address].size()=" << tmp.size()
|
||||
<< " vals_width=" << vals_width << endl;
|
||||
assert(0);
|
||||
}
|
||||
tmp.set_vec(part_off, val);
|
||||
vals->set_word(address, tmp);
|
||||
} else {
|
||||
vals->set_word(address, val);
|
||||
}
|
||||
word_change(address);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue