ChimeraTK-DeviceAccess  03.18.00
testMapFileParser.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 
4 #define BOOST_TEST_DYN_LINK
5 
6 #define BOOST_TEST_MODULE MapFileParser
7 #include <boost/test/unit_test.hpp>
8 using namespace boost::unit_test_framework;
9 
10 #include "Exception.h"
11 #include "helperFunctions.h"
12 #include "MapFileParser.h"
14 
15 #include <sstream>
16 
17 using namespace ChimeraTK;
18 using namespace boost::unit_test_framework;
19 
20 BOOST_AUTO_TEST_SUITE(MapFileParserTestSuite)
21 
22 /**********************************************************************************************************************/
23 
24 void printRegInfo(const ChimeraTK::NumericAddressedRegisterInfo& info, std::ostream& ostr = std::cout) {
25  ostr << "Register " << info.pathName << ": at " << info.bar << "," << info.address << " nElems = " << info.nElements
26  << " pitch = " << info.elementPitchBits << " access: " << int(info.registerAccess) << " int: [";
27  for(auto i : info.interruptId) {
28  ostr << i << ",";
29  }
30  ostr << "]" << std::endl;
31  size_t ich = 0;
32  for(const auto& c : info.channels) {
33  ostr << " channel " << ich << " at: " << c.bitOffset << " " << c.width << " " << c.nFractionalBits << " "
34  << c.signedFlag << " " << int(c.dataType) << std::endl;
35  ++ich;
36  }
37 }
38 
39 /**********************************************************************************************************************/
40 
42  const std::vector<ChimeraTK::NumericAddressedRegisterInfo>& RegisterInfoents) {
43  // first check that size is equal
44  BOOST_CHECK_EQUAL(regcat.getNumberOfRegisters(), RegisterInfoents.size());
45 
46  // compare and check for same order of elements
47  auto mapIter = regcat.begin();
48  auto elementsIter = RegisterInfoents.begin();
49  for(; mapIter != regcat.end() && elementsIter != RegisterInfoents.end(); ++mapIter, ++elementsIter) {
50  std::stringstream message;
51  message << "Failed comparison:" << std::endl;
52  printRegInfo(*mapIter, message);
53  printRegInfo(*elementsIter, message);
54  BOOST_CHECK_MESSAGE(*mapIter == *elementsIter, message.str());
55  }
56 }
57 
58 /**********************************************************************************************************************/
59 /**********************************************************************************************************************/
60 
61 BOOST_AUTO_TEST_CASE(testFileDoesNotExist) {
62  ChimeraTK::MapFileParser fileparser;
63  BOOST_CHECK_THROW(fileparser.parse("NonexistentFile.map"), ChimeraTK::logic_error);
64 }
65 
66 /**********************************************************************************************************************/
67 
68 BOOST_AUTO_TEST_CASE(testInvalidMetadata) {
69  ChimeraTK::MapFileParser map_file_parser;
70  BOOST_CHECK_THROW(map_file_parser.parse("invalid_metadata.map"), ChimeraTK::logic_error);
71 }
72 
73 /**********************************************************************************************************************/
74 
75 BOOST_AUTO_TEST_CASE(testMandatoryRegisterFieldMissing) {
76  ChimeraTK::MapFileParser map_file_parser;
77  BOOST_CHECK_THROW(map_file_parser.parse("MandatoryRegisterfIeldMissing.map"), ChimeraTK::logic_error);
78 }
79 
80 /**********************************************************************************************************************/
81 
82 BOOST_AUTO_TEST_CASE(testIncorrectRegisterWidth) {
83  ChimeraTK::MapFileParser map_file_parser;
84  BOOST_CHECK_THROW(map_file_parser.parse("IncorrectRegisterWidth.map"), ChimeraTK::logic_error);
85 }
86 
87 /**********************************************************************************************************************/
88 
89 BOOST_AUTO_TEST_CASE(testFracBits) {
90  ChimeraTK::MapFileParser map_file_parser1;
91  ChimeraTK::MapFileParser map_file_parser2;
92  BOOST_CHECK_THROW(map_file_parser1.parse("IncorrectFracBits1.map"), ChimeraTK::logic_error);
93  BOOST_CHECK_THROW(map_file_parser2.parse("IncorrectFracBits2.map"), ChimeraTK::logic_error);
94 }
95 
96 /**********************************************************************************************************************/
97 
98 BOOST_AUTO_TEST_CASE(testGoodMapFileParse) {
99  ChimeraTK::MapFileParser map_file_parser;
100  auto [regcat, mdcat] = map_file_parser.parse("goodMapFile_withoutModules.map");
101 
102  std::string metaDataNameToRetrieve;
103  std::string retrievedValue;
104 
105  metaDataNameToRetrieve = "HW_VERSION";
106  retrievedValue = mdcat.getMetadata(metaDataNameToRetrieve);
107  BOOST_CHECK(retrievedValue == "1.6");
108 
109  metaDataNameToRetrieve = "FW_VERSION";
110  retrievedValue = mdcat.getMetadata(metaDataNameToRetrieve);
111  BOOST_CHECK(retrievedValue == "2.5");
112 
113  /* TODO: remove default assignments to unused fields in the parse
114  * function and move it all to the constructor */
115 
116  std::vector<ChimeraTK::NumericAddressedRegisterInfo> RegisterInfoents;
117  RegisterInfoents.emplace_back("WORD_FIRMWARE", 0x00000001, 0x00000000, 0x00000004, 0x0, 32, 0, true);
118  RegisterInfoents.emplace_back("WORD_COMPILATION", 0x00000001, 0x00000004, 0x00000004, 0x00000000, 32, 0, true);
119  RegisterInfoents.emplace_back("WORD_STATUS", 0x00000001, 0x00000008, 0x00000004, 0x00000000, 32, 0, true);
120  RegisterInfoents.emplace_back("WORD_USER1", 0x00000001, 0x0000000C, 0x00000004, 0x00000000, 32, 0, true);
121  RegisterInfoents.emplace_back("WORD_USER2", 0x00000001, 0x00000010, 0x00000004, 0x00000000, 32, 0, false);
122 
123  RegisterInfoents.emplace_back(ChimeraTK::NumericAddressedRegisterInfo("INT2D", 0x0, 0x0, 0x05, 96,
124  {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, false},
125  {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, false},
126  {64, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, false}},
127  NumericAddressedRegisterInfo::Access::READ_WRITE, {}));
128 
129  RegisterInfoents.emplace_back(
130  ChimeraTK::NumericAddressedRegisterInfo("INT2D.MULTIPLEXED_RAW", 0x0f, 0x0, 0x3c, 0x0, 32, 0, true,
131  NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {}));
132 
133  compareCatalogue(regcat, RegisterInfoents);
134 }
135 
136 /**********************************************************************************************************************/
137 
138 BOOST_AUTO_TEST_CASE(testGoodMappFileParse) {
139  ChimeraTK::MapFileParser map_file_parser;
140  auto [regcat, mdcat] = map_file_parser.parse("goodMapFile.map");
141 
142  BOOST_CHECK_EQUAL(regcat.getNumberOfRegisters(), 22);
143 
144  std::string metaDataNameToRetrieve;
145  std::string retrievedValue;
146 
147  metaDataNameToRetrieve = "HW_VERSION";
148  retrievedValue = mdcat.getMetadata(metaDataNameToRetrieve);
149  BOOST_CHECK(retrievedValue == "1.6");
150 
151  metaDataNameToRetrieve = "FW_VERSION";
152  retrievedValue = mdcat.getMetadata(metaDataNameToRetrieve);
153  BOOST_CHECK(retrievedValue == "2.5");
154 
155  std::vector<ChimeraTK::NumericAddressedRegisterInfo> RegisterInfoents(22);
156 
157  RegisterInfoents[0] =
158  ChimeraTK::NumericAddressedRegisterInfo("BOARD.WORD_FIRMWARE", 0x01, 0x0, 0x04, 0x0, 32, 0, true);
159  RegisterInfoents[1] =
160  ChimeraTK::NumericAddressedRegisterInfo("BOARD.WORD_COMPILATION", 0x01, 0x04, 0x04, 0x0, 32, 0, true);
161  RegisterInfoents[2] =
162  ChimeraTK::NumericAddressedRegisterInfo("APP0.WORD_STATUS", 0x01, 0x08, 0x04, 0x01, 32, 0, true);
163  RegisterInfoents[3] =
164  ChimeraTK::NumericAddressedRegisterInfo("APP0.WORD_SCRATCH", 0x01, 0x08, 0x04, 0x01, 16, 0, true);
165  RegisterInfoents[4] = ChimeraTK::NumericAddressedRegisterInfo("APP0.MODULE0", 0x03, 0x10, 0x0C, 0x01, 32, 0, true);
166  RegisterInfoents[5] = ChimeraTK::NumericAddressedRegisterInfo("APP0.MODULE1", 0x03, 0x20, 0x0C, 0x01, 32, 0, true);
167  RegisterInfoents[6] =
168  ChimeraTK::NumericAddressedRegisterInfo("MODULE0.WORD_USER1", 0x01, 0x10, 0x04, 0x01, 16, 3, true);
169  RegisterInfoents[7] =
170  ChimeraTK::NumericAddressedRegisterInfo("MODULE0.WORD_USER2", 0x01, 0x14, 0x04, 0x01, 18, 5, false);
171  RegisterInfoents[8] =
172  ChimeraTK::NumericAddressedRegisterInfo("MODULE0.WORD_USER3", 0x01, 0x18, 0x04, 0x01, 18, 5, false);
173  RegisterInfoents[9] =
174  ChimeraTK::NumericAddressedRegisterInfo("MODULE1.WORD_USER1", 0x01, 0x20, 0x04, 0x01, 16, 3, true);
175  RegisterInfoents[10] =
176  ChimeraTK::NumericAddressedRegisterInfo("MODULE1.WORD_USER2", 0x01, 0x24, 0x04, 0x01, 18, 5, false);
177  RegisterInfoents[11] = ChimeraTK::NumericAddressedRegisterInfo(
178  "MODULE1.WORD_USER3", 0x01, 0x28, 0x04, 0x01, 18, 5, false, NumericAddressedRegisterInfo::Access::READ_ONLY);
179  RegisterInfoents[12] =
180  ChimeraTK::NumericAddressedRegisterInfo("MODULE2.NO_OPTIONAL", 0x01, 0x2C, 0x04, 0x01, 32, 0, true);
181  RegisterInfoents[13] =
182  ChimeraTK::NumericAddressedRegisterInfo("MODULE.NAME.WITH.DOTS.REGISTER", 0x01, 0x00, 0x04, 0x02, 32, 0, true);
183  RegisterInfoents[14] =
184  ChimeraTK::NumericAddressedRegisterInfo("MODULE1.TEST_AREA", 0x0A, 0x025, 0x028, 0x01, 32, 0, false);
185  RegisterInfoents[15] = ChimeraTK::NumericAddressedRegisterInfo("FLOAT_TEST.SCALAR", 0x01, 0x060, 0x04, 0x01, 32, 0,
186  true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::IEEE754);
187  RegisterInfoents[16] = ChimeraTK::NumericAddressedRegisterInfo("FLOAT_TEST.ARRAY", 0x04, 0x064, 0x010, 0x01, 32, 0,
188  true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::IEEE754);
189  RegisterInfoents[17] =
190  ChimeraTK::NumericAddressedRegisterInfo("BOARD.NO_OPTIONAL", 0x01, 0x08, 0x04, 0x0, 32, 0, true);
191  RegisterInfoents[18] =
192  ChimeraTK::NumericAddressedRegisterInfo("LARGE_BAR.NUMBER", 0x01, 0x0, 0x04, 0x100000000, 32, 0, true);
193  RegisterInfoents[19] = ChimeraTK::NumericAddressedRegisterInfo("MODULE0.INTERRUPT_VOID1", 0x00, 0x0, 0x00, 0, 0, 0,
194  false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {3});
195  RegisterInfoents[20] = ChimeraTK::NumericAddressedRegisterInfo("MODULE0.INTERRUPT_VOID2", 0x00, 0x0, 0x00, 0, 0, 0,
196  false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {2});
197  RegisterInfoents[21] = ChimeraTK::NumericAddressedRegisterInfo("MODULE0.INTERRUPT_TYPE", 0x01, 0x68, 0x04, 1, 18, 5,
198  false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {6});
199 
200  compareCatalogue(regcat, RegisterInfoents);
201 }
202 
203 /**********************************************************************************************************************/
204 
205 BOOST_AUTO_TEST_CASE(testMixedMapFileParse) {
206  ChimeraTK::MapFileParser map_file_parser;
207  auto [regcat, mdcat] = map_file_parser.parse("mixedMapFile.map");
208 
209  std::vector<ChimeraTK::NumericAddressedRegisterInfo> RegisterInfoents(4);
210 
211  RegisterInfoents[0] = ChimeraTK::NumericAddressedRegisterInfo("WORD_FIRMWARE_ID", 0x01, 0x0, 0x04, 0x0, 32, 0, true);
212  RegisterInfoents[1] = ChimeraTK::NumericAddressedRegisterInfo("WORD_USER", 0x01, 0x4, 0x04, 0x0, 32, 0, true);
213  RegisterInfoents[2] = ChimeraTK::NumericAddressedRegisterInfo("APP0.MODULE_ID", 0x01, 0x0, 0x04, 0x1, 32, 0, true);
214  RegisterInfoents[3] = ChimeraTK::NumericAddressedRegisterInfo("APP0.WORD_USER", 0x03, 0x4, 0x0C, 0x1, 18, 3, false);
215 
216  compareCatalogue(regcat, RegisterInfoents);
217 }
218 
219 /**********************************************************************************************************************/
220 
221 BOOST_AUTO_TEST_CASE(testInterruptBadMapFileParse) {
222  ChimeraTK::MapFileParser fileparser;
223 
224  BOOST_CHECK_THROW(fileparser.parse("interruptMapFileWithError1.map"), ChimeraTK::logic_error);
225  BOOST_CHECK_THROW(fileparser.parse("interruptMapFileWithError2.map"), ChimeraTK::logic_error);
226  BOOST_CHECK_THROW(fileparser.parse("interruptMapFileWithError3.map"), ChimeraTK::logic_error);
227  BOOST_CHECK_THROW(fileparser.parse("interruptMapFileWithError4.map"), ChimeraTK::logic_error);
228 }
229 
230 /**********************************************************************************************************************/
231 
232 BOOST_AUTO_TEST_CASE(testInterruptMapFileParse) {
233  ChimeraTK::MapFileParser fileparser;
234  auto [regcat, mdcat] = fileparser.parse("interruptMapFile.map");
235 
236  std::vector<ChimeraTK::NumericAddressedRegisterInfo> RegisterInfoents(13);
237 
238  RegisterInfoents[0] = ChimeraTK::NumericAddressedRegisterInfo("APP0.INTERRUPT_VOID_1", 0x00, 0x0, 0x00, 0x0, 0, 0,
239  false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {0});
240 
241  RegisterInfoents[1] = ChimeraTK::NumericAddressedRegisterInfo("APP0.INTERRUPT_VOID_2", 0x00, 0x0, 0x00, 0x0, 0, 0,
242  false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {1, 1});
243 
244  RegisterInfoents[2] = ChimeraTK::NumericAddressedRegisterInfo("APP0.INTERRUPT_VOID_3", 0x00, 0x0, 0x00, 0x0, 0, 0,
245  false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {2, 2, 2});
246 
247  RegisterInfoents[3] = ChimeraTK::NumericAddressedRegisterInfo("APP0.INTERRUPT_UINT_1", 0x01, 0x100, 0x04, 0x0, 32, 0,
248  false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {20});
249 
250  RegisterInfoents[4] =
251  ChimeraTK::NumericAddressedRegisterInfo("APP0.SUB_INTERRUPT_INT_1", 0x01, 0x104, 0x04, 0x0, 32, 0, true,
252  NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {21, 1});
253 
254  RegisterInfoents[5] =
255  ChimeraTK::NumericAddressedRegisterInfo("APP0.SUB_SUB_INTERRUPT_INT_2", 0x01, 0x108, 0x04, 0x0, 32, 0, true,
256  NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {22, 3, 4});
257 
258  RegisterInfoents[6] =
259  ChimeraTK::NumericAddressedRegisterInfo("APP0.INTERRUPT_FIXPOINT_SIGNED", 0x01, 0x200, 0x04, 0x0, 32, 24, true,
260  NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {3});
261 
262  RegisterInfoents[7] =
263  ChimeraTK::NumericAddressedRegisterInfo("APP0.INTERRUPT_FIXPOINT_UNSIGNED", 0x01, 0x220, 0x04, 0x0, 32, 24, false,
264  NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {3});
265 
266  RegisterInfoents[8] = ChimeraTK::NumericAddressedRegisterInfo("APP0.INTERRUPT_ARRAY_UINT", 0x03, 0x300, 12, 0x0, 32,
267  0, false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {4});
268 
269  RegisterInfoents[9] = ChimeraTK::NumericAddressedRegisterInfo("APP0.INTERRUPT_ARRAY_INT", 0x03, 0x400, 12, 0x0, 32, 0,
270  true, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {4});
271 
272  RegisterInfoents[10] =
273  ChimeraTK::NumericAddressedRegisterInfo("APP0.INTERRUPT_ARRAY_FIXPOINT", 0x03, 0x500, 12, 0x0, 32, 24, false,
274  NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {4});
275 
276  RegisterInfoents[11] = ChimeraTK::NumericAddressedRegisterInfo("APP0.INTERRUPT_AREA_INT", 0x0, 0x0, 0x05, 96,
277  {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, false},
278  {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, false},
279  {64, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, false}},
280  NumericAddressedRegisterInfo::Access::INTERRUPT, {5});
281 
282  RegisterInfoents[12] =
283  ChimeraTK::NumericAddressedRegisterInfo("APP0.INTERRUPT_AREA_INT.MULTIPLEXED_RAW", 0x0f, 0x0, 0x3c, 0x0, 32, 0,
284  true, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {5});
285 
286  compareCatalogue(regcat, RegisterInfoents);
287 }
288 
289 /**********************************************************************************************************************/
290 
291 BOOST_AUTO_TEST_CASE(testMapFileWithCommentsParse) {
292  ChimeraTK::MapFileParser map_file_parser;
293  auto [regcat, mdcat] = map_file_parser.parse("goodMapFileWithComments.map");
294 
295  BOOST_CHECK_EQUAL(regcat.getNumberOfRegisters(), 22);
296 
297  std::string metaDataNameToRetrieve;
298  std::string retrievedValue;
299 
300  metaDataNameToRetrieve = "HW_VERSION";
301  retrievedValue = mdcat.getMetadata(metaDataNameToRetrieve);
302  BOOST_CHECK(retrievedValue == "1.6");
303 
304  metaDataNameToRetrieve = "FW_VERSION";
305  retrievedValue = mdcat.getMetadata(metaDataNameToRetrieve);
306  BOOST_CHECK(retrievedValue == "2.5");
307 
308  std::vector<ChimeraTK::NumericAddressedRegisterInfo> RegisterInfoents(22);
309 
310  RegisterInfoents[0] =
311  ChimeraTK::NumericAddressedRegisterInfo("BOARD.WORD_FIRMWARE", 0x01, 0x0, 0x04, 0x0, 32, 0, true);
312  RegisterInfoents[1] =
313  ChimeraTK::NumericAddressedRegisterInfo("BOARD.WORD_COMPILATION", 0x01, 0x04, 0x04, 0x0, 32, 0, true);
314  RegisterInfoents[2] =
315  ChimeraTK::NumericAddressedRegisterInfo("APP0.WORD_STATUS", 0x01, 0x08, 0x04, 0x01, 32, 0, true);
316  RegisterInfoents[3] =
317  ChimeraTK::NumericAddressedRegisterInfo("APP0.WORD_SCRATCH", 0x01, 0x08, 0x04, 0x01, 16, 0, true);
318  RegisterInfoents[4] = ChimeraTK::NumericAddressedRegisterInfo("APP0.MODULE0", 0x03, 0x10, 0x0C, 0x01, 32, 0, true);
319  RegisterInfoents[5] = ChimeraTK::NumericAddressedRegisterInfo("APP0.MODULE1", 0x03, 0x20, 0x0C, 0x01, 32, 0, true);
320  RegisterInfoents[6] =
321  ChimeraTK::NumericAddressedRegisterInfo("MODULE0.WORD_USER1", 0x01, 0x10, 0x04, 0x01, 16, 3, true);
322  RegisterInfoents[7] =
323  ChimeraTK::NumericAddressedRegisterInfo("MODULE0.WORD_USER2", 0x01, 0x14, 0x04, 0x01, 18, 5, false);
324  RegisterInfoents[8] =
325  ChimeraTK::NumericAddressedRegisterInfo("MODULE0.WORD_USER3", 0x01, 0x18, 0x04, 0x01, 18, 5, false);
326  RegisterInfoents[9] =
327  ChimeraTK::NumericAddressedRegisterInfo("MODULE1.WORD_USER1", 0x01, 0x20, 0x04, 0x01, 16, 3, true);
328  RegisterInfoents[10] =
329  ChimeraTK::NumericAddressedRegisterInfo("MODULE1.WORD_USER2", 0x01, 0x24, 0x04, 0x01, 18, 5, false);
330  RegisterInfoents[11] = ChimeraTK::NumericAddressedRegisterInfo(
331  "MODULE1.WORD_USER3", 0x01, 0x28, 0x04, 0x01, 18, 5, false, NumericAddressedRegisterInfo::Access::READ_ONLY);
332  RegisterInfoents[12] =
333  ChimeraTK::NumericAddressedRegisterInfo("MODULE2.NO_OPTIONAL", 0x01, 0x2C, 0x04, 0x01, 32, 0, true);
334  RegisterInfoents[13] =
335  ChimeraTK::NumericAddressedRegisterInfo("MODULE.NAME.WITH.DOTS.REGISTER", 0x01, 0x00, 0x04, 0x02, 32, 0, true);
336  RegisterInfoents[14] =
337  ChimeraTK::NumericAddressedRegisterInfo("MODULE1.TEST_AREA", 0x0A, 0x025, 0x028, 0x01, 32, 0, false);
338  RegisterInfoents[15] = ChimeraTK::NumericAddressedRegisterInfo("FLOAT_TEST.SCALAR", 0x01, 0x060, 0x04, 0x01, 32, 0,
339  true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::IEEE754);
340  RegisterInfoents[16] = ChimeraTK::NumericAddressedRegisterInfo("FLOAT_TEST.ARRAY", 0x04, 0x064, 0x010, 0x01, 32, 0,
341  true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::IEEE754);
342  RegisterInfoents[17] =
343  ChimeraTK::NumericAddressedRegisterInfo("BOARD.NO_OPTIONAL", 0x01, 0x08, 0x04, 0x0, 32, 0, true);
344  RegisterInfoents[18] =
345  ChimeraTK::NumericAddressedRegisterInfo("LARGE_BAR.NUMBER", 0x01, 0x0, 0x04, 0x100000000, 32, 0, true);
346  RegisterInfoents[19] = ChimeraTK::NumericAddressedRegisterInfo("MODULE0.INTERRUPT_VOID1", 0x00, 0x0, 0x00, 0, 0, 0,
347  false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {1, 3});
348  RegisterInfoents[20] = ChimeraTK::NumericAddressedRegisterInfo("MODULE0.INTERRUPT_VOID2", 0x00, 0x0, 0x00, 0, 0, 0,
349  false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::VOID, {1, 2});
350  RegisterInfoents[21] = ChimeraTK::NumericAddressedRegisterInfo("MODULE0.INTERRUPT_TYPE", 0x01, 0x68, 0x04, 1, 18, 5,
351  false, NumericAddressedRegisterInfo::Access::INTERRUPT, NumericAddressedRegisterInfo::Type::FIXED_POINT, {5, 6});
352 
353  compareCatalogue(regcat, RegisterInfoents);
354 }
355 
356 /**********************************************************************************************************************/
357 
358 BOOST_AUTO_TEST_CASE(testMapFileNewStyleMuxed) {
359  ChimeraTK::MapFileParser map_file_parser;
360  auto [regcat, mdcat] = map_file_parser.parse("newSequences.mapp");
361 
362  BOOST_CHECK_EQUAL(regcat.getNumberOfRegisters(), 18);
363 
364  std::vector<ChimeraTK::NumericAddressedRegisterInfo> RegisterInfoents(18);
365  RegisterInfoents[0] = ChimeraTK::NumericAddressedRegisterInfo("TEST.INT", 0x0, 0x0, 0x05, 96,
366  {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0, true},
367  {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0, true},
368  {64, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0, true}},
369  NumericAddressedRegisterInfo::Access::READ_WRITE, {});
370 
371  RegisterInfoents[1] = ChimeraTK::NumericAddressedRegisterInfo("TEST.INT.MULTIPLEXED_RAW", 0x0f, 0x0, 0x3c, 0x0, 32, 0,
372  true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
373 
374  RegisterInfoents[2] = ChimeraTK::NumericAddressedRegisterInfo("TEST.CHAR", 0x0, 0x40, 0x05, 24,
375  {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0, true},
376  {8, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0, true},
377  {16, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0, true}},
378  NumericAddressedRegisterInfo::Access::READ_WRITE, {});
379 
380  RegisterInfoents[3] = ChimeraTK::NumericAddressedRegisterInfo("TEST.CHAR.MULTIPLEXED_RAW", 0x04, 0x40, 0x10, 0x0, 32,
381  0, true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
382 
383  RegisterInfoents[4] = ChimeraTK::NumericAddressedRegisterInfo("TEST.SHORT", 0x0, 0x50, 0x05, 48,
384  {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, true},
385  {16, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, true},
386  {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, true}},
387  NumericAddressedRegisterInfo::Access::READ_WRITE, {});
388 
389  RegisterInfoents[5] = ChimeraTK::NumericAddressedRegisterInfo("TEST.SHORT.MULTIPLEXED_RAW", 0x08, 0x50, 0x20, 0x0, 32,
390  0, true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
391 
392  RegisterInfoents[6] = ChimeraTK::NumericAddressedRegisterInfo("TEST.FRAC_INT", 0x1, 0x0, 0x05, 96,
393  {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 1, true},
394  {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 2, true},
395  {64, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 3, true}},
396  NumericAddressedRegisterInfo::Access::READ_WRITE, {});
397 
398  RegisterInfoents[7] =
399  ChimeraTK::NumericAddressedRegisterInfo("TEST.FRAC_INT.MULTIPLEXED_RAW", 0x0f, 0x0, 0x3c, 0x01, 32, 0, true,
400  NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
401 
402  RegisterInfoents[8] = ChimeraTK::NumericAddressedRegisterInfo("TEST.FRAC_CHAR", 0x1, 0x40, 0x05, 24,
403  {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 1, true},
404  {8, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 2, true},
405  {16, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 3, true}},
406  NumericAddressedRegisterInfo::Access::READ_WRITE, {});
407 
408  RegisterInfoents[9] =
409  ChimeraTK::NumericAddressedRegisterInfo("TEST.FRAC_CHAR.MULTIPLEXED_RAW", 0x04, 0x40, 0x10, 0x01, 32, 0, true,
410  NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
411 
412  RegisterInfoents[10] = ChimeraTK::NumericAddressedRegisterInfo("TEST.FRAC_SHORT", 0x1, 0x50, 0x05, 48,
413  {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 1, true},
414  {16, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 2, true},
415  {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 3, true}},
416  NumericAddressedRegisterInfo::Access::READ_WRITE, {});
417 
418  RegisterInfoents[11] =
419  ChimeraTK::NumericAddressedRegisterInfo("TEST.FRAC_SHORT.MULTIPLEXED_RAW", 0x08, 0x50, 0x20, 0x01, 32, 0, true,
420  NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
421 
422  RegisterInfoents[12] = ChimeraTK::NumericAddressedRegisterInfo("TEST.DMA", 0x0d, 0x0, 0x04, 256,
423  {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
424  {16, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
425  {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
426  {48, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
427  {64, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
428  {80, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
429  {96, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
430  {112, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
431  {128, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
432  {144, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
433  {160, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
434  {176, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
435  {192, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
436  {208, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
437  {224, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true},
438  {240, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, -2, true}},
439  NumericAddressedRegisterInfo::Access::READ_WRITE, {});
440 
441  RegisterInfoents[13] = ChimeraTK::NumericAddressedRegisterInfo("TEST.DMA.MULTIPLEXED_RAW", 0x20, 0x00, 0x80, 0x0d, 32,
442  0, true, NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
443 
444  RegisterInfoents[14] = ChimeraTK::NumericAddressedRegisterInfo("TEST.MIXED", 0x3, 0x00, 0x03, 56,
445  {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0, true},
446  {8, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, true},
447  {24, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0, true}},
448  NumericAddressedRegisterInfo::Access::READ_WRITE, {});
449 
450  RegisterInfoents[15] =
451  ChimeraTK::NumericAddressedRegisterInfo("TEST.MIXED.MULTIPLEXED_RAW", 0x06, 0x00, 0x18, 0x03, 32, 0, true,
452  NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
453 
454  RegisterInfoents[16] = ChimeraTK::NumericAddressedRegisterInfo("APP0.DAQ0_BAM", 0x02, 0x0, 372, 352,
455  {{0, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, true},
456  {16, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, true},
457  {32, NumericAddressedRegisterInfo::Type::FIXED_POINT, 18, 0, true},
458  {64, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, true},
459  {80, NumericAddressedRegisterInfo::Type::FIXED_POINT, 16, 0, true},
460  {96, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0, true},
461  {112, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0, true},
462  {128, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0, true},
463  {136, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0, true},
464  {144, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0, true},
465  {152, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0, true},
466  {160, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0, true},
467  {192, NumericAddressedRegisterInfo::Type::FIXED_POINT, 8, 0, true},
468  {224, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0, true},
469  {256, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0, false},
470  {288, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0, false},
471  {320, NumericAddressedRegisterInfo::Type::FIXED_POINT, 32, 0, false}},
472  NumericAddressedRegisterInfo::Access::READ_WRITE, {});
473 
474  RegisterInfoents[17] =
475  ChimeraTK::NumericAddressedRegisterInfo("APP0.DAQ0_BAM.MULTIPLEXED_RAW", 0x1000, 0x00, 0x4000, 0x02, 32, 0, true,
476  NumericAddressedRegisterInfo::Access::READ_WRITE, NumericAddressedRegisterInfo::Type::FIXED_POINT, {});
477 
478  compareCatalogue(regcat, RegisterInfoents);
479 }
480 
481 /**********************************************************************************************************************/
482 
483 BOOST_AUTO_TEST_SUITE_END()
helperFunctions.h
MapFileParser.h
ChimeraTK::NumericAddressedRegisterInfo
Definition: NumericAddressedRegisterCatalogue.h:15
ChimeraTK::BackendRegisterCatalogue::end
BackendRegisterCatalogueImplIterator< BackendRegisterInfo > end()
Return end iterator for iterating through the registers in the catalogue.
Definition: BackendRegisterCatalogue.h:117
ChimeraTK::MapFileParser
Provides method to parse MAP file.
Definition: MapFileParser.h:21
compareCatalogue
void compareCatalogue(const NumericAddressedRegisterCatalogue &regcat, const std::vector< ChimeraTK::NumericAddressedRegisterInfo > &RegisterInfoents)
Definition: testMapFileParser.cpp:41
NumericAddressedRegisterCatalogue.h
ChimeraTK::NumericAddressedRegisterCatalogue
Definition: NumericAddressedRegisterCatalogue.h:136
Exception.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(testFileDoesNotExist)
Definition: testMapFileParser.cpp:61
ChimeraTK
Definition: DummyBackend.h:16
ChimeraTK::BackendRegisterCatalogue::getNumberOfRegisters
size_t getNumberOfRegisters() const override
Get number of registers in the catalogue.
Definition: BackendRegisterCatalogue.h:281
ChimeraTK::logic_error
Exception thrown when a logic error has occured.
Definition: Exception.h:51
ChimeraTK::BackendRegisterCatalogue::begin
BackendRegisterCatalogueImplIterator< BackendRegisterInfo > begin()
Return begin iterator for iterating through the registers in the catalogue.
Definition: BackendRegisterCatalogue.h:112
ChimeraTK::MapFileParser::parse
std::pair< NumericAddressedRegisterCatalogue, MetadataCatalogue > parse(const std::string &file_name)
Performs parsing of specified MAP file.
Definition: MapFileParser.cpp:19
printRegInfo
void printRegInfo(const ChimeraTK::NumericAddressedRegisterInfo &info, std::ostream &ostr=std::cout)
Definition: testMapFileParser.cpp:24