Bitstream Interpretation Library (BIL)  0.1
V5FDRIRegister.cpp
Go to the documentation of this file.
1 
11 
12 using namespace bil;
13 
14 
16  Register(V5RegisterAddress::FDRI, V5RegisterAddress::FDRI_STRING, true, false),
17  m_configuration(),
18  m_cmdReg(cmdReg),
19  m_farReg(farReg),
20  m_previousFrame()
21 {
22  // copy address layout into FAR's address instance
23  V5FrameAddress& fa = m_farReg.frameAddress();
24  fa.addressLayout(&(m_configuration.addressLayout()));
25 }
26 
27 
28 void V5FDRIRegister::write(const boost::uint32_t* words, size_t wordCount)
29 {
30  Register::write(words, wordCount);
31 
32  // writing 0 words does nothing
33  if (0 == wordCount) return;
34 
35  // check that wordCount denotes an integer number of frames
36  if (0 != wordCount % V5CfgFrame::WORDCOUNT) throw Exception();
37  // check that CMD register is in WCFG state
38  if (V5CommandCode::WCFG != m_cmdReg.commandCode()) throw Exception();
39 
40  // get frame address from FAR register
41  V5FrameAddress& fa = m_farReg.frameAddress();
42 
43  // loop over given data frame by frame
44  V5CfgFrame frame;
45  const boost::uint32_t* wordsLast = 0;
46  const boost::uint32_t* wordsEnd = words + wordCount;
47  while (words < wordsEnd)
48  {
49  // load frame
50  memcpy(frame.data(), words, V5CfgFrame::WORDCOUNT << 2);
51  wordsLast = words;
52  words += V5CfgFrame::WORDCOUNT;
53 
54  // copy frame at FAR frame address into configuration object
55  m_configuration.insert(fa, frame);
56 
57  // auto increment frame address and skip if necessary padding frames
58  // (after every row there are 2 padding frames)
59  unsigned prevRow = fa.rowIndex();
60  fa.next();
61  if (fa.rowIndex() != prevRow) words += (V5CfgFrame::WORDCOUNT << 1);
62  }
63 
64  // cache last written frame data for later use
65  memcpy(m_previousFrame.data(), wordsLast, V5CfgFrame::WORDCOUNT << 2);
66 }
67 
68 
70 {
71  // get frame address from FAR register
72  V5FrameAddress& fa = m_farReg.frameAddress();
73  // copy frame at FAR frame address into configuration object
74  m_configuration.insert(fa, m_previousFrame);
75 }
76 
77 
79 {
80  return m_configuration;
81 }
82 
83 
85 {
86  return m_configuration;
87 }
88 
89 
91 {
92  return m_cmdReg;
93 }
94 
95 
97 {
98  return m_farReg;
99 }