Bitstream Interpretation Library (BIL)  0.1
V5PacketProcessor.cpp
Go to the documentation of this file.
1 
10 
11 using namespace bil;
12 
13 
15  m_addressLayoutRegistry(registry),
16  m_registerLookup(V5RegisterAddress::CTL1),
17  m_crcReg(),
18  m_farReg(),
19  m_cmdReg(m_crcReg),
20  m_fdriReg(m_cmdReg, m_farReg),
21  m_mfwrReg(m_cmdReg, m_fdriReg),
22  m_idcodeReg(m_fdriReg, m_addressLayoutRegistry),
23  m_fdroReg(V5RegisterAddress::FDRO, V5RegisterAddress::FDRO_STRING, false, true),
24  m_ctl0Reg(V5RegisterAddress::CTL0, V5RegisterAddress::CTL0_STRING, true, true),
25  m_maskReg(V5RegisterAddress::MASK, V5RegisterAddress::MASK_STRING, true, true),
26  m_statReg(V5RegisterAddress::STAT, V5RegisterAddress::STAT_STRING, false, true),
27  m_loutReg(V5RegisterAddress::LOUT, V5RegisterAddress::LOUT_STRING, true, false),
28  m_cor0Reg(V5RegisterAddress::COR0, V5RegisterAddress::COR0_STRING, true, true),
29  m_cbcReg(V5RegisterAddress::CBC, V5RegisterAddress::CBC_STRING, true, false),
30  m_axssReg(V5RegisterAddress::AXSS, V5RegisterAddress::AXSS_STRING, true, true),
31  m_cor1Reg(V5RegisterAddress::COR1, V5RegisterAddress::COR1_STRING, true, true),
32  m_csobReg(V5RegisterAddress::CSOB, V5RegisterAddress::CSOB_STRING, true, false),
33  m_wbstarReg(V5RegisterAddress::WBSTAR, V5RegisterAddress::WBSTAR_STRING, true, true),
34  m_timerReg(V5RegisterAddress::TIMER, V5RegisterAddress::TIMER_STRING, true, true),
35  m_reg19Reg(V5RegisterAddress::REG19, V5RegisterAddress::REG19_STRING, true, false),
36  m_bootstsReg(V5RegisterAddress::BOOTSTS, V5RegisterAddress::BOOTSTS_STRING, false, true),
37  m_ctl1Reg(V5RegisterAddress::CTL1, V5RegisterAddress::CTL1_STRING, true, true)
38 {
39  m_registerLookup.add(m_crcReg);
40  m_registerLookup.add(m_farReg);
41  m_registerLookup.add(m_cmdReg);
42  m_registerLookup.add(m_fdriReg);
43  m_registerLookup.add(m_mfwrReg);
44  m_registerLookup.add(m_idcodeReg);
45  m_registerLookup.add(m_fdroReg);
46  m_registerLookup.add(m_ctl0Reg);
47  m_registerLookup.add(m_maskReg);
48  m_registerLookup.add(m_statReg);
49  m_registerLookup.add(m_loutReg);
50  m_registerLookup.add(m_cor0Reg);
51  m_registerLookup.add(m_cbcReg);
52  m_registerLookup.add(m_axssReg);
53  m_registerLookup.add(m_cor1Reg);
54  m_registerLookup.add(m_csobReg);
55  m_registerLookup.add(m_wbstarReg);
56  m_registerLookup.add(m_timerReg);
57  m_registerLookup.add(m_reg19Reg);
58  m_registerLookup.add(m_bootstsReg);
59  m_registerLookup.add(m_ctl1Reg);
60 }
61 
62 
63 void V5PacketProcessor::visit(const DummyWord& dummyWord)
64 {
65  // dummy words after sync word contribute to the CRC check as they are used
66  // for writing padding frames
67  const boost::uint32_t dummy = dummyWord.value();
68  if (behindSyncWord()) m_crcReg.update(&dummy, 1, V5RegisterAddress::FDRI);
69 }
70 
71 
72 void V5PacketProcessor::visit(const Type1Packet& type1Packet)
73 {
75  visitDataPacket(type1Packet);
76 }
77 
78 
79 void V5PacketProcessor::visit(const Type2Packet& type2Packet)
80 {
82  visitDataPacket(type2Packet);
83 }
84 
85 
87 {
88  // reset syntax check state and configuration memory
90  m_fdriReg.configuration().clear();
91 }
92 
93 
95 {
96  return m_fdriReg.configuration();
97 }
98 
99 
101 {
102  return m_fdriReg.configuration();
103 }
104 
105 
107 {
108  return m_addressLayoutRegistry;
109 }
110 
111 
113 {
114  // handle type 2 based data packets, they contain data for the register
115  // engine
116  switch (type2Packet.opcode()) {
118  // do register write
119  registerWrite(lastType1Address(), type2Packet.dataWords(), type2Packet.wordCount());
120  break;
121 
123  // do register read - not implemented yet
124  break;
125 
126  case PacketOpcode::NO_OP:
127  // NO OP - do nothing
128  break;
129 
130  default: throw Exception();
131  }
132 }
133 
134 
135 void V5PacketProcessor::registerWrite(RegisterAddress::address_t regAddr, const boost::uint32_t* words, size_t wordCount)
136 {
137  // get pointer to target register
138  Register* reg = m_registerLookup.lookup(regAddr);
139  if (0 == reg) throw Exception();
140 
141  // CRC check written data (excluding writes to LOUT)
142  if (V5RegisterAddress::LOUT != regAddr)
143  m_crcReg.update(words, wordCount, regAddr);
144 
145  // write data to target register
146  reg->write(words, wordCount);
147 }