Bitstream Interpretation Library (BIL)  0.1
V5BitstreamDeviceDetector.cpp
Go to the documentation of this file.
1 
10 
11 using namespace bil;
12 
13 
15 {
16  reset();
17 }
18 
19 
21 {
22  return m_id;
23 }
24 
25 
27 {
29  m_id = 0;
30 }
31 
32 
34 {
36  checkDeviceID(type1Packet);
37 }
38 
39 
41 {
43  checkDeviceID(type2Packet);
44 }
45 
46 
48 {
49  // only writes to IDCODE register contain the device ID
50  if (PacketOpcode::REGISTER_WRITE != type2Packet.opcode()) return;
52  if (1 != type2Packet.wordCount()) return;
53 
54  // device ID found
55  const DeviceID::ID_t id = *(type2Packet.dataWords());
56  // check for multiple contradicting device IDs
57  if ((0 != m_id) && (id != m_id)) throw Exception();
58  // store device ID
59  m_id = id;
60 }
61 
62 
64 {
65  V5BitstreamDeviceDetector deviceDetector;
66  bitstream.runVisitor(deviceDetector);
67  return deviceDetector.deviceID();
68 }