DSPRelated.com
Forums

C code that can auto-detect C67x vs. C62x

Started by Jeff Brower October 16, 2008
All-

Does anyone know where to find a bit of C code that can determine if the underlying
CPU is C6701 vs. C6201 (or C6711 vx. C6211)?

I want to build some code with 67x as the target in CCS, but calls fixed-point
routines if it's running on a 62x device.

Thanks.

-Jeff
Jeff,

On Thu, Oct 16, 2008 at 9:06 AM, Jeff Brower wrote:
> All-
>
> Does anyone know where to find a bit of C code that can determine if the
> underlying
> CPU is C6701 vs. C6201 (or C6711 vx. C6211)?


I don't have any C code, but it should be fairly easy. The key is the
device CSR bits 24-31.
CSR = 0xAABBCCCC
AA = 0x00 = 620x,621x
AA = 0x02 = 6701,671x
AA = 0x03 = 672x

mikedunn
>
> I want to build some code with 67x as the target in CCS, but calls
> fixed-point
> routines if it's running on a 62x device.
>
> Thanks.
>
> -Jeff

--
www.dsprelated.com/blogs-1/nf/Mike_Dunn.php
Jeff,

Per the TI knowledge base...

"Identifying whether the DSP is C6201 Integer DSP or a C6701 Floating Point DSP

Problem:
How can the user use software to check a DSP to identify if it is a C6201
interger DSP or a C6701 Floating Point DSP?

Solution:
The user can view the value of the CSR register to determine this. See bit
positions 31-24 that indicates the CPU ID. If CPU ID is equal to 00b it
indicates a C62x if the value is 10b - indicates a C67x. Please see detail on
page 2-18 of the TMS320C6000 CPU Instruction Set Referernce Guide (spru189F) for
more information.
"

R. Williams
---------- Original Message -----------
From: Jeff Brower
To: c...
Sent: Thu, 16 Oct 2008 09:06:22 -0500
Subject: [c6x] C code that can auto-detect C67x vs. C62x

> All-
>
> Does anyone know where to find a bit of C code that can determine if
> the underlying CPU is C6701 vs. C6201 (or C6711 vx. C6211)?
>
> I want to build some code with 67x as the target in CCS, but calls
> fixed-point routines if it's running on a 62x device.
>
> Thanks.
>
> -Jeff
------- End of Original Message -------
I think that if you look in the CSL, you will find that there is an internal register with a code that identifies the DSP, manufacturer...

> To: c...
> From: j...@signalogic.com
> Date: Thu, 16 Oct 2008 09:06:22 -0500
> Subject: [c6x] C code that can auto-detect C67x vs. C62x
>
> All-
>
> Does anyone know where to find a bit of C code that can determine if the underlying
> CPU is C6701 vs. C6201 (or C6711 vx. C6211)?
>
> I want to build some code with 67x as the target in CCS, but calls fixed-point
> routines if it's running on a 62x device.
>
> Thanks.
>
> -Jeff
>
>
>
Richard-

> Per the TI knowledge base...
>
> "Identifying whether the DSP is C6201 Integer DSP or a C6701 Floating Point DSP
>
> Problem:
> How can the user use software to check a DSP to identify if it is a C6201
> interger DSP or a C6701 Floating Point DSP?
>
> Solution:
> The user can view the value of the CSR register to determine this. See bit
> positions 31-24 that indicates the CPU ID. If CPU ID is equal to 00b it
> indicates a C62x if the value is 10b - indicates a C67x. Please see detail on
> page 2-18 of the TMS320C6000 CPU Instruction Set Referernce Guide (spru189F) for
> more information."

Thanks very much -- it's easy to read the CSR from C code, so I'm good.

-Jeff

> ---------- Original Message -----------
> From: Jeff Brower
> To: c...
> Sent: Thu, 16 Oct 2008 09:06:22 -0500
> Subject: [c6x] C code that can auto-detect C67x vs. C62x
>
> > All-
> >
> > Does anyone know where to find a bit of C code that can determine if
> > the underlying CPU is C6701 vs. C6201 (or C6711 vx. C6211)?
> >
> > I want to build some code with 67x as the target in CCS, but calls
> > fixed-point routines if it's running on a 62x device.
> >
> > Thanks.
> >
> > -Jeff
Mike-

