|
PPG Client/Frontend
Classes and programs to interact with PPG
|
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. | |
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;
|
inline |
| i | retrieve text representation of sequence, i.e. file content |
| int PpgInterface::LoadSeqFromFile | ( | std::string | filename, |
| unsigned int | bufindex, | ||
| uint64_t & | duration ) |
Load PPG sequence file, as generated by PPGCompiler.
| filename | path to sequence file |
| bufindex | position in sequences buffer, argument for SetAddr() to select sequence to run |
| duration | return value of sequence duration in clock ticks |
| void PpgInterface::StartSeq | ( | bool | external = false | ) |
Start selected sequence.
Use SetAddr() to select sequence from buffer. Only starts if gate/veto conditions are met.
| external | if false, sequence starts asap, if true, it starts on next external trigger pulse |
| 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.
| 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
| gatemask | bitmask of enabled gate pins |
| mode | 0 = ignore gates, 1 = grandOR, 2 = grandAND |
| void PpgInterface::WriteStep | ( | int | index, |
| int | setpatt, | ||
| int | clrpatt, | ||
| int | delay, | ||
| int | instr ) |
Write step insequence.
| index | index of instruction to overwrite (will usually be done in sequence) |
| setpatt | bitmask of outputs to set high in this step |
| clrpatt | bitmask of outputs to set low in this step |
| delay | wait in units of 10ns clock ticks |
| instr | instruction type |