7 template <
class DAECardPolicy>
8 SIMDAE2Card<DAECardPolicy>::SIMDAE2Card(
int position,
VMESimulationIface* vme,
isisU32_t firmware,
bool fw32,
FaultMode fault_mode,
DAEstatus& status) : Base(), m_position(position), m_type(UnknownCard), m_vme(vme), m_veto_raised(false), m_is_running(true), m_firmware(firmware)
11 addMapping(
ISISVME::TransferIORegisterSpace, FIRMVERS, 1, &
m_firmware,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
14 template <
class DAECardPolicy>
17 os <<
"SIMDAE2 card at position " << m_position;
20 template <
class DAECardPolicy>
22 bool writable,
isisU32_t* access_reg,
unsigned access_bit,
bool wrap,
23 bool sixteen_bit_access,
FaultMode fault_mode)
27 m_mapping.push_back(
sim_mapping(props, address, n,
sizeof(
isisU32_t), var, name, readable, writable, access_reg, access_bit, wrap, sixteen_bit_access, fault_mode));
32 template <
class DAECardPolicy>
34 bool writable,
isisU32_t* access_reg,
unsigned access_bit,
bool wrap,
35 bool sixteen_bit_access,
FaultMode fault_mode)
39 m_mapping.push_back(
sim_mapping(props, address, n,
sizeof(uint64_t), var, name, readable, writable, access_reg, access_bit, wrap, sixteen_bit_access, fault_mode));
44 template <
class __type,
class DAECardPolicy>
48 int ts =
sizeof(__type);
50 card = DAECardPolicy::cardFromAddress(address);
56 std::vector<sim_mapping>& mapping = d2card->
mapping();
57 address = DAECardPolicy::baseAddress(address);
59 for(i=0; i<mapping.size() && !done; i++)
61 access_reg_ok = ( (mapping[i].access_reg == NULL) || ((*(mapping[i].access_reg) & mapping[i].access_bit) != 0) );
62 if ( access_reg_ok && (address >= mapping[i].address) && (props & mapping[i].props) )
64 if (mapping[i].fault_mode !=
Working)
68 else if ( (address + ts * nitems) <= (mapping[i].address + ts * mapping[i].n) )
70 address -= mapping[i].address;
71 var = mapping[i].var<__type>();
72 for(j=0; j<nitems; j++)
74 data[j] = var[j + address/4];
78 else if (mapping[i].wrap)
80 address -= mapping[i].address;
81 var = mapping[i].var<__type>();
82 for(j=0; j<nitems; j++)
84 data[j] = var[(j + address/ts) % mapping[i].n];
100 template <
class __type,
class DAECardPolicy>
104 int ts =
sizeof(__type);
105 card = DAECardPolicy::cardFromAddress(address);
111 std::vector<sim_mapping>& mapping = d2card->
mapping();
112 address = DAECardPolicy::baseAddress(address);
113 for(i=0; i<mapping.size() && !done; i++)
115 if ( (address >= mapping[i].address) && (props & mapping[i].props) &&
116 ( (mapping[i].access_reg == NULL) || ((*(mapping[i].access_reg) & mapping[i].access_bit) != 0) ) )
118 if (mapping[i].fault_mode !=
Working)
122 else if (address + ts * nitems <= mapping[i].address + mapping[i].ws * mapping[i].n)
124 address -= mapping[i].address;
125 for(j=0; j<nitems; j++)
127 (mapping[i].var<__type>())[j + address/ts] = data[j];
131 else if (mapping[i].wrap)
133 address -= mapping[i].address;
134 for(j=0; j<nitems; j++)
136 (mapping[i].var<__type>())[(j + address/ts) % mapping[i].n] = data[j];
153 template <
class DAECardPolicy>
156 return simulateRead<isisU16_t>(
this, props, address, data16, nitems, status);
159 template <
class DAECardPolicy>
162 return simulateRead<isisU32_t>(
this, props, address, data32, nitems, status);
165 template <
class DAECardPolicy>
168 return simulateWrite<isisU16_t>(
this, props, address, data16, nitems, status);
171 template <
class DAECardPolicy>
174 return simulateWrite<isisU32_t>(
this, props, address, data32, nitems, status);
178 template <
class DAECardPolicy>
185 template <
class DAECardPolicy>
196 template <
class DAECardPolicy>
206 template <
class DAECardPolicy>
209 if ((low + (uint64_t)value) < low)
213 low += (uint64_t)value;
216 template <
class DAECardPolicy>
223 if (++middle > 0xffff)
uint32_t TransferProps
combination of TransferProp values
static void increment2(int value, isisU32_t &low, isisU32_t &high)
int read32(ISISVME::TransferProps props, unsigned long address, isisU32_t *data32, long nitems, DAEstatus &status)
int write32(ISISVME::TransferProps props, unsigned long address, isisU32_t *data32, long nitems, DAEstatus &status)
int read16(ISISVME::TransferProps props, unsigned long address, isisU16_t *data16, long nitems, DAEstatus &status)
virtual void printStatus(std::ostream &os)=0
static void increment32(int value, isisU32_t &low, isisU32_t &high)
static int simulateWrite(SIMDAE2Card< DAECardPolicy > *d2card, ISISVME::TransferProps props, unsigned long address, __type *data, long nitems, DAEstatus &status)
static void increment3(int value, isisU32_t &low, isisU32_t &middle, isisU32_t &high)
int addMapping(ISISVME::TransferProps props, isisU32_t address, int n, isisU32_t *var, const char *name, bool readable, bool writable, isisU32_t *access_reg, unsigned access_bit, bool wrap, bool sixteen_bit_access, FaultMode fault_mode)
static void increment(int value, isisU32_t &low)
SIMDAE2Card(int position, VMESimulationIface *vme, isisU32_t firmware, bool fw32, FaultMode fault_mode, DAEstatus &status)
std::vector< sim_mapping > & mapping()
int write16(ISISVME::TransferProps props, unsigned long address, isisU16_t *data16, long nitems, DAEstatus &status)
static int simulateRead(SIMDAE2Card< DAECardPolicy > *d2card, ISISVME::TransferProps props, unsigned long address, __type *data, long nitems, DAEstatus &status)