Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20749 Discussions

Code Not Running (Adding Tightly Coupled Instruction & Data Memory)

Altera_Forum
Honored Contributor II
994 Views

Dear Friend's, 

 

I have added Tightly coupled instruction and data memory and then-after my Code won't run, there is no activity on eclipse console. 

 

Attached is my sopc and Code. 

 

kaushal
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
250 Views

From your bsp I see you are actually not using TCM in your project; everything is still in ddr2. So your code stopped working after you simply added TCM ports. 

At first glance I can't see any flaw in the design itself. 

Did you check if the extra resources requested from fpga caused gave rise to any timing problems?
0 Kudos
Altera_Forum
Honored Contributor II
250 Views

Hello There, 

 

There is no no extra resource request from FPGA. just figurung out how to use tightly coupled instruction and data memory to speed up the performance. 

 

So how do i put TCM in my project ?  

Is adding these two in sopc is not sufficient...? 

Do we need to add something in code too..? 

 

Regards 

 

kaushal
0 Kudos
Altera_Forum
Honored Contributor II
250 Views

 

--- Quote Start ---  

 

There is no no extra resource request from FPGA. j 

 

--- Quote End ---  

 

Adding TCM or simply adding the TC ports on Nios DOES require extra resources from FPGA, since the additional logic related to the TC controller has to be implemented. 

 

 

 

--- Quote Start ---  

 

So how do i put TCM in my project ?  

Is adding these two in sopc is not sufficient...? 

Do we need to add something in code too..? 

 

--- Quote End ---  

 

No. Adding those blocks in sopc is not enough. You also need to instruct the compiler to use them. 

You can either change the linker settings in bsp, or move single functions/variables into TCM with code directives. 

In the bsp linker settings you can move a whole code section into the desired memory: in your case you must change the setting from ddr2_bot to tcm. 

Code defaults to .text section, but it's generally unlikely it can all fit in TCM, which is very small compared to ddr2. So you'd need to add a new code memory section to be mapped to TCM and you place here only the time critical code. 

In case you only have a few well defined time critical functions, it's easier to map them singularly using the an attribute directive just after the function definition: 

For example: 

int tcm_function(int p) __attribute__ ((section (".tightly_coupled_code"))); 

would place tcm_function in the specified memory (replace "tightly_coupled_code" with the actual memory name you used in sopc) 

The same applies to data: either change the .rwdata mapping in linker settings or place the attribute directive after each variable you want to move to tcm.
0 Kudos
Altera_Forum
Honored Contributor II
250 Views

As I said before, it's very unlikely your code can wholly fit into onchip memory. Using stdio and other lib functions brings to big code size, even if you write a basic "Hello world" application. You should map into TCM only time critical functions and data.

0 Kudos
Reply