LCOV - code coverage report
Current view: top level - mu2e-pcie-utils/cfoInterfaceLib - CFO_Compiler.hh (source / functions) Coverage Total Hit
Test: mu2edaq.info.cleaned Lines: 0.0 % 2 0
Test Date: 2026-07-30 01:56:44 Functions: 0.0 % 2 0

            Line data    Source code
       1              : #ifndef CFOINTERFACELIB_MU2ECOMPILER_HH
       2              : #define CFOINTERFACELIB_MU2ECOMPILER_HH
       3              : 
       4              : #include <algorithm>
       5              : #include <cctype>
       6              : #include <deque>
       7              : #include <fstream>
       8              : #include <locale>
       9              : #include <map>
      10              : #include <memory>
      11              : #include <sstream>
      12              : #include <string>
      13              : #include <vector>
      14              : 
      15              : #ifndef __CLING__
      16              : #include "tracemf.h"
      17              : #endif
      18              : 
      19              : /// <summary>
      20              : /// The CFO Namespace
      21              : /// </summary>
      22              : namespace CFOLib
      23              : {
      24              : 
      25              : /// <summary>
      26              : /// The CFO Compiler class
      27              : /// </summary>
      28              : class CFO_Compiler
      29              : {
      30              :   public:
      31              :         /// <summary>
      32              :         /// Instruction names
      33              :         /// </summary>
      34              :         enum class CFO_INSTR : uint8_t
      35              :         {
      36              :                 NOOP                    = 0,  // also used for LABEL
      37              :                 HEARTBEAT               = 1,
      38              :                 MARKER                  = 10,  // Event Marker 0x1C10-0x1CEF
      39              :                 DATA_REQUEST            = 2,
      40              :                 SET_TAG                 = 3,
      41              :                 INC_TAG                 = 4,
      42              :                 WAIT                    = 5,  // before a MARKER op, to declare how long previous event window should last (i.e. NEXT RF-0, or a time in clocks)
      43              :                 LOOP                    = 6,
      44              :                 DO_LOOP                 = 7,
      45              :                 REPEAT                  = 8,
      46              :                 END                     = 9,
      47              :                 GOTO                    = 11,
      48              :                 LABEL                   = 12,
      49              :                 CLEAR_MODE_BITS         = 100,  // used by HEARTBEAT w/param 'event_mode = registered'
      50              :                 SET_MODE_BITS           = 101,  // used by HEARTBEAT w/param 'event_mode = registered'
      51              :                 AND_MODE_BITS           = 102,  // used by HEARTBEAT w/param 'event_mode = registered'
      52              :                 OR_MODE_BITS            = 103,  // used by HEARTBEAT w/param 'event_mode = registered'
      53              :                 OR_SINGLESHOT_MODE_BITS = 111,  // single-shot OR; identical to OR but fires only once in hardware
      54              :                 SET_MODE                = 200,  // used by HEARTBEAT w/param 'event_mode = registered'
      55              :                 INVALID                 = 0xFF,
      56              :         };
      57              : 
      58              :         static const std::string                                            MAIN_GOTO_LABEL;
      59              :         static const std::map<uint8_t, std::string>                         CODE_to_OP_TRANSLATION;
      60              :         static const std::map<std::string, CFOLib::CFO_Compiler::CFO_INSTR> OP_to_CODE_TRANSLATION;
      61              : 
      62              :   public:
      63            0 :         CFO_Compiler(){};
      64            0 :         ~CFO_Compiler(){};
      65              : 
      66              :         std::string             processFile(const std::string& sourceCodeFile, const std::string& binaryOutputFile);
      67              :         const std::deque<char>& getBinaryOutput() { return output_; }
      68              : 
      69              :         static const uint64_t FPGAClock_;  // period of FPGA clock in ns
      70              :   private:
      71              :         bool isComment(const std::string& line);
      72              : 
      73              :         CFO_INSTR          parseInstruction(const std::string& instructionBuffer);
      74              :         const std::string& translateOpCode(CFO_INSTR);
      75              :         void               processOp(void);
      76              :         uint64_t           calculateParameterAndErrorCheck(CFO_INSTR);
      77              :         void               outParameter(uint64_t);
      78              : 
      79              :         std::vector<uint64_t /* line number */> loopStack_;
      80              :         std::map<std::string /* label */,
      81              :                  uint64_t /* line number */>
      82              :                                  labelMap_;
      83              :         uint64_t                 modeClearMask_;
      84              :         bool                     hasRequiredPlanEndOp_ = false;  // require at least one END, REPEAT, or GOTO MAIN command to give a handle on switch Run Plan buffers to the CFO firmware
      85              :         std::vector<std::string> opArguments_;
      86              : 
      87              :         size_t           txtLineNumber_, binLineNumber_;
      88              :         std::deque<char> output_;
      89              : };
      90              : 
      91              : }  // namespace CFOLib
      92              : 
      93              : #endif  // CFOINTERFACELIB_MU2ECOMPILER_HH
        

Generated by: LCOV version 2.0-1