Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

ID for each module from the for generate

Hello guys,

I instantiate a bunch of the same module with a for generate statement.

I dont know how to store the hcu_id of the module( I need it in an another part of the system); with ID I mean the

variable i of the for generate. I would need something like a constant input equal to the i variable of the for generate.

Any ideas?? Thanks

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    not quite sure I get the problem? it would be easy to pass in the loop value into a signal of the instatiation inside the generate, giving each instance access to it's ID number.

    Why not post some code so we have a better idea of what you are trying to do.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Ok this is the top entity. I instantiate this module like this:

    g_upd_req_conn : FOR i IN 0 TO MAX_H_TILES - 1 GENERATE

    u_upd_req_conn : ENTITY work.upd_req_conn(beh)

    PORT MAP(

    rst_n => rst_n,

    clk => clk,

    ID => ???

    );

    END GENERATE g_upd_req_conn;

    I need to give an ID to each module equal to the variable i, like a constant input. Any ideas?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Ok this is the top entity. I instantiate this module like this:

    g_upd_req_conn : FOR i IN 0 TO MAX_H_TILES - 1 GENERATE

    u_upd_req_conn : ENTITY work.upd_req_conn(beh)

    PORT MAP(

    rst_n => rst_n,

    clk => clk,

    ID => ???

    );

    END GENERATE g_upd_req_conn;

    I need to give an ID to each module equal to the variable i, like a constant input. Any ideas?

    --- Quote End ---

    if ID is integer:

    
    g_upd_req_conn : FOR i IN 0 TO MAX_H_TILES - 1 GENERATE
            u_upd_req_conn : ENTITY work.upd_req_conn(beh)
                PORT MAP(
                    rst_n                    => rst_n,
                    clk                      => clk,
                    ID                      => i
                    );
        END GENERATE g_upd_req_conn;