Quantcast
Channel: Altera Forums
Viewing all articles
Browse latest Browse all 19390

What's Wrong with This SV Code Involving Interfaces?

$
0
0
I'm trying to set initial conditions for registers in an array of interfaces. Doing it manually seems to work. In my project, this builds in Quartus without errors:
Code:

    initial begin
        ports[0].done = '1;
        ports[1].done = '1;
        ports[2].done = '1;
        ports[3].done = '1;
    end

However, changing that block of code to this causes the build to fail:

Code:

    initial begin
        for(int n=0; n<4; n++) begin
            ports[n].done = '1;
        end
    end

In the second case I get an error of 'can't resolve reference to object "ports"' as though the array doesn't exist. Am I making a dumb mistake or trying something that isn't possible? My eventual goal is to have a parameterized number of ports, but that requires being able to make assignments using loops.

Viewing all articles
Browse latest Browse all 19390

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>