> On Thu, Oct 16, 2008 at 9:06 AM, Jeff Brower wrote:
> > All-
> >
> > Does anyone know where to find a bit of C code that can determine if the
> > underlying
> > CPU is C6701 vs. C6201 (or C6711 vx. C6211)?
>
>
> I don't have any C code, but it should be fairly easy. The key is the
> device CSR bits 24-31.
> CSR = 0xAABBCCCC
> AA = 0x00 = 620x,621x
> AA = 0x02 = 6701,671x
> AA = 0x03 = 672x

Right -- you and Richard must have this in your brain banks. With you guys, who
needs Google. Thanks. Will try this ASAP.

-Jeff

> > I want to build some code with 67x as the target in CCS, but calls
> > fixed-point
> > routines if it's running on a 62x device.
> >
> > Thanks.
> >
> > -Jeff
Jeff,

My prior experience with the TI DSPs lead me to think that an appropriate
register would be available.

However, I found the specific answer via going to the TI.com web site and
searching. Took about 10 minutes to find the answer that I provided.

Nothing 'google' about it.
R. Williams

---------- Original Message -----------
From: Jeff Brower
To: Michael Dunn
Cc: c...
Sent: Thu, 16 Oct 2008 11:43:07 -0500
Subject: Re: [c6x] C code that can auto-detect C67x vs. C62x

> Mike-
>
> > On Thu, Oct 16, 2008 at 9:06 AM, Jeff Brower wrote:
> > > All-
> > >
> > > Does anyone know where to find a bit of C code that can determine if the
> > > underlying
> > > CPU is C6701 vs. C6201 (or C6711 vx. C6211)?
> >
> >
> > I don't have any C code, but it should be fairly easy. The key is the
> > device CSR bits 24-31.
> > CSR = 0xAABBCCCC
> > AA = 0x00 = 620x,621x
> > AA = 0x02 = 6701,671x
> > AA = 0x03 = 672x
>
> Right -- you and Richard must have this in your brain banks. With you
> guys, who needs Google. Thanks. Will try this ASAP.
>
> -Jeff
>
> > > I want to build some code with 67x as the target in CCS, but calls
> > > fixed-point
> > > routines if it's running on a 62x device.
> > >
> > > Thanks.
> > >
> > > -Jeff
------- End of Original Message -------
Hi Jeff,

> Does anyone know where to find a bit of C code that can determine if
> the underlying CPU is C6701 vs. C6201 (or C6711 vx. C6211)?
>
> I want to build some code with 67x as the target in CCS, but calls
> fixed-point routines if it's running on a 62x device.

Never thought anyone might be interested. To be on a safe side,
always compile it with -mv6200 (smallest possible architecture).

Rgds,
Andrew

/* ---------------- begin c6x_cpu_id.c ----------------------------*/

// ---------------------------------
// Copyright (C) 1997-2009 by Andrew Nesterov. All rights reserved.
// Author: Andrew Nesterov
//
// This work has been placed into public domain. Usual disclaimer
// should be applied as necessary. No warranties whatsoever.
// ---------------------------------

#include

/* ------------------------------ */
/* CPU Control Status Register */
/* if not defined internally in cl6x */
/* ------------------------------ */
extern cregister volatile unsigned int CSR;

/* ------------------------------ */
/* CPUID: bits [31..24] of CSR */
/* ------------------------------ */

#define CPU_C62x 0x00 // C62x CPU
#define CPU_C64x 0x0C // C64x CPU
#define CPU_C64P 0x10 // C64+ CPU
#define CPU_C67x 0x02 // C67x CPU
#define CPU_C67P 0x03 // C67+ CPU

/* ------------------------------ */
/* REVID: bits [23..16] of CSR */
/* ------------------------------ */

