#include <VmeModule.h>
class CVmeModule {CVmeModule(Space space, UInt_t base, UInt_t length, int nCrate = 0);
UChar_t peekb(UInt_t offset = 0);
UShort_t peekw(UInt_t offset = 0);
ULong_t peekl(UInt_t offset = 0);
void pokeb(UChar_t byte, UInt_t nOffset);
void pokew(UShort_t word, UInt_t nOffset);
void pokel(ULong_t lword, UInt_t nOffset);
UInt_t readl(void* pBuffer, UInt_t nOffset, size_t longs);
UInt_t readw(void* pBuffer, UInt_t nOffset, size_t words);
UInt_t readb(void* pBuffer, UInt_t nOffset, size_t bytes);
}
The CVmeModule
class provides a convenient set of services for
device drivers. Device drivers can either be implemented by private derivation
or inclusion of an object of type CVmeModule
, using its member
functions to access register space or to perform data transfers.
Private derivation is shown in the example below:
In this example, all the member functions ofCVmeModule
can be called by member functions of MyDriver
but not by
its clients.
Layering via inclusion is shown below:
Example 2. Creating a device driver via inclusion
class MyDriver { private: CVmeModule& m_Registers; ... }
m_Registers
.
CVmeModule(Space space, UInt_t base, UInt_t length, int nCrate = 0);
Constructs a CVmeModule
object. The space
,
base
, and length
describe the physical
address space of the module, including its address modifier.
If nCrate
is supplied,
it is the number of the VME crate in which the address space is described. If not supplied,
this defaults to VME crate 0 which is suitable for systems with a single VME crate.
UChar_t peekb(UInt_t offset = 0);
Returns the value of the byte at offset
bytes from the
base address of the module. If offset
is not supplied,
it defaults to zero.
UShort_t peekw(UInt_t offset = 0);
Returns the 16 bit word value at offset
words from the
base address of the module. If offset
is not supplied,
it defaults to zero.
ULong_t peekl(UInt_t offset = 0);
Returns the longword at offset
longwords from the base of the
module. If the offset
parameter is not supplied, then
0 is used.
void pokeb(UChar_t byte, UInt_t nOffset);
Writes the 8 bit byte byte
to the byte offset
nOffset
of the module.
void pokew(UShort_t word, UInt_t nOffset);
Writes the 16 bit word word
to the word offset
nOffset
in the module.
void pokel(ULong_t lword, UInt_t nOffset);
Writes the 32 bit longword lword
to the longword offset
nOffset
in the module.
UInt_t readl(void* pBuffer, UInt_t nOffset, size_t longs);
Reads a block of longwords from the modules. The longwords are read starting
at the longword offset nOffset
longs
32 bit longwords are read. The interface may
engage a block transfer engine if appropriate or if available.
The longwords reads are transferred to successiver longwords pointed to by
pBuffer
.
pBuffer
must point to a block of storage that is at
least longs
32 bit longwords long.
UInt_t readw(void* pBuffer, UInt_t nOffset, size_t words);
Reads a block of 16 bit words from the interface. The words are read starting
at word offset nOffset
.
words
consecutive 16 bit words are read into the buffer
pointed to by pBuffer
.
pBuffer
must point to a writable block of storage that
is at least words
16 bit words long.
UInt_t readb(void* pBuffer, UInt_t nOffset, size_t bytes);
Reads a block of 8 bit bytes from the module. The bytes are read from consucutive
locations starting at nOffset
bytes from the base of the module.
bytes
8 bit bytes are read into the buffer pointed to by
pBuffer
.
pBuffer
must point to a block of writable storage that is at least
bytes
8 bit bytes long.
The VME address modifier for the module is determined by a data type called CVmeModule::Space. CVmeModule::Space is an enumerated type that describes the address space characteristics of the VME address space inhabited by the module. While CVmeModule::Space values specify both the address and data width, in fact only the address width is important. CVmeModule::Space values can be one of the following:
Selects the VME Short IO address space. Short IO addresses are 16 bits wide. In addtion, the module is free to only decode the top 8 bits of the address as a board select. Short IO space is intended for simple program control I/O devices.
Selects the VME standard address space. Standard addresses are 24 bits wide. In the original backplane specification, the VME bus had 24 address and 16 data bits. There are no longer any backplanes of this sort in use (at least not at the NSCL). The current backplanes support 32 address lines and 32 data lines (VME64 a related standard expands this to 64 bits of address and data).
Selects the VME extended address space. Extended addresses are 32 bits wide.
Selects VME geographical addressing per the CERN backplane extensions. CERN Backplane extensions for the VME bus provide the ability to address a module by slot. This requires a an additional backplane connected (p3) in between the two standard connectors, and modules that are capable of reading the geographical address space.