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++
12745 Discussions

Setting a custom component class name

Altera_Forum
Honored Contributor II
1,249 Views

Hi everyone! 

 

I have an SOPC system with some custom components. It was working fine while I was writing some testing software running under uCOS/II, but now when trying to use them under Ecos I'm facing a problem with the automatic generation tools. I don't think the problem is (only) Ecos-related, so I prefer to post my message here. 

 

The problem is that I can't set the class names of my components. If I go in the .ptf file generated by SOPC builder after the system generation, I find for each of my components the following lines: 

 

class = "no_legacy_module"; class_version = "7.080900"; gtf_class_name = "my_component_name"; gtf_class_version = "0.1"; 

 

My component name in the gtf_class_name is the correct one, but I always get the class = "no_legacy_module" line on each of my custom components. Then when I build the Ecos OS for my board, the gtf-generate script picks up the wrong class name and inserts this line in devices.h to instantiate the driver: 

 

NO_LEGACY_MODULE_INSTANCE(MY_COMPONENT_NAME, my_component_name) 

which makes it rather messy, especially if I have several components in the same system. 

 

I've tried all kind of magic in the *_hw.tcl file to set the class name, including the undocumented "className" parameter that I found in some of Altera's components, but nothing seems to work. In fact the rare Altera components that don't have a class.ptf file have the same problem. Here is the line generated for the Cyclone III remote update component: 

 

NO_LEGACY_MODULE_INSTANCE(REMOTE_UPDATE_CYCLONEIII, remote_update_cycloneiii) 

 

What's the difference between "class" and "gtf_class_name"? Where does this "no_legacy_module" come from? 

 

And what do you think I should do? 

 

1) trash my *_hw.tcl file and use a good old class.ptf for my component, as Altera is still doing on most of their IPs 

2) use a secret undocumented parameter in the tcl file to change the class name 

3) modify the template called by gtf-generate to use the gtf_class_name, when available 

 

For solution 1, I can't find any documentation bout the class.ptf format. From what I've seen, it has slightly different parameters that the system ptf generated by sopc builder. Is there a kind of *_hw.tcl -> class.ptf converter around? 

 

For solution 3 the template is Ecos specific I think. The difficulty is that some components don't have a gtf_class_name and in that case the name in class should be used instead. Can that be done? 

 

I'd appreciate any input or ideas on the subject. Thanks!
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
551 Views

I eventually compared the templates that generate those files for the ecos and uC OS chains, and found out how to correct this, using solution 3. If someone is interested, you need to correct the nios2ecos/packages/hal/nios2/arch/current/gtf/devices.h.gtf, look for the following lines, and add the lines in red: 

