Forum Discussion

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

Issue in component editor

Hi all.

I try to write a validation callback for a component I just wrote.

I get a weird TCL issue (that I don't get in a classical TCL script, I checked)

Here is my code:

--- Quote Start ---

...

set_module_property NAME pio

...

set_module_property VALIDATION_CALLBACK validate

...

add_parameter PORT_31_TRISTATE BOOLEAN false

set_parameter_property PORT_31_TRISTATE DEFAULT_VALUE false

set_parameter_property PORT_31_TRISTATE DISPLAY_NAME PORT_31_TRISTATE

set_parameter_property PORT_31_TRISTATE UNITS None

set_parameter_property PORT_31_TRISTATE DISPLAY_HINT ""

set_parameter_property PORT_31_TRISTATE AFFECTS_GENERATION false

set_parameter_property PORT_31_TRISTATE HDL_PARAMETER true

...

add_parameter PORT_31_INIT STRING TIE_DOWN

set_parameter_property PORT_31_INIT DEFAULT_VALUE TIE_DOWN

set_parameter_property PORT_31_INIT DISPLAY_NAME PORT_31_INIT

set_parameter_property PORT_31_INIT UNITS None

set_parameter_property PORT_31_INIT ALLOWED_RANGES {"TIE_UP" "TIE_DOWN" "HIGH_Z" "INPUT" "INPUT_n"}

set_parameter_property PORT_31_INIT DISPLAY_HINT radio

set_parameter_property PORT_31_INIT AFFECTS_GENERATION false

set_parameter_property PORT_31_INIT HDL_PARAMETER true

...

proc validate {} {

if {(![get_parameter_value PORT_31_TRISTATE]) && ([get_parameter_value PORT_31_INIT] == "HIGH_Z")} {

send_message error "PORT_31_INIT cannot be set to 'HIGH_Z' as PORT_31_TRISTATE has been set to false"

}[/INDENT]

}

...

--- Quote End ---

Then I get the following error message at SOPC Builder startup, when the code is sourced:

--- Quote Start ---

Error: pio_0: can't use non-numeric string as operand of "!"

("if" test expression)

invoked from within

"if {(![get_parameter_value PORT_31_TRISTATE]) && ([get_parameter_value PORT_31_INIT] == "HIGH_Z")} {

send_message error "PORT_31_INIT cannot be set ..."

(procedure "validate" line 2)

invoked from within

"validate"

--- Quote End ---

Can you tell me what is wrong???

Thx

7 Replies

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

    What is the issue you are seeing?

    Moving to the general nios forum section.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Oooops I totally forgot to quote the error message.

    I just edited my original post...

    So it seems to be a TCL syntax error but I can't get it...
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for the reply.

    Unfortunatly, there are no boolean parameters in the _hw.tcl you provided.

    Maybe you can find another one with actual boolean parameters?

    Thx a lot.

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

    If you search through the ip folder for .tcl files you might find one that uses HDL boolean parameters. I was lazy and just used a regular integer parameter in the HDL and then made it appear as a boolean (checkbox) in the GUI by setting the display hint to boolean. By using a display hint of boolean it can only get set to 0 or 1 so you might be able to do the same.

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

    I'll do that if I really can solve this issue, but it ****es me off as it's only tcl syntax! :D

    I looked in the IP folder and could not find any boolean parameter in any _hw.tcl file...
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    problem solved

    --- Quote Start ---

    proc validate {} {

    if {([get_parameter_value PORT_31_TRISTATE] == "false") && ([get_parameter_value PORT_31_INIT] == "HIGH_Z")} {

    send_message error "PORT_31_INIT cannot be set to 'HIGH_Z' as PORT_31_TRISTATE has been set to false"

    }[/INDENT]

    }

    --- Quote End ---

    I had tried that before but I forgot the double quotes around 'false'...