DSPRelated.com
Forums

Access to multiprocessing memory of adsp-21160

Started by Nikolay Berbatov March 20, 2001
Hi,

can anybody tell me, how can I access the multiprocessor memory of other
DSPs from the Host DSP (ADSP-21160). Can you give me a short C source code
of that. I
want to transfer a buffer to the multiprocessor memory (without link port)
and than to receive it back.

Thanks in advance!

Nikolay Berbatov



On Tue, 20 Mar 2001 08:43:05 +0100, Nikolay Berbatov wrote:

> can anybody tell me, how can I access the multiprocessor memory of other
> DSPs from the Host DSP (ADSP-21160). Can you give me a short C source code
> of that. I
> want to transfer a buffer to the multiprocessor memory (without link port)
> and than to receive it back.

Don't know about the 21160, but with the 21065L, multiprocessor memory
shows up at low addresses, with each other SHARC showing up at a fixed
multiple of its CPU ID. IIRC, it's 0x100 times the CPU ID to see the
registers for another CPU.

To access absolute addresses in C, use something like this:

#define my_register (* (unsigned*) 0x100)

unsigned foo()
{
my_register = 0x1234;
return my_register;
}



The ADSP-21160 is much the same as the ADSP-21065L in that it has a
multiprocessing memory space. Each processor resides in a different addressing
range within this memory space, determined by the processor's ID
(selected by hardwiring ID pins on the processor).
Information on this can be found on page 5-17 of the ADSP-21160 hardware
reference manual. It is also possible to map areas of interprocessor memory in
the projects LDF file (assuming you are using VisualDSP++),
which would allow one to define the multiproccessing memory maps once and not
again.

Regards,
Clifford

Kenneth Porter wrote:

> On Tue, 20 Mar 2001 08:43:05 +0100, Nikolay Berbatov wrote:
>
> > can anybody tell me, how can I access the multiprocessor memory of other
> > DSPs from the Host DSP (ADSP-21160). Can you give me a short C source code
> > of that. I
> > want to transfer a buffer to the multiprocessor memory (without link port)
> > and than to receive it back.
>
> Don't know about the 21160, but with the 21065L, multiprocessor memory
> shows up at low addresses, with each other SHARC showing up at a fixed
> multiple of its CPU ID. IIRC, it's 0x100 times the CPU ID to see the
> registers for another CPU.
>
> To access absolute addresses in C, use something like this:
>
> #define my_register (* (unsigned*) 0x100)
>
> unsigned foo()
> {
> my_register = 0x1234;
> return my_register;
> }
>
> _____________________________________
> Note: If you do a simple "reply" with your email client, only the author of
this message will receive your answer. You need to do a "reply all" if you want
your answer to be distributed to the entire group.
>
> _____________________________________
> About this discussion group:
>
> To Join: Send an email to
>
> To Post: Send an email to
>
> To Leave: Send an email to
>
> Archives: http://groups.yahoo.com/group/adsp
>
> Other Groups: http://www.dsprelated.com/groups.php3 > ">http://docs.yahoo.com/info/terms/


VCard
Clifford van Dyk <>

Development Engineer
Peralex Electronic Development

Peralex House
5 Dreyersdal Road
Bergvliet
Cape Town
Western Cape
7945
South Africa
Fax: +27-21-7123879
Home: +27-21-7152716
Work: +27-21-7120203

Thank you Clifford,

I'm using VisualDSP++ 1.0 and I know that I can map multiprocessing memory
in LDF file, but I have a problem to declare for exmple a data buffer in the
maped memory. I write the following:

#define SIZE 1024
int data_buf[SIZE] __attribute__((segment=seg_mp));

and this didn't work. The compiler dave me an error in __attribute__((.....

Where is the problem?

Regards,
Nikolay

