Forum Discussion

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

Qsys: Component Editor Parameter Error

I am trying to create a custom component to be imported in qsys. However, it can't recognize certain parameter and localparam in my .v file.

Besides, it generates an error:

Width of port avs_csr_address is invalid: (non-static) - (0) +1 (must be an integer or parameter name)

What should i do with it? Or is there any better way to control a set of parameter?

I have uploaded the Test.v and new_component_hw.txt (it is tcl file actually).

Thanks

6 Replies

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

    The component interface isn't very smart and needs all port widths to be either a constant, a top level parameter or a simple expression with only integers and top level parameters. It probably isn't happy with your local parameters. I suggest to either put the whole expression (ex (SINGLE_ENTRY==1) ? 3 : CSR_ADDR_WITDH) in the port width, or use a top level parameter instead of LOCAL_CSR_ADDR_WITDH and put your logic with SINGLE_ENTRY in the tcl file instead.

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

    Hi Daixiwen,

    I got the same error while trying to create custom component with quartus version 13.1 in qsys which has parameter dependent address width.

    I tried two cases to generate component but in both the cases i got same error that is "Error: Width of port av_d_addr_word_i/av_c_addr_word_i is invalid + (non-static) - (0) + 1 (must be an integer or parameter name)"

    The tried case is in texts below.

    ******************************************************************************************************

    // for case_1

    // parameter for simulation purpose

    parameter SIMULATION = 1'b0;

    // parameter for specifying the memory depth in KBytes

    parameter MEMORY_DEPTH_IN_KBYTES = 16;

    // Local Parameter for memory depth in bytes.

    localparam MEM_DEPTH_8 = ( MEMORY_DEPTH_IN_KBYTES * 1024 );

    // Local Parameter for memory address width.(_8 prefix indicates this is for byte(8 bit)).

    localparam MEM_ADDR_WIDTH_8 = clogb2( MEM_DEPTH_8 );

    // Local Parameter for avalon slave component address width ( 32 bit aligned )

    localparam AV_ADDR_WIDTH = ( MEM_ADDR_WIDTH_8 - 2 );

    input [(AV_ADDR_WIDTH-1):0] av_d_addr_word_i;

    input [(AV_ADDR_WIDTH-1):0] av_c_addr_word_i;

    function integer clogb2;

    input integer depth;

    integer i;

    integer result;

    begin

    result = 0;

    for ( i = 0; 2 ** i < depth; i = i + 1 )

    begin

    result = i + 1;

    end

    clogb2 = result;

    end

    endfunction

    ******************************************************************************************************

    ******************************************************************************************************

    For case_2

    // parameter for simulation purpose

    parameter SIMULATION = 1'b0;

    // parameter for specifying the memory depth in KBytes

    parameter MEMORY_DEPTH_IN_KBYTES = 16;

    input [clogb2((MEMORY_DEPTH_IN_KBYTES * 1024)-2) -1 : 0] av_d_addr_word_i;

    input [clogb2((MEMORY_DEPTH_IN_KBYTES * 1024)-2) -1 : 0] av_c_addr_word_i;

    function integer clogb2;

    input integer depth;

    integer i;

    integer result;

    begin

    result = 0;

    for ( i = 0; 2 ** i < depth; i = i + 1 )

    begin

    result = i + 1;

    end

    clogb2 = result;

    end

    endfunction

    ******************************************************************************************************

    Is there any other way to do this!

    Will be looking forward to your reply.

    Regards,

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

    None of those will work. As I said before you can't use localparams, and it won't recognize your log2 function either. You need to have your width directly as a top level parameter, instead of the value in kilobytes.

    If you really want to be able to specify your memory size in kbytes in the GUI, you can apply the log2 function to convert it to a width in the hw_tcl script.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Daixiwen,

    Thanks for the reply.

    I am agree with you about local parameter declaration in top file but can't get your point of applying log2 function in tcl script file.

    In altera guideline they mentioned that complex functions such as log2 are not supported in tcl script after quartus version 12.0.

    Could you please give me any reference script file or document.

    Thanks & Regards,

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

    I wasn't aware of this limitation, but here we are still using Quartus II version 11.1... Where is this new limitation written?

    Anyway, it's easy to implement your own recursive function for log2 in TCL, just the way you made it in HDL.

    I don't have a direct example for you, but I have something from one of my components that required an operation the other way round. I had a component that used a stream input for which the channel signal size was adjustable. The size was specified as number of bits as a module parameter, but for SOPC Builder I also needed to get the correct value for the "maxChannel" property of the Avalon stream input, or SOPC builder would complain if it didn't match the one of the source.

    So at the module level in the TCL file I specified that I had a custom elaboration function:

    set_module_property ELABORATION_CALLBACK elaboration

    And my elaboration function was as such:

    # elaboration callback
    proc elaboration { } {
        set chanbits 
        set maxchans 
        
        set_interface_property packets_in maxChannel $maxchans
    }
    

    You can use a similar construction, with a log2 function in the "expr" line instead of pow, and set_parameter_value instead of set_interface_property