Rodmodule class library
Download
1 / 26

RodModule Class Library - PowerPoint PPT Presentation


  • 38 Views
  • Uploaded on

RodModule Class Library. Tom Meyer Iowa State University [email protected] Design Choices. K.I.S.S. – Keep it Simple, Stupid Try to avoid using interrupts. Build hardware to support them, if needed, but try to do it all with polling until forced to do otherwise.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' RodModule Class Library' - jaron


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Rodmodule class library

RodModule Class Library

Tom Meyer

Iowa State University

[email protected]

6 Feb 2003


Design choices
Design Choices

  • K.I.S.S. – Keep it Simple, Stupid

  • Try to avoid using interrupts. Build hardware to support them, if needed, but try to do it all with polling until forced to do otherwise.

  • RCC-ROD communication is mostly a matter of list processing. The “smarts” of how to do things is built into the DSP programs.

  • VME talks to three areas

    • Master DSP (slave DSP communication is possible, but usually goes through master). This is via lists of primitive commands.

    • Flash memories (for FPGAs and master DSP program)

    • Command (R/W) and status (R) registers

  • Because of the buffering of the DSPs, the RCC does not need a real-time OS. Plain vanilla Red Hat 7.x (x>=1) will do fine.

6 Feb 2003


Present status
Present Status

  • Basic functionality works.

    • Create a primitive and add it to a primitive list

    • Send a primitive list and retrieve the reply buffer if it exists

    • Send a primitive list to a slave DSP via the Master DSP

    • Read an unsolicited text buffer

  • In namespace “SctPixelRod”

  • One known problem:

    • Block read/writes do not work reliably. A work-around is to do single word writes. Less efficient, but works. Problem is under study.

  • Deferred items

    • Full implementation of the status() method – XML record?

    • Testing flash memory access methods

    • Verify() method

    • Testing text buffer wrap-around

    • Testing multi-block transfers

6 Feb 2003


Directory structure on sbc rcc0
Directory Structure on SBC (rcc0)

  • /CommonWithDsp

    • processor.h

    • smSendTxtBuff.h

    • txtBuffer.h

    • comRegDfns.h

    • memoryPartitions.h

    • primParams.h

    • sctStructure.h

    • utilities.h

    • vmeAddressMap.h

  • /CommonForHosts

    • errorCodes.h

    • flashUtility.h

    • hostDefinitions.h

    • primListTableDefinitions.h

    • commandListDefinitions.h

  • /RodCrate

    • RodModule.h, -.cxx

    • RodPrimitive.h, -.cxx

    • RodPrimList.h, -.cxx

    • RodOutList.h, -.cxx

    • RodRegisterBits.h

    • RodDspAddresses.h

    • RodVmeAddresses.h

  • /VmeInterface

    • RCCVmeInterface.h, -.cxx

    • VmeModule.h, -.cxx

    • VmePort.h

    • libRCCVmeInterface.a

  • /RodTests

    • EchoTest

    • Echo2Test

    • LedTest

    • MdspDump

    • SlvDspDump

6 Feb 2003


Methods inherited from vmemodule
Methods Inherited from VmeModule

Key:  = well tested; ? = untested; ! = known problems

  •  initialize()

    • Reset the ROD (bit 7 of FPGA Control Register 2)

    • Read ROD serial number

    • Initialize Master HPIC register and read it back to verify

    • Wait for MasterDSP init

    • Read reply buffer addresses

    • Initialize state variables

  •  reset()

    • Reset the ROD (bit 7 of FPGA Control Register 2)

    • Clear IDRAM

    • Reinitialize state variables

  • ? status()

    • Under development

    • For now just print to standard output

    • What information do we want?, Levels of info?

    • How to display it? XML record?

6 Feb 2003


Vme addresses
VME Addresses

  • DSP Host Port Interface (HPI)

    • Command Register (HPIC): Sets half-word order. Set once at start of program and leave it alone. (0x00000000/VME)

    • Address Register (HPIA): Address in DSP space to be accessed.

    • Data Registers: Data port (0x02000000/VME)

      • HPID_AUTO: Auto increments HPIA after access (0x04000000/VME)

      • HPID_NOAUTO: Leaves HPIA unchanged (0x06000000/VME)

  • FPGA Status and Control Registers

    • They access the FPGAs directly for configuration, reset, status, halt, etc.

      • FPGA_CONTROL_REG_REL_ADDR[8] (0x00C00000/VME)

      • FPGA_STATUS_REG_REL_ADDR[8] (0x00C00024/VME)

