PPG Client/Frontend
Classes and programs to interact with PPG
Loading...
Searching...
No Matches
PpgInterface Class Reference

Class to simplify communication between the linux susbsystem and the PPG firmware. More...

#include <PpgInterface.hh>

Public Types

enum  state { idle , waiting , running }
 

Public Member Functions

 PpgInterface ()
 Constructor.
 
 ~PpgInterface ()
 Destructor.
 
const int ReadSysID ()
 
const int ReadSysTimeStamp ()
 
const int ReadCSR ()
 Read Control and Status Register.
 
const int ReadTest ()
 Read Test register.
 
const int ReadTimeStamp ()
 
const int ReadGates ()
 Read Gate enable bitmask.
 
void WriteTest (int val)
 Write Test register, usually followed by ReadTest()
 
void WriteCSR (int val)
 Write Control and Status Register.
 
void WriteStep (int index, int setpatt, int clrpatt, int delay, int instr)
 Write step insequence.
 
void WriteGates (uint16_t gatemask, uint8_t mode=2)
 Set bit patterns for enable gates.
 
void WriteVetos (int vetomask)
 Enable veto pins.
 
int LoadSeqFromFile (std::string filename, unsigned int bufindex, uint64_t &duration)
 Load PPG sequence file, as generated by PPGCompiler.
 
const std::string GetSeqString (unsigned int i)
 
void StartSeq (bool external=false)
 Start selected sequence.
 
void Abort ()
 Abort running sequence.
 
const state GetState ()
 Report if PPG is idle, waiting for trigger, or currently running.
 
void TurnOffExt ()
 Turn off external trigger once running.
 
void SetAddr (int index)
 Select sequence to write/execute.
 

Detailed Description

Class to simplify communication between the linux susbsystem and the PPG firmware.

See https://daq00.triumf.ca/DaqWiki/index.php/VME-PPG32 for details.

PPG Registers:

0x00 0x04 0x08 0x0c 0x10 0x14 0x18 0x20
csr test addr data data data data tstamp

5'd0: bus_data_out <= csr;

5'd1: bus_data_out <= test_reg;

5'd2: bus_data_out <= prog_addr;

5'd3: bus_data_out <= prog_data[ 31: 0];

5'd4: bus_data_out <= prog_data[ 63:32];

5'd5: bus_data_out <= prog_data[ 95:64];

5'd6: bus_data_out <= prog_data[127:96];

5'd7: bus_data_out <= output_invmask;

5'd8: bus_data_out <= timestamp;

5'd9: bus_data_out <= sfl_in;

//4'd10: // serial# ;

//4'd11: // module_id ;

//5'd12: clockctrl_data <= bus_data_in;

//5'd13: csr <= csr & ~bus_data_in; // Selective clear

//5'd14: csr <= csr | bus_data_in; // Selective set

//5'd15: csr <= bus_data_in;

5'd16: bus_data_out <= gates;

Member Function Documentation

◆ GetSeqString()

const std::string PpgInterface::GetSeqString ( unsigned int i)
inline
Parameters
iretrieve text representation of sequence, i.e. file content

◆ LoadSeqFromFile()

int PpgInterface::LoadSeqFromFile ( std::string filename,
unsigned int bufindex,
uint64_t & duration )

Load PPG sequence file, as generated by PPGCompiler.

Parameters
filenamepath to sequence file
bufindexposition in sequences buffer, argument for SetAddr() to select sequence to run
durationreturn value of sequence duration in clock ticks
Returns
memory address of sequence

◆ StartSeq()

void PpgInterface::StartSeq ( bool external = false)

Start selected sequence.

Use SetAddr() to select sequence from buffer. Only starts if gate/veto conditions are met.

Parameters
externalif false, sequence starts asap, if true, it starts on next external trigger pulse

◆ TurnOffExt()

void PpgInterface::TurnOffExt ( )

Turn off external trigger once running.

In general, once put into external trigger mode (by WriteCSR(4)), the PPG will remain in this mode, so subsequent triggers will start the sequence again.

In order to avoid this, this function runs in a separate thread and waits for the sequence to start, at which point it turns off the external trigger input to avoid re-triggering.

◆ WriteGates()

void PpgInterface::WriteGates ( uint16_t gatemask,
uint8_t mode = 2 )

Set bit patterns for enable gates.

active gate pins must have pull-down to ground, or they will be undefined if disconnected

Parameters
gatemaskbitmask of enabled gate pins
mode0 = ignore gates, 1 = grandOR, 2 = grandAND

◆ WriteStep()

void PpgInterface::WriteStep ( int index,
int setpatt,
int clrpatt,
int delay,
int instr )

Write step insequence.

Parameters
indexindex of instruction to overwrite (will usually be done in sequence)
setpattbitmask of outputs to set high in this step
clrpattbitmask of outputs to set low in this step
delaywait in units of 10ns clock ticks
instrinstruction type

The documentation for this class was generated from the following files: