Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
821 Views

Reuse values of Qsys generics in C++ app

Hi, 

 

when generating a Qsys system, a sopcinfo file is generated. This file can be used to created C/C++ headers containing a lot of macro definitions like base addresses, etc. What it is apparently missing are the values of generics. E.g. I would like to use the HPS user clock frequency in my C++ app without maintaining its value manually. I'm aware that the generic values are included in the sopcinfo file, so I could probably write a script to extract the desired values. But maybe there is an automatic way to do this already?
0 Kudos
4 Replies
Altera_Forum
Honored Contributor I
30 Views

Perhaps the "sopc-generate-header-files" is the utility that you are looking for? It is installed with SoC EDS.

Altera_Forum
Honored Contributor I
30 Views

I use this utility to generate headers. However, these headers do not include the values of generics. But I should check the parameters of the tool, maybe there is an option to include them.

Altera_Forum
Honored Contributor I
30 Views

Hm, no, I don't see a option to include the generics.

Altera_Forum
Honored Contributor I
30 Views

I think the only way to transmit those kind of parameters to the C/C++ app is through a custom component. Please note that this example is quite old, I'm still working on a design with Quartus 11 and SOPC builder, but I think it should still apply to QSys and HPS designs. 

All those lines need to be put in the component's *_hw.tcl file 

 

The component needs a custom elaboration callback 

set_module_property ELABORATION_CALLBACK elaboration_proc 

 

Create a generic parameter for the component that takes a clock frequency as value 

add_parameter CLOCK_FREQ Integer set_parameter_property CLOCK_FREQ SYSTEM_INFO { CLOCK_RATE clock } set_parameter_property CLOCK_FREQ VISIBLE False set_parameter_property CLOCK_FREQ AFFECTS_ELABORATION True set_parameter_property CLOCK_FREQ AFFECTS_GENERATION False 

 

For that property to work you need a clock input port with the "clock" name 

# +----------------------------------- # | connection point clock # | add_interface clock clock end set_interface_property clock clockRate 0 set_interface_property clock ENABLED true add_interface_port clock csi_sys_Clk clk Input 1 

 

And then in the elaboration procedure you can transmit the value to the software layer 

# custom elaboration procedure proc elaboration_proc { } { set_module_assignment embeddedsw.CMacro.CLOCK_FREQ }  

It's probably overkill if you don't already have a custom component with custom driver but it's the only way I know, other than parsing the sopcinfo file yourself.
Reply