<for_each variable="MODULE" ptf_path="SYSTEM/MODULE"> <if true="and( ptf_module_is_mastered_by( %MODULE%, %CPU% ), !=( %MODULE%, %CPU% ) )"> <set_variable variable="MODULE_CLASS" ptf_path="SYSTEM/MODULE %MODULE%/class"/> <if condition="eq( %MODULE_CLASS%, no_legacy_module )"> <set_variable variable="MODULE_CLASS" ptf_path="SYSTEM/MODULE %MODULE%/gtf_class_name"/> </if> <!-- did we already add it to ECOS_COMPONENT_LIST? (we don't want duplicate defines) --> 

 

It looks like a ugly hack, but it is what Altera is doing in the uC OS BSP anyway, so I guess it's ok ;) 

I still don't know why there can be two different parameters for the component class name, though.
0 Kudos
Altera_Forum
Honored Contributor II
551 Views

While working on the http://www.nioswiki.com/exampledesigns/fifoed_avalon_uart project I ran into this problem. 

 

If I can make it work then I would like to update nios2ecos.  

 

As a maintainer of nios2ecos, is there any reason why I shouldn't include the workaround you outlined? 

 

Øyvind Harboe 

http://www.zylin.com
0 Kudos
Altera_Forum
Honored Contributor II
551 Views

Since I made the change, I haven't seen any side effects, so I think that you can include the change in the repository. 

I had to do the modification in several places though, here is a patch that should do all the necessary changes:Index: devices.h.gtf =================================================================== --- devices.h.gtf (revision 245) +++ devices.h.gtf (working copy) @@ -91,21 +91,28 @@ <if true="and( ptf_module_is_mastered_by( %MODULE%, %CPU% ), !=( %MODULE%, %CPU% ) )"> <set_variable variable="MODULE_CLASS" ptf_path="SYSTEM/MODULE %MODULE%/class"/> + <if condition="eq( %MODULE_CLASS%, no_legacy_module )"> + <set_variable variable="MODULE_CLASS" + ptf_path="SYSTEM/MODULE %MODULE%/gtf_class_name"/> + </if> <!-- did we already add it to ECOS_COMPONENT_LIST? (we don't want duplicate defines) --> <if true="lt list_index_of( %ECOS_COMPONENT_LIST%, %MODULE_CLASS% ), 0 )"> <set_variable variable="ECOS_COMPONENT_LIST" to="list_add( %ECOS_COMPONENT_LIST%, %MODULE_CLASS% )"/> <set_variable variable="MODULE_CLASS" ptf_path="SYSTEM/MODULE %MODULE%/class"/> + <if condition="eq( %MODULE_CLASS%, no_legacy_module )"> + <set_variable variable="MODULE_CLASS" + ptf_path="SYSTEM/MODULE %MODULE%/gtf_class_name"/> + </if> <set_variable variable="MODULE_CLASS_UPPER" to="uppercase( %MODULE_CLASS% )"/> <text>#ifndef %MODULE_CLASS_UPPER%_INSTANCE # define %MODULE_CLASS_UPPER%_INSTANCE(dev, inst) # endif - -</text> + </text> </if> - </if> + </if> </for_each> <text> @@ -120,6 +127,10 @@ <if true="and( ptf_module_is_mastered_by( %MODULE%, %CPU% ), !=( %MODULE%, %CPU% ) )"> <set_variable variable="MODULE_CLASS" ptf_path="SYSTEM/MODULE %MODULE%/class"/> + <if condition="eq( %MODULE_CLASS%, no_legacy_module )"> + <set_variable variable="MODULE_CLASS" + ptf_path="SYSTEM/MODULE %MODULE%/gtf_class_name"/> + </if> <set_variable variable="MODULE_CLASS_UPPER" to="uppercase( %MODULE_CLASS% )"/> <set_variable variable="MODULE_UPPER" @@ -145,12 +156,20 @@ <if true="and( ptf_module_is_mastered_by( %MODULE%, %CPU% ), !=( %MODULE%, %CPU% ) )"> <set_variable variable="MODULE_CLASS" ptf_path="SYSTEM/MODULE %MODULE%/class"/> + <if condition="eq( %MODULE_CLASS%, no_legacy_module )"> + <set_variable variable="MODULE_CLASS" + ptf_path="SYSTEM/MODULE %MODULE%/gtf_class_name"/> + </if> <!-- did we already add it to ECOS_COMPONENT_LIST? (we don't want duplicate defines) --> <if true="lt( list_index_of( %ECOS_COMPONENT_LIST%, %MODULE_CLASS% ), 0 )"> <set_variable variable="ECOS_COMPONENT_LIST" to="list_add( %ECOS_COMPONENT_LIST%, %MODULE_CLASS% )"/> <set_variable variable="MODULE_CLASS" ptf_path="SYSTEM/MODULE %MODULE%/class"/> + <if condition="eq( %MODULE_CLASS%, no_legacy_module )"> + <set_variable variable="MODULE_CLASS" + ptf_path="SYSTEM/MODULE %MODULE%/gtf_class_name"/> + </if> <set_variable variable="MODULE_CLASS_UPPER" to="uppercase( %MODULE_CLASS% )"/> <text>#undef %MODULE_CLASS_UPPER%_INSTANCE
0 Kudos
Altera_Forum
Honored Contributor II
551 Views

I'm getting running into a similar problem when running SOPC via command line. I have some custom modules in my SOPC system. SOPC generation works perfectly fine when I run it via GUI. However, when I run it via command line by doing: 

sopc_builder tiger.ptf --generate=1 

I get the following errors: 

Error: tigers_jtag_uart: Component no_legacy_module 7.80912 not found Error: tigers_jtag_uart_1: Component no_legacy_module 7.80912 not found Error: data_cache_0: Component no_legacy_module 7.80912 not found Error: tiger_top_0: Component no_legacy_module 7.80912 not found Error: top_0: Component no_legacy_module 7.80912 not found Error: data_cache_0.dataMaster/sdram.s1: Illegal connection start (data_cache_0.dataMaster is an end interface) Error: tiger_top_0.instructionMaster/sdram.s1: Illegal connection start (tiger_top_0.instructionMaster is an end interface) Error: data_cache_0.AccelMaster/sdram.s1: Illegal connection start (data_cache_0.AccelMaster is an end interface) Error: data_cache_0.dataMaster/tigers_jtag_uart.controlSlave: Illegal connection start (data_cache_0.dataMaster is an end interface) Error: data_cache_0.dataMaster/tigers_jtag_uart_1.controlSlave: Illegal connection start (data_cache_0.dataMaster is an end interface) Error: data_cache_0.dataMaster/onchip_mem.s1: Illegal connection start (data_cache_0.dataMaster is an end interface) Error: tiger_top_0.instructionMaster/onchip_mem.s1: Illegal connection start (tiger_top_0.instructionMaster is an end interface) Error: data_cache_0.AccelMaster/onchip_mem.s1: Illegal connection start (data_cache_0.AccelMaster is an end interface) Error: data_cache_0.dataMaster/uart_0.s1: Illegal connection start (data_cache_0.dataMaster is an end interface) Error: data_cache_0.dataMaster/performance_counter_0.control_slave: Illegal connection start (data_cache_0.dataMaster is an end interface) Error: tiger_top_0.dCacheADDR/data_cache_0.dCacheADDR: Illegal connection start (tiger_top_0.dCacheADDR is an end interface) Error: top_0.SIZE/data_cache_0.accelSIZE: Illegal connection start (top_0.SIZE is an end interface) Error: top_0.DATA/data_cache_0.accelDATA: Illegal connection start (top_0.DATA is an end interface) Error: top_0.ADDR/data_cache_0.accelADDR: Illegal connection start (top_0.ADDR is an end interface) Error: tiger_top_0.dCacheCtrlTx/data_cache_0.dCacheCtrlRx: Illegal connection start (tiger_top_0.dCacheCtrlTx is an end interface) Error: tiger_top_0.dCacheDATA/data_cache_0.dCacheDATA: Illegal connection start (tiger_top_0.dCacheDATA is an end interface) Error: data_cache_0.dataMaster/tiger_top_0.debugSlave: Illegal connection start (data_cache_0.dataMaster is an end interface) Error: data_cache_0.dCacheCtrlTx/tiger_top_0.dCacheCtrlRx: Illegal connection start (data_cache_0.dCacheCtrlTx is an end interface) Error: data_cache_0.dataMaster/top_0.s1: Illegal connection start (data_cache_0.dataMaster is an end interface) Error: Generation skipped because the system has validation errors. 

 

I checked tiger.ptf and its assigning the below to all of my custom components 

class = "no_legacy_module"; class_version = "7.080912"; 

 

Any idea how to get around this? It's very strange that it works fine when using the GUI.  

Any help would be appreciated!!
0 Kudos
Reply