----- Original Message -----
From: "Clifford van Dyk" <>
To: "Kenneth Porter" <>
Cc: <>
Sent: Thursday, March 22, 2001 7:44 AM
Subject: Re: [adsp] Access to multiprocessing memory of adsp-21160 > The ADSP-21160 is much the same as the ADSP-21065L in that it has a
multiprocessing memory space. Each processor resides in a different
addressing range within this memory space, determined by the processor's ID
> (selected by hardwiring ID pins on the processor).
> Information on this can be found on page 5-17 of the ADSP-21160 hardware
reference manual. It is also possible to map areas of interprocessor memory
in the projects LDF file (assuming you are using VisualDSP++),
> which would allow one to define the multiproccessing memory maps once and
not again.
>
> Regards,
> Clifford
>
> Kenneth Porter wrote:
>
> > On Tue, 20 Mar 2001 08:43:05 +0100, Nikolay Berbatov wrote:
> >
> > > can anybody tell me, how can I access the multiprocessor memory of
other
> > > DSPs from the Host DSP (ADSP-21160). Can you give me a short C source
code
> > > of that. I
> > > want to transfer a buffer to the multiprocessor memory (without link
port)
> > > and than to receive it back.
> >
> > Don't know about the 21160, but with the 21065L, multiprocessor memory
> > shows up at low addresses, with each other SHARC showing up at a fixed
> > multiple of its CPU ID. IIRC, it's 0x100 times the CPU ID to see the
> > registers for another CPU.
> >
> > To access absolute addresses in C, use something like this:
> >
> > #define my_register (* (unsigned*) 0x100)
> >
> > unsigned foo()
> > {
> > my_register = 0x1234;
> > return my_register;
> > }
> >
> > _____________________________________
> > Note: If you do a simple "reply" with your email client, only the author
of this message will receive your answer. You need to do a "reply all" if
you want your answer to be distributed to the entire group.
> >
> > _____________________________________
> > About this discussion group:
> >
> > To Join: Send an email to
> >
> > To Post: Send an email to
> >
> > To Leave: Send an email to
> >
> > Archives: http://groups.yahoo.com/group/adsp
> >
> > Other Groups: http://www.dsprelated.com/groups.php3
> >
> >
> > ">http://docs.yahoo.com/info/terms/
>
> _____________________________________
> Note: If you do a simple "reply" with your email client, only the author
of this message will receive your answer. You need to do a "reply all" if
you want your answer to be distributed to the entire group.
>
> _____________________________________
> About this discussion group:
>
> To Join: Send an email to
>
> To Post: Send an email to
>
> To Leave: Send an email to
>
> Archives: http://groups.yahoo.com/group/adsp
>
> Other Groups: http://www.dsprelated.com/groups.php3 > ">http://docs.yahoo.com/info/terms/



I send you my LDF file. Please, look at it! ARCHITECTURE(ADSP-21160)

//
// ADSP-21160 Memory Map:
// ------------
// Internal memory 0x0000 0000 to 0x000f ffff
// ------------
// 0x0000 0000 to 0x0000 0?ff IOP Regs
// 0x0000 0?00 to 0x0001 ffff (reserved)
// Block 0 0x0002 0000 to 0x0002 7fff Long Word (64) Addresses
// Block 1 0x0002 8000 to 0x0002 ffff Long Word (64) Addresses
// 0x0003 0000 to 0x0003 ffff (reserved)
// Block 0 0x0004 0000 to 0x0004 ffff Normal Word (32/48)
Addresses
// Block 1 0x0005 0000 to 0x0005 ffff Normal Word (32/48)
Addresses
// 0x0006 0000 to 0x0007 ffff (reserved)
// Block 0 0x0008 0000 to 0x0009 ffff Short Word (16) Addresses
// Block 1 0x000a 0000 to 0x000b ffff Short Word (16) Addresses
// 0x000c 0000 to 0x000f ffff (reserved)
// ------------
// Multiproc memory 0x0010 0000 to 0x007f ffff
// ------------
// 0x0010 0000 to 0x001f ffff Hammerhead ID1 Internal
memory
// 0x0020 0000 to 0x002f ffff Hammerhead ID0 Internal
memory
// 0x0030 0000 to 0x003f ffff Hammerhead ID1 Internal
memory
// 0x0040 0000 to 0x004f ffff Hammerhead ID0 Internal
memory
// 0x0050 0000 to 0x005f ffff Hammerhead ID1 Internal
memory
// 0x0060 0000 to 0x006f ffff Hammerhead ID0 Internal
memory
// 0x0070 0000 to 0x007f ffff Hammerhead ID=all Internal
memory
// ------------
// External memory 0x0080 0000 to 0xffff ffff
// ------------
//
// This architecture file allocates:
// Internal 256 words of run-time header in memory block 0
// 256 words of initialization code in memory block 0
// 38K words of C code space in memory block 0
// 6K words of C PM data space in memory block 0
// 32K words of C DM data space in memory block 1
// 8K words of C heap space in memory block 1
// 8K words of C stack space in memory block 1