#define CPU_C6201 0x01 // C6201 C62x
#define CPU_C6211 0x02 // C6201B C6202 C6211 C62x
#define CPU_C6202 0x03 // C6202B C6203 C6204 C6205 C62x
#define CPU_C6701 0x01 // C6701 revision 0 (early CPU) C67x
#define CPU_C6711B 0x02 // C6701 C6711/11B C6712 C67x
#define CPU_C6711C 0x03 // C6711C/11D C6712C/12D C6713/13B C67x
#define CPU_C6411 0x01 // C64xx C64x

/* ------------------------------ */
/* function declaration */
/* ------------------------------ */
void c6x_cpu_id (int *cpuid, int *revid);

/* ------------------------------ */
/* function definition */
/* ------------------------------ */
void c6x_cpu_id (int *cpuid, int *revid)
{
unsigned int temp = CSR;
*cpuid = _extu (temp, 0x00, 0x18);
*revid = _extu (temp, 0x08, 0x18);
return;
}

/* ------------------------------ */
/* test routine */
/* ------------------------------ */

#define _TEST_ /* undef _TEST_ if not needed */
#ifdef _TEST_

unsigned char c62x_srt [] = "C62X CPU detected \n\r" ;
unsigned char c64x_srt [] = "C64X CPU detected \n\r" ;
unsigned char c64p_srt [] = "C64+ CPU detected \n\r" ;
unsigned char c67x_srt [] = "C67X CPU detected \n\r" ;
unsigned char c67p_srt [] = "C67+ CPU detected \n\r" ;

#include

int main (void)
{
int cpuid, revid;

c6x_cpu_id (&cpuid, &revid);

switch (cpuid) /* revid is processed elsewhere */
{
case CPU_C62x:
printf ("%s", c62x_srt);
break;
case CPU_C64x:
printf ("%s", c64x_srt);
break;
case CPU_C64P:
printf ("%s", c64p_srt);
break;
case CPU_C67x:
printf ("%s", c67x_srt);
break;
case CPU_C67P:
printf ("%s", c67p_srt);
break;
default:
;
}

return (cpuid);
}

#endif /*_TEST_*/

/* ---------------- end c6x_cpu_id.c ----------------------------*/
Richard - FYI,

On Thu, Oct 16, 2008 at 12:37 PM, Richard Williams
wrote:
> Jeff,
>
> My prior experience with the TI DSPs lead me to think that an appropriate
> register would be available.
>
> However, I found the specific answer via going to the TI.com web site and
> searching. Took about 10 minutes to find the answer that I provided.
>
> Nothing 'google' about it.

FYI.
Some of us who have wrestled with TI's 'searchability issues' over the
years have found that sometimes the '10 minutes to find an answer' is
reduced to 5 when you use google [since it finds stuff at ti.com].

BTW - TI's site search features are much better than they used to be -
its just that old habits die hard.

mikedunn
> R. Williams
>
> ---------- Original Message -----------
> From: Jeff Brower
> To: Michael Dunn
> Cc: c...
> Sent: Thu, 16 Oct 2008 11:43:07 -0500
> Subject: Re: [c6x] C code that can auto-detect C67x vs. C62x
>
>> Mike-
>>
>> > On Thu, Oct 16, 2008 at 9:06 AM, Jeff Brower wrote:
>> > > All-
>> > >
>> > > Does anyone know where to find a bit of C code that can determine if the
>> > > underlying
>> > > CPU is C6701 vs. C6201 (or C6711 vx. C6211)?
>> >
>> >
>> > I don't have any C code, but it should be fairly easy. The key is the
>> > device CSR bits 24-31.
>> > CSR = 0xAABBCCCC
>> > AA = 0x00 = 620x,621x
>> > AA = 0x02 = 6701,671x
>> > AA = 0x03 = 672x
>>
>> Right -- you and Richard must have this in your brain banks. With you
>> guys, who needs Google. Thanks. Will try this ASAP.
>>
>> -Jeff
>>
>> > > I want to build some code with 67x as the target in CCS, but calls
>> > > fixed-point
>> > > routines if it's running on a 62x device.
>> > >
>> > > Thanks.
>> > >
>> > > -Jeff
> ------- End of Original Message -------

--
www.dsprelated.com/blogs-1/nf/Mike_Dunn.php
Andrew-

