Issue #544
Support associative arrays
| Status: | Feature | Start date: | 08/09/2012 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | Unsupported | |||
| Target version: | - |
Description
Obviously not synthesizable but useful for testbenches and behavioral models.
Example:
bit [MEM_DQ_WIDTH - 1:0] mem_data[*]
History
Updated by Wilson Snyder 10 months ago
- Category set to Unsupported
- Status changed from New to Feature
Unfortunately not high priority for my usage, and requires moderate work as it's a dynamic construct. Perhaps you or someone else will be interested in implementing it.
Updated by Alex Solomatnikov 10 months ago
Could you explain a little bit what needs to be done for this? I am assuming backend implementation would use an existing map, e.g. STL map?
Updated by Wilson Snyder 10 months ago
It's not too hard, just a lot of effort on details. First there's the parsing, and creating related Ast node types which is pretty easy. The big thing is all present internal analysis assumes the entire state of the model is available for static analysis, that will have to be bypassed. (Not allowing <= assignments would simplify.) Then the actual implementation which can yes be a map, though the key type needs to allow arbitrary width numbers. This needs to be implemented (as most things are) in both verilator for static analysis and in the runtime. Finally there's how to waveform trace something like this.
If you only have a few, you can easily make a dpi function to do your lookup or faster something like this instead (untested): Note that using `systemc stuff disables some optimizations.
`systemc_header
#include <map>
`systemc_interface
map<vluint64_t,vluint64_t> mem_data;
`verilog
...
// mem_data[y] = x
$c("mem_data[",y,"]=",x);
// x = mem_data[y]
x = $c64("mem_data[",y,"]");
Updated by Wilson Snyder 10 months ago
Fixed lookup line to "mem_data[",y,"]".
Also available in: Atom
![[logo]](/img/veripool_small.png)