SEARCH_DIR( $ADI_DSP\211xx\lib )

// The lib160.dlb must come before libchh.dlb because libchh.dlb has some
21020
// specific code and data
$LIBRARIES = lib160.dlb, libc160.dlb, libio160_32.dlb, libdsp160.dlb; // Libraries from the command line are included in COMMAND_LINE_OBJECTS.
$OBJECTS = 160_hdr.doj, $COMMAND_LINE_OBJECTS;

MEMORY
{
seg_rth { TYPE(PM RAM) START(0x00040000) END(0x000400ff) WIDTH(48) }
seg_init { TYPE(PM RAM) START(0x00040100) END(0x000401ff) WIDTH(48) }
seg_pmco { TYPE(PM RAM) START(0x00040200) END(0x00047fff) WIDTH(48) }
seg_pm40 { TYPE(PM RAM) START(0x00048000) END(0x00049aa9) WIDTH(40) }

seg_pmda { TYPE(DM RAM) START(0x0004e800) END(0x0004ffff) WIDTH(32) }

seg_dmda { TYPE(DM RAM) START(0x00050000) END(0x00057fff) WIDTH(32) }

seg_heap { TYPE(DM RAM) START(0x0005c000) END(0x0005dfff) WIDTH(32) }
seg_stak { TYPE(DM RAM) START(0x0005e000) END(0x0005ffff) WIDTH(32) }

seg_mp { TYPE(DM RAM) START(0x00200000) END(0x0027ffff) WIDTH(32) }

seg_extm { TYPE(DM RAM) START(0x00800000) END(0xffffffff) WIDTH(32) }
}

