I have an issue for a system-verilog project. I simulate using Questasim, but this is more a language-related question, I actually have not been able to find any answer in more than 2 weeks of studying.
I have a collection of many (~1000s) almost identical modules, repeated and connected one another. This module is parametrized with an ID. Inside the module, some actions are performed depending on the value of this ID and everything looks working as expected.
The reason why these modules are not exactly identical is that, depending on the ID, some signals to and from the modules swap. What I mean is that, in pseudo code, I would like to have something like:
module test #(
ID = 0
) (
...
if(ID == 0) input wire A
else if(ID == 1) output wire A
...
...
endmodule
does systemverilog support, in any way, something like this? I can work around this problem using a verilog generating script, but that is not so maintainable in my experience.
This is actually a semplification, I truly have ~10s of signal and they change from input to output in almost any possible way, therefore manual writing is hardly possible.
I know it may be possible to just work with inout and do everything inside, but at compile time I do know exactly what is an input and what is an output for every ID, therefore this solution does not look elegant at all to me.