Giter Site home page Giter Site logo

Comments (3)

amykyta3 avatar amykyta3 commented on August 24, 2024

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.

markcohen32 avatar markcohen32 commented on August 24, 2024

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.

amykyta3 avatar amykyta3 commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.