PROCESSOR p0
{
LINK_AGAINST( $COMMAND_LINE_LINK_AGAINST)
OUTPUT( $COMMAND_LINE_OUTPUT_FILE )

SECTIONS
{
// .text output section
seg_rth
{
INPUT_SECTIONS( $OBJECTS(seg_rth) $LIBRARIES(seg_rth))
} >seg_rth

seg_init
{
ldf_seginit_space = . ;
INPUT_SECTIONS( $OBJECTS(seg_init) $LIBRARIES(seg_init))
} >seg_init

seg_pmco
{
INPUT_SECTIONS( $OBJECTS(seg_pmco) $LIBRARIES(seg_pmco))
} >seg_pmco

seg_pm40
{
INPUT_SECTIONS( $OBJECTS(seg_pm40) $LIBRARIES(seg_pm40))
} >seg_pm40

seg_pmda
{
INPUT_SECTIONS( $OBJECTS(seg_pmda) $LIBRARIES(seg_pmda))
} >seg_pmda

seg_dmda
{
INPUT_SECTIONS( $OBJECTS(seg_dmda) $LIBRARIES(seg_dmda))
} > seg_dmda

seg_mp
{
INPUT_SECTIONS( $OBJECTS(seg_mp) $LIBRARIES(seg_mp))
} > seg_mp

stackseg
{

// allocate a stack for the application
ldf_stack_space = .;
ldf_stack_length = MEMORY_SIZEOF(seg_stak);
} > seg_stak

heap
{
// allocate a heap for the application
ldf_heap_space = .;
ldf_heap_end = ldf_heap_space + MEMORY_SIZEOF(seg_heap) - 1;
ldf_heap_length = ldf_heap_end - ldf_heap_space;
} > seg_heap

}
} ----- Original Message -----
From: "Clifford van Dyk" <>
To: "Nikolay Berbatov" <>
Sent: Thursday, March 22, 2001 3:58 PM
Subject: Re: [adsp] Access to multiprocessing memory of adsp-21160 > Please post a copy of your LDF file so that I can see what you have done.
>
> Regards,
> Clifford van Dyk
>
> Nikolay Berbatov wrote:
>
> > Thank you Clifford,
> >
> > I'm using VisualDSP++ 1.0 and I know that I can map multiprocessing
memory
> > in LDF file, but I have a problem to declare for exmple a data buffer in
the
> > maped memory. I write the following:
> >
> > #define SIZE 1024
> > int data_buf[SIZE] __attribute__((segment=seg_mp));
> >
> > and this didn't work. The compiler dave me an error in
__attribute__((.....
> >
> > Where is the problem?
> >
> > Regards,
> > Nikolay
> >
> > ----- Original Message -----
> > From: "Clifford van Dyk" <>
> > To: "Kenneth Porter" <>
> > Cc: <>
> > Sent: Thursday, March 22, 2001 7:44 AM
> > Subject: Re: [adsp] Access to multiprocessing memory of adsp-21160
> >
> > > The ADSP-21160 is much the same as the ADSP-21065L in that it has a
> > multiprocessing memory space. Each processor resides in a different
> > addressing range within this memory space, determined by the processor's
ID
> > > (selected by hardwiring ID pins on the processor).
> > > Information on this can be found on page 5-17 of the ADSP-21160
hardware
> > reference manual. It is also possible to map areas of interprocessor
memory
> > in the projects LDF file (assuming you are using VisualDSP++),
> > > which would allow one to define the multiproccessing memory maps once
and
> > not again.
> > >
> > > Regards,
> > > Clifford
> > >
> > > Kenneth Porter wrote:
> > >
> > > > On Tue, 20 Mar 2001 08:43:05 +0100, Nikolay Berbatov wrote:
> > > >
> > > > > can anybody tell me, how can I access the multiprocessor memory of
> > other
> > > > > DSPs from the Host DSP (ADSP-21160). Can you give me a short C
source
> > code
> > > > > of that. I
> > > > > want to transfer a buffer to the multiprocessor memory (without
link
> > port)
> > > > > and than to receive it back.
> > > >
> > > > Don't know about the 21160, but with the 21065L, multiprocessor
memory
> > > > shows up at low addresses, with each other SHARC showing up at a
fixed
> > > > multiple of its CPU ID. IIRC, it's 0x100 times the CPU ID to see the
> > > > registers for another CPU.
> > > >
> > > > To access absolute addresses in C, use something like this:
> > > >
> > > > #define my_register (* (unsigned*) 0x100)
> > > >
> > > > unsigned foo()
> > > > {
> > > > my_register = 0x1234;
> > > > return my_register;
> > > > }
> > > >
> > > > _____________________________________
> > > > Note: If you do a simple "reply" with your email client, only the
author
> > of this message will receive your answer. You need to do a "reply all"
if
> > you want your answer to be distributed to the entire group.
> > > >
> > > > _____________________________________
> > > > About this discussion group:
> > > >
> > > > To Join: Send an email to
> > > >
> > > > To Post: Send an email to
> > > >
> > > > To Leave: Send an email to
> > > >
> > > > Archives: http://groups.yahoo.com/group/adsp
> > > >
> > > > Other Groups: http://www.dsprelated.com/groups.php3
> > > >
> > > >
> > > > ">http://docs.yahoo.com/info/terms/
> > >
> > > _____________________________________
> > > Note: If you do a simple "reply" with your email client, only the
author
> > of this message will receive your answer. You need to do a "reply all"
if
> > you want your answer to be distributed to the entire group.
> > >
> > > _____________________________________
> > > About this discussion group:
> > >
> > > To Join: Send an email to
> > >
> > > To Post: Send an email to
> > >
> > > To Leave: Send an email to
> > >
> > > Archives: http://groups.yahoo.com/group/adsp
> > >
> > > Other Groups: http://www.dsprelated.com/groups.php3
> > >
> > >
> > > ">http://docs.yahoo.com/info/terms/
> > >
> > >
> >
> > _____________________________________
> > Note: If you do a simple "reply" with your email client, only the author
of this message will receive your answer. You need to do a "reply all" if
you want your answer to be distributed to the entire group.
> >
> > _____________________________________
> > About this discussion group:
> >
> > To Join: Send an email to
> >
> > To Post: Send an email to
> >
> > To Leave: Send an email to
> >
> > Archives: http://groups.yahoo.com/group/adsp
> >
> > Other Groups: http://www.dsprelated.com/groups.php3
> >
> >
> > ">http://docs.yahoo.com/info/terms/
>



Hi Nikolay

I presume that this would also apply to C/C++, but here is the method for
accessing multiprocessor memory space:

The LDF file should have the following format:

MPMEMORY
{
p1 {START(0x00100000)}
p2 {START(0x00200000)}
}

PROCESSOR p1
{
LINK_AGAINST(P2.dxe)
OUTPUT(P1.dxe)
SECTIONS {INCLUDE("pe1_sections.h")}
}

PROCESSOR p2
{
LINK AGAINST(P1.dxe)
OUTPUT(P2.dxe)
SECTIONS {INCLUDE("pe2_sections.h")}
}

In SHARC1, one can then define a variable within, for example, segment seg_dmda
segment("segdmda") int iBuffer[100];

In SHARC2, one would declare this buffer as an extern:
extern int iBuffer[]; etc.

Hope this helps...

Regards,
Clifford van Dyk



VCard
Clifford van Dyk <>

Development Engineer
Peralex Electronic Development

Peralex House
5 Dreyersdal Road
Bergvliet
Cape Town
Western Cape
7945
South Africa
Fax: +27-21-7123879
Home: +27-21-7152716
Work: +27-21-7120203

On Thu, 22 Mar 2001 13:27:40 +0100, Nikolay Berbatov wrote:

> int data_buf[SIZE] __attribute__((segment=seg_mp));

I use:

int segment("seg_mp") data_buf[SIZE];

I think segment is deprecated in VDSPC++ and is now replaced by
section. In any case, hide this behind a macro for portability like
this:

#define MPMEM section("seg_mp");
int MPMEM data_buf[SIZE];

If you change compilers (eg. if you went to another vendor's chip), you
just need to change the macro in one place in some common header, not
on every variable declaration.



I have only asm example. #include "def21160.h"

#define N 16

#define BDCST 0x00700000
#define ID6 0x00600000
#define ID5 0x00500000
#define ID4 0x00400000
#define ID3 0x00300000
#define ID2 0x00200000
#define ID1 0x00100000

#define Block1 0x050000

/* DM data */
.segment/dm seg_dmda;
.VAR source[N] =
0x11111111,0x22222222,0x33333333,0x44444444,0x55555555,0x66666666,0x77777777,0x8\
8888888,

0x99999999,0xaaaaaaaa,0xbbbbbbbb,0xcccccccc,0xdddddddd,0xeeeeeeee,0xffffffff,0xa\
5a5a5a5;
.endseg;

/* PM interrupt vector code */
.segment/pm seg_rth;
Reserved_1: rti; nop; nop; nop;
Chip_Reset: idle; jump begin; nop; nop;
.endseg;

/* program memory code */
.segment/pm seg_pmco;
begin:
ustat1=dm(SYSCON);
bit clr ustat1 BHD;
dm(SYSCON)=ustat1;

/* Clear registers */
r0=0; s0=0;
r1=0; s1=0;
r2=0; s2=0;
r3=0; s3=0;
r4=0; s4=0;
r5=0; s5=0;
r6=0; s6=0;
r7=0; s7=0;
r8=0; s8=0;
r9=0; s9=0;
r10=0; s10=0;
r11=0; s11=0;
r12=0; s12=0;
r13=0; s13=0;
r14=0; s14=0;
r15=0; s15=0; b0=source;
m0=1;

b1=Block1+ID2; /* change this line for different ID's */

r0=dm(i0,m0); dm(i1,m0)=r0;
r1=dm(i0,m0); dm(i1,m0)=r1;
r2=dm(i0,m0); dm(i1,m0)=r2;
r3=dm(i0,m0); dm(i1,m0)=r3;
r4=dm(i0,m0); dm(i1,m0)=r4;
r5=dm(i0,m0); dm(i1,m0)=r5;
r6=dm(i0,m0); dm(i1,m0)=r6;
r7=dm(i0,m0); dm(i1,m0)=r7;
s0=dm(i0,m0); dm(i1,m0)=s0;
s1=dm(i0,m0); dm(i1,m0)=s1;
s2=dm(i0,m0); dm(i1,m0)=s2;
s3=dm(i0,m0); dm(i1,m0)=s3;
s4=dm(i0,m0); dm(i1,m0)=s4;
s5=dm(i0,m0); dm(i1,m0)=s5;
s6=dm(i0,m0); dm(i1,m0)=s6;
s7=dm(i0,m0); dm(i1,m0)=s7; b1=Block1+ID2; /* change this line for different ID's */

r8=dm(i1,m0);
r9=dm(i1,m0);
r10=dm(i1,m0);
r11=dm(i1,m0);
r12=dm(i1,m0);
r13=dm(i1,m0);
r14=dm(i1,m0);
r15=dm(i1,m0);
s8=dm(i1,m0);
s9=dm(i1,m0);
s10=dm(i1,m0);
s11=dm(i1,m0);
s12=dm(i1,m0);
s13=dm(i1,m0);
s14=dm(i1,m0);
s15=dm(i1,m0);

wait1: idle;
jump wait1;
.endseg; >From: "Nikolay Berbatov" <>
>Reply-To: "Nikolay Berbatov" <>
>To: <>
>Subject: [adsp] Access to multiprocessing memory of adsp-21160
>Date: Tue, 20 Mar 2001 08:43:05 +0100
>
>Hi,
>
>can anybody tell me, how can I access the multiprocessor memory of other
>DSPs from the Host DSP (ADSP-21160). Can you give me a short C source code
>of that. I
>want to transfer a buffer to the multiprocessor memory (without link port)
>and than to receive it back.
>
>Thanks in advance!
>
>Nikolay Berbatov >_____________________________________
>Note: If you do a simple "reply" with your email client, only the author of
>this message will receive your answer. You need to do a "reply all" if you
>want your answer to be distributed to the entire group.
>
>_____________________________________
>About this discussion group:
>
>To Join: Send an email to
>
>To Post: Send an email to
>
>To Leave: Send an email to
>
>Archives: http://groups.yahoo.com/group/adsp
>
>Other Groups: http://www.dsprelated.com/groups.php3 >">http://docs.yahoo.com/info/terms/

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


1. When linking (from VisualDSP) how do I specify the PROCESSOR (i.e. p1 vs.
p2)?

2. How do I grant visibility to the other DSP's .dxe file? Do the .dxe's
need to be in the same directory? Or do I make the directory visible via
the Link "Search Directories"?

Regards,
Don Waldron From: Clifford van Dyk <clifford@p...>
Date: Thu Mar 22, 2001 3:51pm
Subject: Re: [adsp] Access to multiprocessing memory of
adsp-21160

Hi Nikolay

I presume that this would also apply to C/C++, but here is
the method for
accessing multiprocessor memory space:

The LDF file should have the following format:

MPMEMORY
{
p1 {START(0x00100000)}
p2 {START(0x00200000)}
}

PROCESSOR p1
{
LINK_AGAINST(P2.dxe)
OUTPUT(P1.dxe)
SECTIONS {INCLUDE("pe1_sections.h")}
}

PROCESSOR p2
{
LINK AGAINST(P1.dxe)
OUTPUT(P2.dxe)
SECTIONS {INCLUDE("pe2_sections.h")}
}

In SHARC1, one can then define a variable within, for
example, segment seg_dmda
segment("segdmda") int iBuffer[100];

In SHARC2, one would declare this buffer as an extern:
extern int iBuffer[]; etc.

Hope this helps...

Regards,
Clifford van Dyk