16#define PPG_STACKDEPTH 4000
21#define ALT_STM_OFST 0xfc000000
22#define ALT_LWFPGASLVS_OFST 0xff200000
24#define HWREG_BASE (ALT_STM_OFST)
25#define HWREG_SPAN (0x04000000)
26#define HWREG_MASK (HWREG_SPAN - 1)
28#define ADDR_ADJ(addr) ((long)((addr) + ALT_LWFPGASLVS_OFST) & (long)(HWREG_MASK))
31#define SYSID_QSYS_BASE 0x01000
32#define PPG_BASE 0x10000
34class MemMapException :
public std::runtime_error
37 MemMapException() : std::runtime_error(
"MemMapException") {}
90 const int csr = 0x04 * 0;
91 const int test = 0x04 * 1;
92 const int addr = 0x04 * 2;
93 const int setp = 0x04 * 3;
94 const int clrp = 0x04 * 4;
95 const int dly = 0x04 * 5;
109 const int inst = 0x04 * 6;
111 const int tstamp = 0x04 * 8;
112 const int flash = 0x04 * 9;
116 const int gates = 0x04 * 16;
117 const int vetos = 0x04 * 17;
119 const int fpga_read32(
int addr);
120 void fpga_write32(
int addr,
int data);
121 std::vector<std::string> seqstring;
122 std::thread *watchthread =
nullptr;
123 std::atomic<bool> abort =
false;
128 const int ReadSysID();
129 const int ReadSysTimeStamp();
132 const int ReadTimeStamp();
149 void WriteStep(
int index,
int setpatt,
int clrpatt,
int delay,
int instr);
157 void WriteGates(uint16_t gatemask, uint8_t mode = 2);
167 int LoadSeqFromFile(std::string filename,
unsigned int bufindex, uint64_t &duration);
171 if (i < seqstring.size())
174 return std::string();
182 void StartSeq(
bool external =
false);
void StartSeq(bool external=false)
Start selected sequence.
Definition PpgInterface.cc:42
const std::string GetSeqString(unsigned int i)
Definition PpgInterface.hh:169
~PpgInterface()
Destructor.
Definition PpgInterface.cc:26
const int ReadTest()
Read Test register.
Definition PpgInterface.cc:151
void TurnOffExt()
Turn off external trigger once running.
Definition PpgInterface.cc:77
const state GetState()
Report if PPG is idle, waiting for trigger, or currently running.
Definition PpgInterface.cc:66
PpgInterface()
Constructor.
Definition PpgInterface.cc:9
void SetAddr(int index)
Select sequence to write/execute.
Definition PpgInterface.cc:176
void WriteTest(int val)
Write Test register, usually followed by ReadTest()
Definition PpgInterface.cc:166
const int ReadCSR()
Read Control and Status Register.
Definition PpgInterface.cc:146
void WriteGates(uint16_t gatemask, uint8_t mode=2)
Set bit patterns for enable gates.
Definition PpgInterface.cc:181
void WriteStep(int index, int setpatt, int clrpatt, int delay, int instr)
Write step insequence.
Definition PpgInterface.cc:127
const int ReadGates()
Read Gate enable bitmask.
Definition PpgInterface.cc:161
int LoadSeqFromFile(std::string filename, unsigned int bufindex, uint64_t &duration)
Load PPG sequence file, as generated by PPGCompiler.
Definition PpgInterface.cc:196
void WriteVetos(int vetomask)
Enable veto pins.
Definition PpgInterface.cc:191
void Abort()
Abort running sequence.
Definition PpgInterface.cc:60
void WriteCSR(int val)
Write Control and Status Register.
Definition PpgInterface.cc:171