DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::timing::MIBV2IONode Class Reference

Class for the timing FMC board. More...

#include <MIBV2IONode.hpp>

Inheritance diagram for dunedaq::timing::MIBV2IONode:
[legend]
Collaboration diagram for dunedaq::timing::MIBV2IONode:
[legend]

Public Member Functions

 MIBV2IONode (const uhal::Node &node)
 
virtual ~MIBV2IONode ()
 
std::string get_uid_address_parameter_name () const override
 Get the UID address parameter name.
 
std::string get_status (bool print_out=false) const override
 Get status string, optionally print.
 
void reset (const std::string &clock_config_file) const override
 Reset MIB v2 IO.
 
void reset (const ClockSource &clock_source) const override
 Reset IO, with clock file look up.
 
void switch_clock_source (const ClockSource &clock_source) const
 Switch clock input, with clock file look up and upload if necessary.
 
std::string get_sfp_status (uint32_t sfp_id, bool print_out=false) const override
 Print status of on-board SFP.
 
void switch_sfp_soft_tx_control_bit (uint32_t sfp_id, bool turn_on) const override
 control tx laser of on-board SFP softly (I2C command)
 
bool clocks_ok () const override
 Clocks ready?
 
void switch_sfp_tx (uint32_t sfp_id, bool turn_on) const override
 control tx laser of on-board SFP
 
- Public Member Functions inherited from dunedaq::timing::IONode
 IONode (const uhal::Node &node, std::string uid_i2c_bus, std::string pll_i2c_bus, std::string pll_i2c_device, std::vector< std::string > clock_names, std::vector< std::string > sfp_i2c_buses)
 
virtual ~IONode ()
 
virtual uint32_t read_board_type () const
 Read the word identifying the timing board.
 
virtual uint32_t read_carrier_type () const
 Read the word identifying the FPFA carrier board.
 
virtual uint32_t read_design_type () const
 Read the word identifying the firmware design in the FPGA.
 
virtual uint32_t read_firmware_frequency () const
 Read the word identifying the frequency [units of Hz] of the firmware in the FPGA.
 
virtual uint64_t read_board_uid () const
 Read the word containing the timing board UID.
 
virtual BoardRevision get_board_revision () const
 Read the word identifying the timing board.
 
virtual std::string get_hardware_info (bool print_out=false) const
 Print hardware information.
 
virtual std::string get_full_clock_config_file_path (const ClockSource &clock_source) const
 Get the full config path.
 
template<class T >
std::unique_ptr< const T > get_i2c_device (const std::string &i2c_bus_name, const std::string &i2c_device_name) const
 Get the an I2C chip.
 
virtual std::unique_ptr< const SI534xSlave > get_pll () const
 Get the PLL chip.
 
virtual void configure_pll (const std::string &clock_config_file="") const
 Configure clock chip.
 
virtual std::vector< double > read_clock_frequencies () const
 Read frequencies of on-board clocks.
 
virtual std::string get_clock_frequencies_table (bool print_out=false) const
 Print frequencies of on-board clocks.
 
virtual std::string get_pll_status (bool print_out=false) const
 Print status of on-board PLL.
 
virtual void soft_reset () const
 Reset timing node.
 
virtual void get_info (timinghardwareinfo::TimingPLLMonitorData &mon_data) const
 
- Public Member Functions inherited from dunedaq::timing::TimingNode
 TimingNode (const uhal::Node &node)
 
virtual ~TimingNode ()
 
std::map< std::string, uhal::ValWord< uint32_t > > read_sub_nodes (const uhal::Node &node, bool dispatch=true) const
 Read subnodes.
 
void reset_sub_nodes (const uhal::Node &node, uint32_t aValue=0x0, bool dispatch=true) const
 Reset subnodes.
 

Private Member Functions

void validate_sfp_id (uint32_t sfp_id) const
 Fill hardware monitoring structure.
 
void validate_amc_slot (uint32_t amc_slot) const
 

Additional Inherited Members

- Static Public Member Functions inherited from dunedaq::timing::IONode
static const std::map< BoardType, std::string > & get_board_type_map ()
 
static const std::map< CarrierType, std::string > & get_carrier_type_map ()
 
static const std::map< BoardRevision, std::string > & get_board_revision_map ()
 
static const std::map< uint64_t, BoardRevision > & get_board_uid_revision_map ()
 
static const std::map< DesignType, std::string > & get_design_type_map ()
 
static const std::map< std::string, std::string > & get_clock_config_map ()
 
static const std::vector< BoardType > & get_library_supported_boards ()
 
static const std::vector< DesignType > & get_library_supported_designs ()
 
- Protected Member Functions inherited from dunedaq::timing::IONode
virtual void write_soft_reset_register () const
 Write soft reset register.
 
- Static Protected Member Functions inherited from dunedaq::timing::IONode
static std::string clock_source_to_string (const ClockSource &source)
 
- Protected Attributes inherited from dunedaq::timing::IONode
const std::string m_uid_i2c_bus
 
