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

multiprocessors and CPUID registers

Altera_Forum
Honored Contributor II
1,235 Views

Hi all, 

 

I noticed that with NiosII 1.1 Altera added ctl5, a register that basically contains a unique id for each cpu in a SOPCBuilder project. 

 

We created a multiprocessor 2-cpu design using SOPCbuilder, and we noticed that the cpuids are 0 and 1. 

 

Questions: 

- are the cpu numbers always starting from 0, then 1, 2, 3, 4, ...? that is, cpu1 in SOPCBuilder corresponds to cpuid 0, cpu2 correspond to cpuid 1, and so on? 

 

- is there a way to set a custom CPUID? 

Best Regards, 

 

Paolo
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
309 Views

I was told not to count on those following a 0, 1, 2, etc... order. Right now I think that just happens to be the case. As far as I can see there is no need to manually set those. Do you have something in mind?

0 Kudos
Altera_Forum
Honored Contributor II
309 Views

 

--- Quote Start ---  

originally posted by badomen@Feb 1 2005, 11:18 AM 

i was told not to count on those following a 0, 1, 2, etc... order.  right now i think that just happens to be the case.  as far as i can see there is no need to manually set those.  do you have something in mind? 

--- Quote End ---  

 

 

Well... IMHO there is at least a need to know on what CPU your code is executing... if I can set the values or I can assume some values (0,1,... would just be fine), then I can use them in multiprocessor code ... 

 

bye 

 

PJ
0 Kudos
Altera_Forum
Honored Contributor II
309 Views

When you create your software, you have your system library target a specific CPU. So lets say we have 3 cores called "cpu_0", "cpu_1", "cpu_2", then when you download your code for lets say "cpu_1" the ID that gets coded with that application will target only cpu_1. I used to manually tell the IDE to send code to a specific ID like what you are attempting, then I just removed that and found out it does all that work for you (that's one of the main reasons why the system library has you specify which CPU you are targeting in the dropdown box below the ptf selection). Also it's better to let the IDE do this work for you, because some day those IDs may not follow the order of 0, 1, 2, etc...... then managing the IDs will be very difficult. 

 

Does that answer your question? 

 

Cheers, 

BadOmen
0 Kudos
Altera_Forum
Honored Contributor II
309 Views

Yes,I think you can manage cpuid by yourself if you really want. 

The method is using niosII custom instruction.The Custom instruction is just implemented with reading or writing a register ,32bit or 16 bit or .... 

Ra is used as write or read signal, Rb is used as write data,result is the read data(cpuid) . 

I have made it,and test it. It work fine. 

I implement a four cpu design,and each cpu is assign a unique id when it reset(after all,they have different reset address).
0 Kudos
Altera_Forum
Honored Contributor II
309 Views

Ok... 

 

Currently I have no problems in programming and debugging a multicore application. 

I know that I can make a custom instruction to implement "my" CPUID. 

 

However I think that users should take advantage of the CPUID numbers in their applications. Users should at least rely on some numbering scheme for the CPUs... 

 

Suppose that you want to implement a shared data structure, let's say an array with one integer for each CPU... What is probably useful is to use the CPUID value as an index in that array! 

 

but if CPUID soon or later instead of 0,1,2,... become 165, 57, 32, 16523417, they are not so much useful from a programming point of view, and users will have to implement their own ways (e.g., private data values, macros, or custom instructions)... 

 

bye 

 

PJ
0 Kudos
Altera_Forum
Honored Contributor II
309 Views

PJ 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

but if CPUID soon or later instead of 0,1,2,... become 165, 57, 32, 16523417, they are not so much useful from a programming point of view, and users will have to implement their own ways (e.g., private data values, macros, or custom instructions)...[/b] 

--- Quote End ---  

 

 

system.h contains two# defines: 

 

NIOS2_CPU_ID_VALUE NIOS2_CPU_ID_SIZE 

 

The first one can be used in source code where you&#39;d expect to see 0, 1, or 2, etc. 

 

The second one is more useful for hardware. It gives the number of bits needed to represent the largest cpuid. 

 

Can these help? 

 

(BTW, I&#39;ll ask around why the cpuids would change from 0, 1, 2, etc. Currently SOPC Builder just assigns them to the enabled Nios II cpus in GUI order from top to bottom, starting with 0.) 

 

Kerry 

Altera
0 Kudos
Reply