6 Feb 2003


Master dsp addresses
Master DSP Addresses

  • Slave DSP HPI Registers

    • Slave 0 HPIC (0x00780000/MDSP)

    • Slave 0 HPIA (0x00780004/MDSP)

    • Slave 0 HPID++ (0x00780009/MDSP)

    • Slave 0 HPIA (0x0078000c/MDSP)

    • Slave 1 HPIC (0x007A0000/MDSP)

    • Slave 1 HPIA (0x007A0004/MDSP)

    • Slave 1 HPID++ (0x007A0009/MDSP)

    • Slave 1 HPIA (0x007A000c/MDSP)

    • Slave 2 HPIC (0x007C0000/MDSP)

    • Slave 2 HPIA (0x007C0004/MDSP)

    • Slave 2 HPID++ (0x007C0009/MDSP)

    • Slave 2 HPIA (0x007C000c/MDSP)

    • Slave 3 HPIC (0x007E0000/MDSP)

    • Slave 3 HPIA (0x007E0004/MDSP)

    • Slave 3 HPID++ (0x007E0009/MDSP)

    • Slave 3 HPIA (0x007E000c/MDSP)

  • Primitive buffers

    • PRIM_BUFF_BASE (0x02040000/MDSP)

    • PRIM_BUFF_SIZE (0x28000)

  • Reply buffers

    • REPLY_BUFF_BASE (0x02068000/MDSP)

    • REPLY_BUFF_SIZE (0x28000)

  • Text Buffers

    • TEXT_BUFF_SIZE (0x8000)

    • ERR_BUFF_BASE (0x02020000/MDSP)

    • INFO_BUFF_BASE (0x02028000/MDSP)

    • DIAG_BUFF_BASE (0x02030000/MDSP)

    • XFER_BUFF_BASE (0x02038000/MDSP)

  • ROD Status Registers

    • STATUS_REG[3] (0x80000000/MDSP)

  • VME Command Registers

    • COMMAND_REG[2] (0x8000000C/MDSP)

6 Feb 2003


Constructor
Constructor

 RodModule( unsigned long baseAddr, unsigned long mapSize, VmeInterface & ourInterface, long slot, long numSlaves);

  • There are no copy or assignment operators.

  • The constructor creates a VmePort object and registers it with its VmeInterface object.

6 Feb 2003


Shared header files
Shared Header Files

  • The C-code DSP programs and the TestStand program use shared header files to specify addresses and bit assignments. We would like to use these same headers for C++.

  • We want to specify these details in only one place and propagate the information.

  • In C, these are set with #define statements.

  • C++ can use C headers, but it is more in keeping with C++ principles to declare the constants as const unsigned long variables. This lets the compiler catch any attempts to change them, and it does not expose the code to global text substitutions from #define statements.

  • I have wrapped the C headers with C++ header files that expose only data of interest to RodModule and use const unsigned long values. This also isolates C++ code from changes in C headers, and hides C-only parts of the header.

6 Feb 2003


Rodmodule data members
RodModule: Data Members

Board Params:

long m_slot; //! Slot number in VME crate

unsigned long m_serialNumber; //! Board serial number

VmePort* m_myVmePort; //! VME Port handle

long m_numSlaves; //! Number of slave DSPs on this ROD

long m_finBufferSize; //! Size of file input buffer, in bytes. Default=4096

std::string m_masterImageName; //! string holding name of master image file

std::string m_slaveEmifName[4]; //! string array holding names of slave EMIF files

std::string m_slaveIpramName[4]; //! string array holding names of slave IPRAM files

std::string m_slaveIdramName[4]; //! string array holding names of slave IDRAM files

std::string m_slaveExtName[4]; //! string array holding names of slave external files

Register copies:

unsigned long m_vmeCommandReg[2]; //! Cached copy of VME command registers

unsigned long m_rodStatusReg[3]; //! Cached copy of ROD Status registers

Primitive handling:

RodOutList* m_myOutList; //! A pointer to the array holding a reply buffer

PrimState m_myPrimState; //! State variable for sending primitive lists

Text buffer handling:

TextBuffState m_myTextState; //! State variable for reading text buffers

TEXT_BUFFER_TYPE m_textType; //! Text buffer type

struct TXTBUFFER m_txtBuffer; //! A struct holding text buffer info from txtbuffer.h

char m_textData[TEXT_BUFF_SIZE]; //! A local buffer to hold the text data

unsigned long* m_textBuff[N_TXT_BUFFS]; //! Array of pointers to the text buffers in MDSP space

6 Feb 2003


Rodmodule master dsp access methods
RodModule: Master DSP Access Methods

//! Load a 32-bit value into an HPI register.

 voidhpiLoad(const unsigned long hpiReg, const unsigned long hpiValue);

//! Fetch a 32-bit value from an HPI register.

 unsigned long hpiFetch(const unsigned long hpiReg);

//! Read to and write from Master DSP address space

 unsigned long mdspSingleRead(unsigned long address);

 void mdspSingleWrite(unsigned long address, unsigned long value);

(!)void mdspBlockRead(unsigned long address, unsigned long buffer[], long count);

(!)void mdspBlockWrite(unsigned long address, unsigned long buffer[], long count);

Note: VME block transfers are done internally with single word transfers.

Multi-block transfers are not yet tested.

6 Feb 2003


Rodmodule slave dsp access methods
RodModule: Slave DSP Access Methods

//! Load a 32-bit value into an HPI register.

 voidslvHpiLoad(const unsigned long hpiReg, const unsigned long hpiValue, long slaveNum);

//! Fetch a 32-bit value from an HPI register.

 unsigned long slvHpiFetch(const unsigned long hpiReg, long slaveNum);

//! Read to and write from a slave DSP memory address

 Unsigned long slaveSingleRead(long slaveNum, unsigned long dspAddr);

 void slaveSingleWrite(long slaveNum, unsigned long address, unsigned long value);

 void slaveBlockRead(long slaveNum, unsigned long address, unsigned long buffer[], long count);

 void slaveBlockWrite(long slaveNum, unsigned long address, unsigned long buffer[], long count);

6 Feb 2003


Rodmodule slave dsp control methods
RodModule: Slave DSP Control Methods

//! Initialize a slave.

 voidinitSlaveDsp(const std::string & emifFile, const std::string & ipramFile, const std::string& idramFile, const std::string extFile, const long slaveNumber);

//! Load a file into slave memory

 void loadSlaveImage(const std::string& fileName, const unsigned long address, const long slaveNum);

//! Start a slave executing

 void startSlave (const long slaveNum);

6 Feb 2003


Rodmodule dsp reset methods
RodModule: DSP Reset Methods

//! Reset the Master DSP via FPGA Control Reg 2

 voidresetMasterDsp();

//! Reset a Slave DSP via FPGA Control Reg 2

 void resetSlaveDsp(long slaveNumber);

//! Reset all DSPs via FPGA Control Reg 2

 void resetAllDsps();

6 Feb 2003


Rodmodule primitives
RodModule: Primitives

//! Send a primitive list

 void sendPrimList(RodPrimList *list);

//! Send a primitive list synchronously (I.e. handle all the handshakes inside this routine)

(?)void synchSendPrim(RodPrimList *list); // Do not use this without a good reason to

// It delays execution and may write to cout.

//! State machine to handle primlist dialog with ROD

 PrimState& primHandler();

//! Delete reply list retrieved by primHandler

 void deleteOutList();

6 Feb 2003


Rodmodule text buffers
RodModule: Text Buffers

//! Get a text buffer

 void getTextBuffer(char * buffer, long length);

//! State machine to handle text dialog with ROD

 TextBuffState textHandler();

Note: reading a wrapped-around buffer not yet tested

//! Clear the text buffer when done

 void clearTextBuffer();

6 Feb 2003


Rodmodule fpga flash memory support
RodModule: FPGA Flash Memory Support

!!Note: all methods on this page compile, but have not been tested!!

//! Erase a sector

? void sectorErase (unsigned long sectorBaseAddress);

//! Write a byte

? void writeByteToFlash (unsigned long address, UINT8 data);

//! Write a block

? void writeBlockToFlash (unsigned long address, UINT8 data, unsigned long numBytes);