> > Does anyone know where to find a bit of C code that can determine if
> > the underlying CPU is C6701 vs. C6201 (or C6711 vx. C6211)?
> >
> > I want to build some code with 67x as the target in CCS, but calls
> > fixed-point routines if it's running on a 62x device.
>
> Never thought anyone might be interested.

Thanks for the code! Good stuff as usual by Nesterov Code Factory.

> To be on a safe side,
> always compile it with -mv6200 (smallest possible architecture).

Well, I want to build it with -mv6700, use floating-point if that's actually the
processor type, but if not then call some fixed-point "replacement" C code in certain
cases. It's an unusual situation where I need to have just one executable.

-Jeff

> /* ---------------- begin c6x_cpu_id.c ----------------------------*/
>
> // ---------------------------------
> // Copyright (C) 1997-2009 by Andrew Nesterov. All rights reserved.
> // Author: Andrew Nesterov
> //
> // This work has been placed into public domain. Usual disclaimer
> // should be applied as necessary. No warranties whatsoever.
> // ---------------------------------
>
> #include /* ------------------------------ */
> /* CPU Control Status Register */
> /* if not defined internally in cl6x */
> /* ------------------------------ */
> extern cregister volatile unsigned int CSR;
>
> /* ------------------------------ */
> /* CPUID: bits [31..24] of CSR */
> /* ------------------------------ */
>
> #define CPU_C62x 0x00 // C62x CPU
> #define CPU_C64x 0x0C // C64x CPU
> #define CPU_C64P 0x10 // C64+ CPU
> #define CPU_C67x 0x02 // C67x CPU
> #define CPU_C67P 0x03 // C67+ CPU
>
> /* ------------------------------ */
> /* REVID: bits [23..16] of CSR */
> /* ------------------------------ */
>
> #define CPU_C6201 0x01 // C6201 C62x
> #define CPU_C6211 0x02 // C6201B C6202 C6211 C62x
> #define CPU_C6202 0x03 // C6202B C6203 C6204 C6205 C62x
> #define CPU_C6701 0x01 // C6701 revision 0 (early CPU) C67x
> #define CPU_C6711B 0x02 // C6701 C6711/11B C6712 C67x
> #define CPU_C6711C 0x03 // C6711C/11D C6712C/12D C6713/13B C67x
> #define CPU_C6411 0x01 // C64xx C64x
>
> /* ------------------------------ */
> /* function declaration */
> /* ------------------------------ */
> void c6x_cpu_id (int *cpuid, int *revid);
>
> /* ------------------------------ */
> /* function definition */
> /* ------------------------------ */
> void c6x_cpu_id (int *cpuid, int *revid)
> {
> unsigned int temp = CSR;
> *cpuid = _extu (temp, 0x00, 0x18);
> *revid = _extu (temp, 0x08, 0x18);
> return;
> }
>
> /* ------------------------------ */
> /* test routine */
> /* ------------------------------ */
>
> #define _TEST_ /* undef _TEST_ if not needed */
> #ifdef _TEST_
>
> unsigned char c62x_srt [] = "C62X CPU detected \n\r" ;
> unsigned char c64x_srt [] = "C64X CPU detected \n\r" ;
> unsigned char c64p_srt [] = "C64+ CPU detected \n\r" ;
> unsigned char c67x_srt [] = "C67X CPU detected \n\r" ;
> unsigned char c67p_srt [] = "C67+ CPU detected \n\r" ;
>
> #include int main (void)
> {
> int cpuid, revid;
>
> c6x_cpu_id (&cpuid, &revid);
>
> switch (cpuid) /* revid is processed elsewhere */
> {
> case CPU_C62x:
> printf ("%s", c62x_srt);
> break;
> case CPU_C64x:
> printf ("%s", c64x_srt);
> break;
> case CPU_C64P:
> printf ("%s", c64p_srt);
> break;
> case CPU_C67x:
> printf ("%s", c67x_srt);
> break;
> case CPU_C67P:
> printf ("%s", c67p_srt);
> break;
> default:
> ;
> }
>
> return (cpuid);
> }
>
> #endif /*_TEST_*/
>
> /* ---------------- end c6x_cpu_id.c ----------------------------*/