1 / 9

Power PMAC Shared Memory December 2013

Power PMAC Shared Memory December 2013. Power PMAC Shared Memory. Key structure for permitting different tasks on Power PMAC to access same data Automatic real-time tasks: phase, servo, motion calculations User-written real-time tasks: phase, servo, foreground C tasks

Download Presentation

Power PMAC Shared Memory December 2013

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Power PMAC Shared MemoryDecember 2013

  2. Power PMAC Shared Memory • Key structure for permitting different tasks on Power PMAC to access same data • Automatic real-time tasks: phase, servo, motion calculations • User-written real-time tasks: phase, servo, foreground C tasks • Background tasks: Script PLC programs, automatic tasks • User-written C background routines and programs • Host communications threads: Telnet, SSH Server • Pre-defined data structures are placed in shared memory – setup, control, and status • User buffer can be defined in shared memory for application-specific data

  3. Pre-Defined Data Structures in Shared Memory • Accessible from Power PMAC script language • Names are not case sensitive from script programs or on-line commands • Use structure and element name directly – e.g.: • Sys.ServoPeriod = 0.250; • Motor[5].JogSpeed = Motor[5].MaxSpeed / 4; • Accessible from C-language routines and programs • Must include header file RtGpShm.h in compilation • Called routines “inherit” access to pshm structure variable • Independent programs must declare struct SHM variable • Use C method for referencing elements within structure: • pshm->ServoPeriod = 0.250; // No need to use “Sys.” • pshm->Motor[5].JogSpeed = pshm->Motor[5].MaxSpeed / 4; • Structure element names are case-sensitive from C programs

  4. Power PMAC Shared Memory User Buffer • Intended for application-specific data storage and transfer • User-definable size, defaults to 1 MByte (1,048,576 bytes) • Part of overall 768 MByte (0.75 GByte) standard user RAM • Part of overall 1.75 GByte extended user RAM • Allocation can be changed in IDE Project Manager • Use “Properties” Control window • Set “User Buffer” size in MBytes • Resulting size stored in ppproj.ini project configuration file • Must issue save command and reset/power-cycle before change takes effect • Base address of buffer can be found in Sys.pushm(user typically does not need to know numerical value)

  5. Shared Memory User Buffer Data Structure Elements • To access memory as 64-bit floating-point value (“double”): • Sys.Ddata[0] // Uses 8 bytes starting at Sys.pushm • Sys.Ddata[1] // Uses 8 bytes starting at Sys.pushm+$8 • Sys.Ddata[n] // n=(size/8)-1, uses last 8 bytes of buffer • To access memory as 32-bit floating-point value (“float”): • Sys.Fdata[0] // Uses 4 bytes starting at Sys.pushm • Sys.Fdata[1] // Uses 4 bytes starting at Sys.pushm+$4 • Sys.Fdata[n] // n=(size/4)-1, uses last 4 bytes of buffer • To access memory as 32-bit integer value • Sys.Idata[j] // Uses 4 bytes for signed integer starting at Sys.pushm+(4*j) • Sys.Udata[j] // Uses 4 bytes for unsigned integer starting at Sys.pushm+(4*j) • To access memory as 8-bit character value (for strings): • Sys.Cdata[j] // Uses 1 byte for character starting at Sys.pushm+j • Constant indices can range from 0 to 16,777,215 (or up to buffer end) • Any L-variable can be used for index (watch subroutine stack offset!) • Note that these are different ways of accessing and interpreting the same registers, so conflicts are possible!

  6. User Buffer Memory Organization

  7. Shared Memory User Buffer Element M-Variables • Define directly to data structure element • Mn->Sys.Ddata[{index}] for 64-bit floating-point variable • Mn->Sys.Fdata[{index}] for 32-bit floating-point variable • Mn->Sys.Idata[{index}] for 32-bit signed integer variable • Mn->Sys.Udata[{index}] for 32-bit unsigned integer variable • Mn->Sys.Cdata[{index}] for 8-bit character variable • {index} can be constant from 0 to 16,777,215 (in range of buffer) • {index} can be any L-variable • With IDE project manager, can declare as pointer variable – e.g. ptr CycleCount->Sys.Udata[32768] • With L-variable index, can use single M-variable to access an entire array of values – e.g. with ptr CycleTime->Sys.Fdata[L10] TotalTime = 0; L10 = 1000; while (L10 < 2000) TotalTime += CycleTime; L10++;

  8. Shared Memory User Buffer Formatted M-Variables • Useful especially for accessing partial words in buffer • Defined as Mn->{format}.user:{byte offset}.[{bit offset}.{width}] • Possible formats are: • d (double) for double-precision floating point • f (float) for single-precision floating point • u (unsigned) for 32-bit unsigned integer register • s (signed) for 32-bit signed integer register that saturates • i (integer) for 32-bit signed integer register that rolls over • {byte offset} must be divisible by 8 for d format • {byte offset} must be divisible by 4 for other formats • {bit offset} (= 0 to 31, default 0) and {width} (= 1 to 32, default 32) can only be used for integer formats • Can declare directly as “ptr” pointer variable in IDE • e.g.ptr HandshakeBit->u.user:$100.4.1

  9. Shared Memory User Buffer Element Addresses • Sys.Xdata[{index}].a specifies numerical address of element • X can be D, F, I, or U for different element types • {index} can be constant or L-variable • Most commonly used to specify data gathering of this element – e.g. Gather.Addr[7]=Sys.Fdata[372].a • Can be used for other purposes as well • Feedback data synthesized by a C-program and placed in shared memory can be accessed this way: EncTable[23].pEnc=Sys.Idata[7243].a • Outputs of virtual motors can be placed in shared memory as a holding register: Motor[9].pDac=Sys.Idata[379].a • From C, declare pointer (array base) variable – e.g.: int *MyUshmIntVar double *MyUshmDarray MyUshmIntVar = (int *) pushm + 9; // Sys.Idata[9] MyUshmDarray = (double *) pushm + 8192; // Sys.Ddata[8192]

More Related