Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Issue in component editor

Altera_Forum
Honored Contributor II
1,618 Views

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
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
449 Views

What is the issue you are seeing? 

 

Moving to the general nios forum section.
0 Kudos
Altera_Forum
Honored Contributor II
449 Views

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...
0 Kudos
Altera_Forum
Honored Contributor II
449 Views

Try comparing it to be equal to 0 instead of inverting it. If you look at the read or write masters in this design you'll see some boolean comparisons in the validation callback similar to what you are doing: http://www.altera.com/support/examples/nios2/exm-modular-scatter-gather-dma.html 

 

There might be cleaner ways to code it..... I wouldn't know since I only know enough .tcl to get my job done :)
0 Kudos
Altera_Forum
Honored Contributor II
449 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
449 Views

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.

0 Kudos
Altera_Forum
Honored Contributor II
449 Views

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...
0 Kudos
Altera_Forum
Honored Contributor II
449 Views

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'...
0 Kudos
Reply