//! Read a byte

? UINT8 readByteFromFlash (unsigned long address, long updateAddress);

//! Read a block

? void readBlockFromFlash (unsigned long address, UINT8 *buffer, unsigned long numBytes);

//! Do common erase command

? void commonEraseCommands (unsigned long flashBaseAddress);

6 Feb 2003


Rodmodule master program flash support
RodModule: Master Program Flash Support

!!Note: all methods on this page compile, but have not been tested!!

//! Erase the memory

? void chipEraseHpi ();

//! Write a block

? void writeBlockToFlashHpi (unsigned long address, UINT8 *data, unsigned long numBytes);

//! Do common erase commands

? void commonEraseCommandsHpi (unsigned long flashBaseAddress);

6 Feb 2003


Rodmodule utilities
RodModule: Utilities

//! Calculate a checksum (bit-wise XOR)

 long checkSum(const unsigned long *sourceArray, const long wordCount);

//! Go to sleep for a specified number of milliseconds

 void sleep(const double milliSecs);

//! Reverse the endian-ness of a data word if a flag is set

 unsigned long endianReverse32(const unsigned long inValue);

These methods may be moved to a RodUtilities class in the future.

6 Feb 2003


Rodprimitive class
RodPrimitive Class

  • A simple class to hold Primitive objects

  • Data members:

    • long m_length

    • long m_index

    • long m_id

    • long m_version

    • long *m_body

  •  Methods: Only the usual data accessor methods (“get” and “put”).

6 Feb 2003


Rodprimlist class
RodPrimList Class

  • Derived from the C++ Standard Template Library (STL) list class. This gives us almost all the functionality we need for free.

  • Data members:

    • unsigned long m_index

    • Unsigned long m_version

    • unsigned long *m_buffer

    • unsigned long m_listLength

  • Methods (other than data accessors)

    •  unsigned long numWords()

    •  unsigned long checkSum()

    •  void bufferBuild()

    •  void clear()

6 Feb 2003


Rodoutlist class
RodOutList Class

  • Contains reply lists generated by the MDSP in response to an associated primitive list.

  • Structure is the same as a PrimList

  • Data members:

    • long m_length

    • unsigned long* m_body

  • Methods:

    •  unsigned long* getBody()

    •  long getLength()

  • RodModule makes no attempt to understand the reply list, it merely passes it to a user thread for further handling.

6 Feb 2003


Main programs for testing
Main Programs for Testing

  • All are located in the RodTests directory.

  •  EchoTest.cc The first program I wrote sends a simple “ECHO” primitive, retrieves the reply, and prints it on the console. It also detects and prints messages from text buffers (mainly error).

    • Useful for debugging RodModule code and as a model for later programs.

    • In real RODDAQ, this functionality will be spread between threads and processes on the host and RCC machines.

  • Other programs are (or will be)

    • DspDump.cxx - Dumps values from a range of DSP addresses to stout. The user is prompted for which DSP space to dump (-1=Master, 0-4=Slave)

    • Echo2Test.cxx – Test primlist with multiple echo primitives in one primlist.

    • LedTest.cxx – Flashes a front panel LED via slave DSP

    • ?TextTest.cxx – Fill a text buffer via a primitive

    • ?EchoTestThread.cxx – A threaded version of EchoTest

6 Feb 2003


Sequence diagram
Sequence Diagram

6 Feb 2003


Text buffers
Text Buffers

  • Text buffers are more useful for debugging than for data taking.

  • If a DSP CPU crashes, we cannot execute primitives. But the on-board extended memory interface (EMIF) circuitry still lets us read the SDRAM contents.

  • Text Buffers are blocks of SDRAM memory to which we can write ASCII records with traceback information, or simple diagnostic info for later analysis. (Recall debugging FORTRAN with print statements.)

  • Even if DSP is fine, it may be useful to pass ASCII data into a message stream (MRS) in ATLAS.

  • There are four text buffers defined for the Master DSP

    • Err: for reporting fatal software error tracebacks

    • Info: for non-priority information messages

    • Diag: for diagnostic messages, “print” to it like we used to print out FORTRAN debug messages.

    • Xfer: A temporary MDSP buffer to relay text buffers from the Slave DSPs

6 Feb 2003



ad