ICP  1
sim_dae2_card.h
Go to the documentation of this file.
1 #ifndef SIMDAE2CARD_H
2 #define SIMDAE2CARD_H
3 
4 #include "isisvme_types.h"
5 #include "DAEstatus.h"
6 #include "dae2_card.h"
7 
9 
11 
12 struct sim_mapping
13 {
14 private:
15  void* m_var;
16 public:
19  int n;
20  int ws; // word size in bytes
21  template <typename T> T* var() { return static_cast<T*>(m_var); }
22  const char* name;
23  bool readable;
24  bool writable;
26  unsigned access_bit; // bitmask
27  bool wrap;
30  sim_mapping(ISISVME::TransferProps props_, isisU32_t address_, int n_, int ws_, void* var_, const char* name_, bool readable_,
31  bool writable_, isisU32_t* access_reg_, unsigned access_bit_, bool wrap_,
32  bool sixteen_bit_access_, FaultMode fault_mode_) :
33  props(props_), address(address_), n(n_), ws(ws_), m_var(var_), name(name_), readable(readable_), writable(writable_),
34  access_reg(access_reg_), access_bit(access_bit_), wrap(wrap_),
35  sixteen_bit_access(sixteen_bit_access_), fault_mode(fault_mode_) {}
36 
37 };
38 
39 template <class DAECardPolicy>
40 class SIMDAE2Card : public ISIS::Base, public DAECardPolicy
41 {
42 public:
44  SIMDAE2Card(int position, VMESimulationIface* vme, isisU32_t firmware, bool fw32, FaultMode fault_mode, DAEstatus& status);
45  int position() { return m_position; };
46  virtual ~SIMDAE2Card() { }
47  virtual void printStatus(std::ostream& os) = 0;
48  virtual void updateCardAfterWrite(DAEstatus& status) = 0;
49 
50  // Normally a card does not change after a read, but this is here to
51  // allow you to set a debugger breakpoint on a card read
52  virtual void updateCardAfterRead(DAEstatus& status) = 0;
53 
54  virtual void simulate(int delay) = 0;
55  int read16(ISISVME::TransferProps props, unsigned long address, isisU16_t* data16, long nitems, DAEstatus& status);
56  int read32(ISISVME::TransferProps props, unsigned long address, isisU32_t* data32, long nitems, DAEstatus& status);
57  int write16(ISISVME::TransferProps props, unsigned long address, isisU16_t* data16, long nitems, DAEstatus& status);
58  int write32(ISISVME::TransferProps props, unsigned long address, isisU32_t* data32, long nitems, DAEstatus& status);
59  std::vector<sim_mapping>& mapping() { return m_mapping; }
60  int addMapping(ISISVME::TransferProps props, isisU32_t address, int n, isisU32_t* var, const char* name, bool readable,
61  bool writable, isisU32_t* access_reg, unsigned access_bit, bool wrap,
62  bool sixteen_bit_access, FaultMode fault_mode);
63  int addMapping(ISISVME::TransferProps props, isisU32_t address, int n, uint64_t* var, const char* name, bool readable,
64  bool writable, isisU32_t* access_reg, unsigned access_bit, bool wrap,
65  bool sixteen_bit_access, FaultMode fault_mode);
66  int addMapping(ISISVME::TransferProps props, const unused_t& address, int n, isisU32_t* var, const char* name, bool readable,
67  bool writable, isisU32_t* access_reg, unsigned access_bit, bool wrap,
68  bool sixteen_bit_access, FaultMode fault_mode) { return 0; }
69  int addMapping(ISISVME::TransferProps props, const unused_t& address, int n, uint64_t* var, const char* name, bool readable,
70  bool writable, isisU32_t* access_reg, unsigned access_bit, bool wrap,
71  bool sixteen_bit_access, FaultMode fault_mode) { return 0; }
72 
73 
74  static void increment(int value, isisU32_t& low);
75  static void increment2(int value, isisU32_t& low, isisU32_t& high);
76  static void increment3(int value, isisU32_t& low, isisU32_t& middle, isisU32_t& high);
77  static void increment32(int value, isisU32_t& low, isisU32_t& high);
78  static void increment32(int value, uint64_t& low, isisU32_t& high);
79  bool isVetoing() { return m_veto_raised; }
80  bool isRunning() { return m_is_running; }
81  CardType type() { return m_type; }
82 
83 protected:
84  int m_position; // card number
89  std::vector<sim_mapping> m_mapping;
90 
91  isisU32_t m_firmware; // firmware register (new 32 bit style)
92 
93 
94 // isisU32_t m_firmware0; // firmware register (old 16 bit style, lower)
95 // isisU32_t m_firmware1; // firmware register (old 16 bit style, upper)
96  std::string loggingPrefix() const { return Poco::format("(card %d) ", m_position); }
97 };
98 
99 
100 #endif /* SIMDAE2CARD_H */
isisU32_t address
Definition: sim_dae2_card.h:18
uint32_t TransferProps
combination of TransferProp values
Definition: isisvme.h:16
isisU32_t m_firmware
Definition: sim_dae2_card.h:91
int position()
Definition: sim_dae2_card.h:45
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)
CardType m_type
Definition: sim_dae2_card.h:85
virtual void printStatus(std::ostream &os)=0
unused_t
Definition: dae_policy.h:4
virtual void updateCardAfterWrite(DAEstatus &status)=0
unsigned long isisU32_t
Definition: isisvme_types.h:8
static void increment32(int value, isisU32_t &low, isisU32_t &high)
static void increment3(int value, isisU32_t &low, isisU32_t &middle, isisU32_t &high)
bool isVetoing()
Definition: sim_dae2_card.h:79
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)
int addMapping(ISISVME::TransferProps props, const unused_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)
Definition: sim_dae2_card.h:66
const char * name
Definition: sim_dae2_card.h:22
FaultMode fault_mode
Definition: sim_dae2_card.h:29
static void increment(int value, isisU32_t &low)
SIMDAE2Card(int position, VMESimulationIface *vme, isisU32_t firmware, bool fw32, FaultMode fault_mode, DAEstatus &status)
int addMapping(ISISVME::TransferProps props, const unused_t &address, int n, uint64_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)
Definition: sim_dae2_card.h:69
VMESimulationIface * m_vme
Definition: sim_dae2_card.h:86
ISISVME::TransferProps props
Definition: sim_dae2_card.h:17
std::string loggingPrefix() const
Definition: sim_dae2_card.h:96
CardType type()
Definition: sim_dae2_card.h:81
unsigned short isisU16_t
Definition: isisvme_types.h:7
std::vector< sim_mapping > & mapping()
Definition: sim_dae2_card.h:59
virtual void simulate(int delay)=0
bool isRunning()
Definition: sim_dae2_card.h:80
int write16(ISISVME::TransferProps props, unsigned long address, isisU16_t *data16, long nitems, DAEstatus &status)
void * m_var
Definition: sim_dae2_card.h:15
bool sixteen_bit_access
Definition: sim_dae2_card.h:28
bool m_is_running
Definition: sim_dae2_card.h:88
bool m_veto_raised
Definition: sim_dae2_card.h:87
FaultMode
Definition: sim_dae2_card.h:10
unsigned access_bit
Definition: sim_dae2_card.h:26
virtual void updateCardAfterRead(DAEstatus &status)=0
isisU32_t * access_reg
Definition: sim_dae2_card.h:25
virtual ~SIMDAE2Card()
Definition: sim_dae2_card.h:46
std::vector< sim_mapping > m_mapping
Definition: sim_dae2_card.h:89
sim_mapping(ISISVME::TransferProps props_, isisU32_t address_, int n_, int ws_, void *var_, const char *name_, bool readable_, bool writable_, isisU32_t *access_reg_, unsigned access_bit_, bool wrap_, bool sixteen_bit_access_, FaultMode fault_mode_)
Definition: sim_dae2_card.h:30