AFHBA404
AFHBA404 connects ACQ2106 to PCI-Express
|
Go to the documentation of this file.
12 #include "../rtm-t_ioctl.h"
32 #define PAGE_SIZE 0x1000
48 memset(
this, 0,
sizeof(
Dev));
54 #define AO_OFFSET 0x1000
56 #define XO_HOST (dev->host_buffer+AO_OFFSET)
66 mlockall(MCL_CURRENT);
75 static void raw_store(
const char* fname,
const char* base,
int len)
77 FILE *fp = fopen(fname,
"w");
95 VO _vo_offsets,
VI& sys_vi_cursor,
VO& sys_vo_cursor) :
97 _vo_offsets, sys_vi_cursor, sys_vo_cursor),
121 virtual unsigned tlatch(
void);
135 VO _vo_offsets,
VI& sys_vi_cursor,
VO& sys_vo_cursor);
146 #define TLATCH0 ((unsigned*)(dev->host_buffer + vi_offsets.SP32))[SPIX::TLATCH]
149 VO _vo_offsets,
VI& sys_vi_cursor,
VO& sys_vo_cursor) :
151 _vo_offsets, sys_vi_cursor, sys_vo_cursor)
154 perror(
"ioctl AFHBA_START_AI_LLC");
169 int ll = xo_xllc_def.
len/64;
170 xo_xllc_def.
len = ++ll*64;
174 perror(
"ioctl AFHBA_START_AO_LLC");
178 printf(
"[%d] AO buf pa: 0x%08x len %d\n",
dev->
devnum, xo_xllc_def.
pa, xo_xllc_def.
len);
184 for (
int ii = 0; ii <= 0xf; ++ii){
185 dox[ii] = (ii<<24)|(ii<<16)|(ii<<8)|ii;
196 #define VITOSI(field) \
198 memcpy(reinterpret_cast<char*>(systemInterface.IN.field+vi_cursor.field), dev->lbuf_vi.cursor+vi_offsets.field, \
199 vi.field*sizeof(systemInterface.IN.field[0])))
209 fprintf(stderr,
"VITOSI(AI32) \"%s\" memcpy(%p, %p, %ld)\n",
toString().c_str(),
222 #define SITOVO(field) \
224 memcpy(XO_HOST+vo_offsets.field, reinterpret_cast<char*>(systemInterface.OUT.field+vo_cursor.field), \
225 vo.field*sizeof(systemInterface.OUT.field[0])))
228 #define SITOVO2(field) \
230 memcpy(dev->lbuf_vo.cursor+vo_offsets.field, (char*)systemInterface.OUT.field+vo_cursor.field, \
231 vo.field*sizeof(systemInterface.OUT.field[0])))
278 cerr <<
"ACQ_HW_BASE::arm: TODO" <<endl;
301 VO _vo_offsets,
VI& sys_vi_cursor,
VO& sys_vo_cursor,
int nbuffers);
309 VO _vo_offsets,
VI& sys_vi_cursor,
VO& sys_vo_cursor,
int _nbuffers):
311 _vo_offsets, sys_vi_cursor, sys_vo_cursor),
313 tl0_array(new unsigned[_nbuffers]),
333 perror(
"ioctl AFHBA_START_AI_ABN");
381 VO _vo_offsets,
VI& sys_vi_cursor,
VO& sys_vo_cursor,
int nmean);
394 VO _vo_offsets,
VI& sys_vi_cursor,
VO& sys_vo_cursor,
int _nmean) :
396 _vo_offsets, sys_vi_cursor, sys_vo_cursor, _nmean),
421 fprintf(stderr,
"TLATCH:%08x\n",
tl0);
436 for (
int ic = 0; ic <
vi.
AI32; ++ic){
439 for (
int sam = 1; sam <
nmean; ++sam){
440 total +=
raw[sam][ic] >> 8;
442 total +=
raw[0][ic] >> 8;
457 VO _vo_offsets,
VI& _sys_vi_cursor,
VO& _sys_vo_cursor,
int _nmean,
int _nskip) :
459 _vo_offsets, _sys_vi_cursor, _sys_vo_cursor, _nmean),
462 fprintf(stderr,
"%s skip:%d\n", __FUNCTION__, nskip);
479 bool over0 =
tl0 + nskip <
tl0;
480 bool over1 = tl1 <
tl0;
482 if (!(over0 || over1)){
483 if (tl1 >
tl0 + nskip){
486 fprintf(stderr,
"TLATCH:%08x\n",
tl0);
491 unsigned long long endpoint =
tl0; endpoint += nskip;
492 unsigned long long current = tl1;
if (over1) current += 1ULL<<32;
494 if (current > endpoint){
497 fprintf(stderr,
"TLATCH:%08x ROLLOVER\n",
tl0);
514 VO _vo_offsets,
VI& sys_vi_cursor,
VO& sys_vo_cursor)
519 sscanf(
getenv(
"HW"),
"%d,%d", &HW, &skip);
526 return new ACQ_HW_MULTI(
devnum, _name, _vi, _vo, _vi_offsets, _vo_offsets, sys_vi_cursor, sys_vo_cursor, multi);
528 return new ACQ_HW(
devnum, _name, _vi, _vo, _vi_offsets, _vo_offsets, sys_vi_cursor, sys_vo_cursor);
531 return new ACQ_HW_MEAN_SKIPPER(
devnum, _name, _vi, _vo, _vi_offsets, _vo_offsets, sys_vi_cursor, sys_vo_cursor, HW, skip);
533 return new ACQ_HW_MEAN(
devnum, _name, _vi, _vo, _vi_offsets, _vo_offsets, sys_vi_cursor, sys_vo_cursor, HW);
536 return new ACQ(
devnum, _name, _vi, _vo, _vi_offsets, _vo_offsets, sys_vi_cursor, sys_vo_cursor);
const VI vi_cursor
index for each Input type in System Interface
#define RTM_T_USE_HOSTBUF
virtual bool newSample(int sample)
checks host buffer for new sample, if so copies to lbuf and reports true
as per ACQ_HW, but with multi dma buffers use for applications like THOMSON where multi back to back ...
acqproc global class interface definition.
ACQ(int devnum, string _name, VI _vi, VO _vo, VI _vi_offsets, VO _vo_offsets, VI &sys_vi_cursor, VO &sys_vo_cursor)
#define VITOSI(field)
copy VI.field to SI.field
SPIX
SPIX: defined fields in SP32 array.
const VO vo_offsets
byte offset for each Output type in Local Vector Out
#define AFHBA_START_AI_ABN
takes mean of N samples, newSample returns true after skip samples
int devnum
AFHBA404 device numbers 0..N.
output the mean of nb values
ACQ_HW_MULTI(int devnum, string _name, VI _vi, VO _vo, VI _vi_offsets, VO _vo_offsets, VI &sys_vi_cursor, VO &sys_vo_cursor, int nbuffers)
virtual void start_shot()
u32 pa
SRC or DST buffer PA - round to 1K RTM_T_USE_HOSTBUF=> use Driver buffer 0.
virtual bool newSample(int sample)
checks host buffer for new sample, if so copies to lbuf and reports true
@ POLLCOUNT
pollcount: number of times SW polled for incoming.
int AI32
AI32 values from the HW.
unsigned len
length in bytes - will round up to next %64
bool _newSample(int sample)
unsigned wd_mask
watchdog mask.
virtual void arm(int nsamples)
prepare to run a shot nsamples long, arm the UUT.
int SP32
SP32 values from the HW.
struct Dev : interface to AFHBA404 device driver.
struct SystemInterface::Inputs IN
ACQ_HW(int devnum, string _name, VI _vi, VO _vo, VI _vi_offsets, VO _vo_offsets, VI &sys_vi_cursor, VO &sys_vo_cursor)
virtual void action2(SystemInterface &systemInterface)
late action(), cleanup
static int maxsam
max samples in shot (for raw memory alloc)
virtual void action2(SystemInterface &systemInterface)
late action(), cleanup
static ACQ * factory(int devnum, string _name, VI _vi, VO _vo, VI _vi_offsets, VO _vo_offsets, VI &sys_vi_cursor, VO &sys_vo_cursor)
abstract model of an ACQ2106 box.
static int getenv(const char *key, int def)
#define AFHBA_START_AI_LLC
ioctl ACQ2106 Start Low Latency Control Inbound outputs actual pa used
concrete model of ACQ2106 box.
#define SITOVO(field)
copy SI.field to VO
int DO32
DO32 values from the algorithm.
const VI vi_offsets
byte offset for each Input type in Local Vector In
void _get_connected(struct Dev *dev, unsigned vi_len)
virtual bool newSample(int sample)
checks host buffer for new sample, if so copies to lbuf and reports true
void * get_mapping(dev_t devnum, int *pfd)
virtual void action(SystemInterface &systemInterface)
on newSample, copy VO from SI, copy VI to SI
#define SITOVO2(field)
copy SI.field to XO archive.
ACQ_HW_MEAN(int devnum, string _name, VI _vi, VO _vo, VI _vi_offsets, VO _vo_offsets, VI &sys_vi_cursor, VO &sys_vo_cursor, int nmean)
Models interface with external PCS.
virtual string toString()
struct XLLC_DEF buffers[MAXABN]
#define AFHBA_START_AO_LLC
ioctl ACQ2106 Start Low Latency Control Outbound
#define TLATCH0
find sample count in VI.
int samples_buffer
number of samples in each VI buffer (default:1)
void clear_mapping(int fd, void *hb)
ACQ_HW_MEAN_SKIPPER(int devnum, string _name, VI _vi, VO _vo, VI _vi_offsets, VO _vo_offsets, VI &_sys_vi_cursor, VO &_sys_vo_cursor, int _nmean, int _nskip)
int getenv(const char *key, int def, int(*cvt)(const char *key))
int nsamples
samples to capture (default:2, typ 200000)
virtual void action(SystemInterface &systemInterface)
on newSample, copy VO from SI, copy VI to SI
virtual bool newSample(int sample)
checks host buffer for new sample, if so copies to lbuf and reports true
ACQ_HW_BASE(int devnum, string _name, VI _vi, VO _vo, VI _vi_offsets, VO _vo_offsets, VI &sys_vi_cursor, VO &sys_vo_cursor)
virtual unsigned tlatch(void)
returns latest tlatch from lbuf
bool nowait
newSample doesn't block for new Tlatch (eg bolo in set with non bolo uuts).