[go: up one dir, main page]

Menu

[0a098c]: / modules / corbo.h  Maximize  Restore  History

Download this file

235 lines (213 with data), 4.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/* -*- mode: c++ -*- */
#ifndef __RCB_8047_CORBO__
#define __RCB_8047_CORBO_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <iosfwd>
#include <daq/VMEmanager.h>
template<class T>
class Reg
{
protected:
VMEmanager *vme;
unsigned long addr;
T v;
virtual void write() = 0;
virtual T read() = 0;
public:
typedef T type;
Reg(unsigned long ad = 0, bool doRead = true) : addr(ad)
{
vme = VMEmanager::VME();
SetAddress(ad, doRead);
}
virtual ~Reg()
{}
virtual Reg &Set(T x)
{
if (addr)
{
v = x;
write();
}
return *this;
}
virtual T Get()
{
if (addr)
v = read();
return v;
}
T operator()()
{
return Get();
}
unsigned long GetAddress()
{
return addr;
}
void SetAddress(unsigned long ad, bool doRead = true)
{
addr = ad;
if (addr && doRead)
Get();
}
};
class CharReg : public Reg<unsigned char>
{
protected:
void write();
type read();
public:
CharReg(unsigned long ad = 0, bool doRead = true)
: Reg<unsigned char>(ad, doRead)
{}
};
class ShortReg : public Reg<unsigned short>
{
protected:
void write();
type read();
public:
ShortReg(unsigned long ad = 0, bool doRead = true)
: Reg<unsigned short>(ad, doRead)
{}
};
class LongReg : public Reg<unsigned long>
{
protected:
void write();
type read();
public:
LongReg(unsigned long ad = 0) : Reg<unsigned long>(ad)
{}
};
class EvtReg : public LongReg
{
private:
unsigned long ival;
public:
EvtReg(unsigned long ad = 0) : LongReg(ad)
{
ival = LongReg::Get();
}
unsigned long Get()
{
return LongReg::Get() - ival;
}
Reg<unsigned long> &Set(unsigned long x)
{
LongReg::Set(x);
ival = LongReg::Get();
return *this;
}
};
class CSR : public ShortReg
{
public:
CSR(unsigned long ad = 0) : ShortReg(ad)
{ }
CSR &ChnEna(unsigned int x);
CSR &BusyMode(unsigned int x);
CSR &InpSel(unsigned int x);
CSR &BusyOut(unsigned int x);
CSR &CntSel(unsigned int x);
CSR &FastClr(unsigned int x);
CSR &PushEna(unsigned int x);
unsigned int ChnEna();
unsigned int BusyMode();
unsigned int InpSel();
unsigned int BusyOut();
unsigned int CntSel();
unsigned int FastClr();
unsigned int PushEna();
unsigned int InpState();
unsigned int LclBusy ();
unsigned int DifBusy();
unsigned int IntPend();
};
//---------------------------------------------------------------------
// Structure for the BIMCR register
//---------------------------------------------------------------------
class BIMCR : public CharReg
{
public:
BIMCR(unsigned long ad = 0) : CharReg(ad)
{}
BIMCR &IRQ(unsigned int x) ;
BIMCR &IRAC(unsigned int x) ;
BIMCR &IRE(unsigned int x) ;
BIMCR &XIN(unsigned int x) ;
BIMCR &FAC(unsigned int x) ;
BIMCR &F(unsigned int x) ;
unsigned int IRQ() ;
unsigned int IRAC();
unsigned int IRE() ;
unsigned int XIN() ;
unsigned int FAC() ;
unsigned int F () ;
};
class ROcntl
{
private:
unsigned long addr;
public:
CSR _csr[4];
EvtReg _evt[4];
ShortReg _dtim[4];
BIMCR _evcr[4];
CharReg _evvr[4];
BIMCR _tmcr[4];
CharReg _tmvr[4];
ShortReg _tst[4];
ShortReg _clr[4];
public:
ROcntl(unsigned long ad = 0) : addr(ad)
{
SetAddress(ad);
}
void SetAddress(unsigned long x);
unsigned long GetAddress()
{
return addr;
}
CSR &csr(int i)
{
return _csr[i];
}
LongReg &evtnum(int i)
{
return _evt[i];
}
ShortReg &dtim(int i)
{
return _dtim[i];
}
BIMCR &evcr(int i)
{
return _evcr[i];
}
CharReg &evvr(int i)
{
return _evvr[i];
}
BIMCR &tmcr(int i)
{
return _tmcr[i];
}
CharReg &tmvr(int i)
{
return _tmvr[i];
}
ShortReg &test(int i)
{
return _tst[i];
}
ShortReg &clr(int i)
{
return _clr[i];
}
void Dump();
};
#endif