1

context

I'm making a simulation environment with systemC co-simulated with verilog/VHDL RTL modules using modelsim/questasim

My Verilog modules use parameters to set up each module My VHDL modules use generics to set up each module My systemC modules can replicate this using templates if needed.

The following discussion is very alike except I can't use the sc_main because of Modelsim: Setting the vector length in SystemC with a received parameter

Question

I want to be able to instantiate a systemC module using a verilog parameter

Example

Here is a minimal (not-working) example :

Verilog file

module submodule
#(
    parameter parameter1 = 32
}
(
    input logic clk,
    /* signals (...) */
); 

systemc_module
#(
    .parameter_sc (parameter1 * 2) /* parameter can be modified */
)
systemc_module_0
(
    .clk(clk),
    /* signals (...) */
);

endmodule 

SystemC file

SC_MODULE(systemc_module)
{
    sc_in<sc_logic> clk;
    sc_signal<sc_lv<parameter_sc> > compilation_dynamic_signal;
    // other signals (...)

    SC_CTOR(systemc_module)
    {
        // I can get the parameter at execution time with modelsim :
        int buf;
        sc_get_param("parameter_sc", buf)
    }
}

/*Modelsim module export*/
SC_MODULE_EXPORT(systemc_module);
2
  • you forgot to ask a question. What is your problem exactly? Commented Aug 6, 2021 at 11:22
  • The question is "How to instantatiate systemC modules from Verilog/VHDL in Modelsim using parameters/generics used in the systemC ports?" Commented Aug 9, 2021 at 7:38

1 Answer 1

0

You cannot do this because your SystemC code gets compiled separately from your Verilog/VHDL code. The concept of generics/parameters is unique to VHDL/Verilog and and does not map directly to C++ templates. At the point where you compile your SystemC code, you do not know how many instances of the SC_MODULE there will be and what their parameter values might be.

The reason the example with sc_main works is because it gets compiled using the C++ compiler where the templatization of the SC_MODULE happens.

choosing appropriate specialized template at runtime

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.