const std::string m_pll_i2c_bus
 
const std::string m_pll_i2c_device
 
const std::vector< std::string > m_clock_names
 
const std::vector< std::string > m_sfp_i2c_buses
 
- Static Protected Attributes inherited from dunedaq::timing::IONode
static const std::map< BoardType, std::string > board_type_map
 
static const std::map< CarrierType, std::string > carrier_type_map
 
static const std::map< BoardRevision, std::string > board_revision_map
 
static const std::map< DesignType, std::string > design_type_map
 
static const std::map< uint64_t, BoardRevisionboard_uid_revision_map
 
static const std::map< ClockSource, std::string > clock_source_map
 
static const std::map< std::string, std::string > clock_config_map
 
static const std::vector< BoardTypelibrary_supported_boards
 
static const std::vector< DesignTypelibrary_supported_designs
 

Detailed Description

Class for the timing FMC board.

Definition at line 32 of file MIBV2IONode.hpp.

Constructor & Destructor Documentation

◆ MIBV2IONode()

dunedaq::timing::MIBV2IONode::MIBV2IONode ( const uhal::Node & node)
explicit

Definition at line 20 of file MIBV2IONode.cpp.

21 : IONode(node, "i2c", "i2c", { "PLL" }, { "OSC", "PLL", "EP 0", "EP 1", "EP 2" }, { "sfp0_i2c", "sfp1_i2c", "sfp2_i2c" })
22{
23}
IONode(const uhal::Node &node, std::string uid_i2c_bus, std::string pll_i2c_bus, std::string pll_i2c_device, std::vector< std::string > clock_names, std::vector< std::string > sfp_i2c_buses)
Definition IONode.cpp:25

◆ ~MIBV2IONode()

dunedaq::timing::MIBV2IONode::~MIBV2IONode ( )
virtual

Definition at line 27 of file MIBV2IONode.cpp.

27{}

Member Function Documentation

◆ clocks_ok()

bool dunedaq::timing::MIBV2IONode::clocks_ok ( ) const
overridevirtual

Clocks ready?

Implements dunedaq::timing::IONode.

Definition at line 117 of file MIBV2IONode.cpp.

118{
119 std::stringstream status;
120
121 auto states = read_sub_nodes(getNode("csr.stat"));
122 bool pll_ok = states.find("pll_ok")->second.value();
123 bool mmcm_ok = states.find("mmcm_ok")->second.value();
124
125 TLOG_DEBUG(5) << "pll ok: " << pll_ok << ", mmcm ok: " << mmcm_ok;
126
127 return pll_ok && mmcm_ok;
128}
std::map< std::string, uhal::ValWord< uint32_t > > read_sub_nodes(const uhal::Node &node, bool dispatch=true) const
Read subnodes.
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112

◆ get_sfp_status()

std::string dunedaq::timing::MIBV2IONode::get_sfp_status ( uint32_t sfp_id,
bool print_out = false ) const
overridevirtual

Print status of on-board SFP.

Reimplemented from dunedaq::timing::IONode.

Definition at line 98 of file MIBV2IONode.cpp.

98 { // NOLINT(build/unsigned)
99 std::stringstream status;
100
101 validate_sfp_id(sfp_id);
102
103 auto sfp = get_i2c_device<I2CSFPSlave>(m_sfp_i2c_buses.at(sfp_id), "SFP_EEProm");
104
105 status << "SFP " << sfp_id << ":" << std::endl;
106 status << sfp->get_status();
107
108 if (print_out)
109 TLOG() << status.str();
110
111 return status.str();
112}
const std::vector< std::string > m_sfp_i2c_buses
Definition IONode.hpp:204
std::unique_ptr< const T > get_i2c_device(const std::string &i2c_bus_name, const std::string &i2c_device_name) const
Get the an I2C chip.
Definition IONode.hxx:6
void validate_sfp_id(uint32_t sfp_id) const
Fill hardware monitoring structure.
#define TLOG(...)
Definition macro.hpp:22

◆ get_status()

std::string dunedaq::timing::MIBV2IONode::get_status ( bool print_out = false) const
overridevirtual

Get status string, optionally print.

Implements dunedaq::timing::TimingNode.

Definition at line 40 of file MIBV2IONode.cpp.

41{
42 std::stringstream status;
43
44 auto subnodes = read_sub_nodes(getNode("csr.stat"));
45 status << format_reg_table(subnodes, "MIB IO state");
46
47 if (print_out)
48 TLOG() << std::endl << status.str();
49 return status.str();
50}
std::string format_reg_table(T data, std::string title, std::vector< std::string > headers)
Format reg-value table.
Definition toolbox.hxx:166

◆ get_uid_address_parameter_name()

std::string dunedaq::timing::MIBV2IONode::get_uid_address_parameter_name ( ) const
overridevirtual

Get the UID address parameter name.

Returns
{ description_of_the_return_value }

Implements dunedaq::timing::IONode.

Definition at line 32 of file MIBV2IONode.cpp.

