Comments (3)
Sounds like there are two separate questions here.
Using parametric values is supported via component parameters. For example:
addrmap top #(longint unsigned N=4) {
reg my_reg_t {
field {} f;
};
my_reg_t reg_array[N];
};
In the above example, reg_array
defaults to have 4 elements, but if needed, could be overridden to any other value via the parameter.
Unfortunately, as the spec is currently written, it doesn't allow for parameters to be used in a definition such as an enum (due to clause 5.1.1.2-d). For example, this would not be allowed due to the current namespace rules:
addrmap top #(longint unsigned N=4) {
enum my_enum {
abcd = N;
};
};
However I'm starting to question whether the spec authors even know about their own rule described in 5.1.1.2-d since they seem to violate it all the time in their examples.
Did that answer your question? If not, maybe a more specific use-case would help me understand what you are trying to do.
from systemrdl-compiler.
First of all, thanks for the response!
I'm trying to assign a value to a parameter dynamically. For design and verification purposes, it's necessary for me to be able to override some values while using some of the design in higher\ lower levels.
Let's look at the example you used in your comment. Is it possible to change the value of 'N' in another part of the code? like:
addrmap top #(longint unsigned N=4) {
reg my_reg_t {
field {} f;
};
my_reg_t reg_array[N];
N=7;
my_reg_t new_reg_array[N];
};
Or, assigning 'N' with a value that comes from another component's property? using the same example:
addrmap top #(longint unsigned N=4) {
reg my_reg_t {
field {} f;
};
N=my_reg_t.f->reset;
my_reg_t reg_array[N];
};
In this example, I'm trying to assign 'N' with the reset value of the field 'f'.
from systemrdl-compiler.
I realize I did not complete my example from before.
If you want to re-use a component with different parameterizations in RDL, you can do so by overriding the parameter during instantiation. Consider the addrmap top
from before - I can instantiate multiple variants of it, each using different values for N:
addrmap system_top {
top top1; // Uses default N=4
top #(.N(8)) top2; // Overrides N=8
};
Also, remember that parameters are constants and are resolved during compile-time. It would not make much sense for something like reg_array[N]
to change size at runtime since it describes hardware in FPGA or ASIC.
Lastly regarding this snippet:
N=my_reg_t.f->reset;
There are some obscure cases where you can reference an RDL property, but it is only to describe a structural connection in the hardware. Probably not what you were looking for :-)
from systemrdl-compiler.
Related Issues (20)
- regfile inside addrmap does not compile HOT 1
- Cannot alias registers with we = true HOT 2
- Add ability to inject define macros into preprocessor
- Empty addrmap causes compiler to crash HOT 4
- Software-writable field spanning multiple words should cause error message (accesswidth/regwidth problem) HOT 1
- User defined property default for array type causes exception HOT 2
- [BUG] Parameter internal cleanup after first elaboration HOT 1
- Add support for assigning references in importer API
- Unintended `external` applied to `addrmap` instance HOT 3
- missing parameterization in the component hierarchy HOT 13
- Add method to generate a globally scoped type name to Node API HOT 1
- if struct is not fully defined, compiler crashes, it should point the line with to the error in the SystemRDL file HOT 2
- detecting name collisions during path serialization HOT 1
- Allow Elaboration without addrmap HOT 1
- Set abbreviated Node.type_name for long parameterized types HOT 1
- [FEATURE] property_src_ref needed for UserEnum and UserEnumMember
- Describe how addressing is impacted by ispresent in docs HOT 2
- `define for value replacement does not work HOT 2
- Compatibility between UDP `default` property and `UDPDefinition.default_assignment` HOT 4
- [BUG] [QUESTION] - Importer API support for signals HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from systemrdl-compiler.