33{
34 return "UID_PROM";
35}

◆ reset() [1/2]

void dunedaq::timing::MIBV2IONode::reset ( const ClockSource & clock_source) const
overridevirtual

Reset IO, with clock file look up.

Reimplemented from dunedaq::timing::IONode.

Definition at line 76 of file MIBV2IONode.cpp.

77{
78 IONode::reset(clock_source);
79
80 switch_clock_source(clock_source);
81}
virtual void reset(const std::string &clock_config_file) const =0
Reset timing node.
void switch_clock_source(const ClockSource &clock_source) const
Switch clock input, with clock file look up and upload if necessary.

◆ reset() [2/2]

void dunedaq::timing::MIBV2IONode::reset ( const std::string & clock_config_file) const
overridevirtual

Reset MIB v2 IO.

Implements dunedaq::timing::IONode.

Definition at line 55 of file MIBV2IONode.cpp.

56{
58
59 millisleep(1000);
60
61 // Upload config file to PLL
62 configure_pll(clock_config_file);
63
64 // Reset mmcm
65 getNode("csr.ctrl.rst").write(0x1);
66 getNode("csr.ctrl.rst").write(0x0);
67
68 getClient().dispatch();
69
70 TLOG() << "Reset done";
71}
virtual void write_soft_reset_register() const
Write soft reset register.
Definition IONode.cpp:296
virtual void configure_pll(const std::string &clock_config_file="") const
Configure clock chip.
Definition IONode.cpp:247
void millisleep(const double &time_in_milliseconds)
Definition toolbox.cpp:83

◆ switch_clock_source()

void dunedaq::timing::MIBV2IONode::switch_clock_source ( const ClockSource & clock_source) const

Switch clock input, with clock file look up and upload if necessary.

Definition at line 86 of file MIBV2IONode.cpp.

87{
88 if (clock_source != kFreeRun)
89 {
90 getNode("csr.ctrl.pll_in_sel").write(clock_source);
91 getClient().dispatch();
92 }
93}

◆ switch_sfp_soft_tx_control_bit()

void dunedaq::timing::MIBV2IONode::switch_sfp_soft_tx_control_bit ( uint32_t sfp_id,
bool turn_on ) const
overridevirtual

control tx laser of on-board SFP softly (I2C command)

Reimplemented from dunedaq::timing::IONode.

Definition at line 133 of file MIBV2IONode.cpp.

133 { // NOLINT(build/unsigned)
134 validate_sfp_id(sfp_id);
135
136 auto sfp = get_i2c_device<I2CSFPSlave>(m_sfp_i2c_buses.at(sfp_id), "SFP_EEProm");
137 sfp->switch_soft_tx_control_bit(turn_on);
138}

◆ switch_sfp_tx()

void dunedaq::timing::MIBV2IONode::switch_sfp_tx ( uint32_t sfp_id,
bool turn_on ) const
overridevirtual

control tx laser of on-board SFP

Implements dunedaq::timing::IONode.

Definition at line 143 of file MIBV2IONode.cpp.

144{
145 // TODO firmware support needed
146 //validate_sfp_id(sfp_id);
147
148 //uint8_t current_sfp_tx_control_flags = getNode("csr.ctrl.sfp_tx_disable").read(); // NOLINT(build/unsigned)
149 //getClient().dispatch();
150
151 //uint8_t new_sfp_tx_control_flags; // NOLINT(build/unsigned)
152 //if (turn_on)
153 //{
154 // new_sfp_tx_control_flags = current_sfp_tx_control_flags & ~(1UL << sfp_id);
155 //}
156 //else
157 //{
158 // new_sfp_tx_control_flags = current_sfp_tx_control_flags | (1UL << sfp_id);
159 //}
160
161 //getNode("csr.ctrl.sfp_tx_disable").write(new_sfp_tx_control_flags);
162 //getClient().dispatch();
163}

◆ validate_amc_slot()

void dunedaq::timing::MIBV2IONode::validate_amc_slot ( uint32_t amc_slot) const
private

Definition at line 194 of file MIBV2IONode.cpp.

194 { // NOLINT(build/unsigned)
195 if (amc_slot < 1 || amc_slot > 12) {
196 throw InvalidAMCSlot(ERS_HERE, format_reg_value(amc_slot, 10));
197 }
198}
#define ERS_HERE
std::string format_reg_value(T reg_value, uint32_t base)
Definition toolbox.hxx:117

◆ validate_sfp_id()

void dunedaq::timing::MIBV2IONode::validate_sfp_id ( uint32_t sfp_id) const
private

Fill hardware monitoring structure.

Give info to collector.

Definition at line 184 of file MIBV2IONode.cpp.

184 { // NOLINT(build/unsigned)
185 // on this board we have 3 upstream SFPs
186 if (sfp_id > 2) {
187 throw InvalidSFPId(ERS_HERE, format_reg_value(sfp_id));
188 }
189}

The documentation for this class was generated from the following files: