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

Class for the PC059 board. More...

#include <PC059IONode.hpp>

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

Public Member Functions

 PC059IONode (const uhal::Node &node)
 
virtual ~PC059IONode ()
 
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 pc059 node.
 
void switch_sfp_mux_channel (uint32_t mux_channel) const override
 Switch the SFP mux channel.
 
uint32_t read_active_sfp_mux_channel () const override
 Read the active SFP mux channel.
 
void switch_sfp_i2c_mux_channel (uint32_t sfp_id) const
 Switch the SFP I2C mux channel.
 
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 softly (I2C command)
 
virtual void reset (const ClockSource &clock_source) const
 Reset IO, with clock file look up.
 
- Public Member Functions inherited from dunedaq::timing::SFPMuxIONode
 SFPMuxIONode (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 ~SFPMuxIONode ()
 
- 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.
 

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 PC059 board.

Definition at line 33 of file PC059IONode.hpp.

Constructor & Destructor Documentation

◆ PC059IONode()

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

Definition at line 21 of file PC059IONode.cpp.

22 : SFPMuxIONode(node, "i2c", "i2c", "SI5345", { "PLL", "CDR" }, { "usfp_i2c", "i2c" })
23{}
SFPMuxIONode(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)

◆ ~PC059IONode()

dunedaq::timing::PC059IONode::~PC059IONode ( )
virtual

Definition at line 27 of file PC059IONode.cpp.

27{}

Member Function Documentation

◆ clocks_ok()

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

Clocks ready?

Implements dunedaq::timing::IONode.

Definition at line 181 of file PC059IONode.cpp.

182{
183 std::stringstream status;
184
185 auto states = read_sub_nodes(getNode("csr.stat"));
186 bool pll_ok = states.find("pll_ok")->second.value();
187 bool mmcm_ok = states.find("mmcm_ok")->second.value();
188
189 TLOG_DEBUG(5) << "pll ok: " << pll_ok << ", mmcm ok: " << mmcm_ok;
190
191 return pll_ok && mmcm_ok;
192}
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::PC059IONode::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 154 of file PC059IONode.cpp.

155{
156 // on this board the upstream sfp has its own i2c bus, and the 8 downstream sfps are muxed onto the main i2c bus
157 std::stringstream status;
158 uint32_t sfp_bus_index; // NOLINT(build/unsigned)
159 if (sfp_id == 0) {
160 sfp_bus_index = 0;
161 status << "Upstream SFP:" << std::endl;
162 } else if (sfp_id > 0 && sfp_id < 9) {
163 switch_sfp_i2c_mux_channel(sfp_id - 1);
164 status << "Fanout SFP " << sfp_id - 1 << ":" << std::endl;
165 sfp_bus_index = 1;
166 } else {
167 throw InvalidSFPId(ERS_HERE, format_reg_value(sfp_id));
168 }
169 auto sfp = get_i2c_device<I2CSFPSlave>(m_sfp_i2c_buses.at(sfp_bus_index), "SFP_EEProm");
170
171 status << sfp->get_status();
172
173 if (print_out)
174 TLOG() << status.str();
175 return status.str();
176}
#define ERS_HERE
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 switch_sfp_i2c_mux_channel(uint32_t sfp_id) const
Switch the SFP I2C mux channel.
#define TLOG(...)
Definition macro.hpp:22
std::string format_reg_value(T reg_value, uint32_t base)
Definition toolbox.hxx:117

◆ get_status()

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

Get status string, optionally print.

Implements dunedaq::timing::TimingNode.

Definition at line 40 of file PC059IONode.cpp.

41{
42 std::stringstream status;
43 auto subnodes = read_sub_nodes(getNode("csr.stat"));
44 status << format_reg_table(subnodes, "PC059 IO state");
45
46 if (print_out)
47 TLOG() << std::endl << status.str();
48 return status.str();
49}
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::PC059IONode::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 PC059IONode.cpp.

33{
34 return "FMC_UID_PROM";
35}

◆ read_active_sfp_mux_channel()

uint32_t dunedaq::timing::PC059IONode::read_active_sfp_mux_channel ( ) const
overridevirtual

Read the active SFP mux channel.

Implements dunedaq::timing::SFPMuxIONode.

Definition at line 127 of file PC059IONode.cpp.

128{
129 auto active_sfp_mux_channel = getNode("csr.ctrl.mux").read();
130 getClient().dispatch();
131 return active_sfp_mux_channel.value();
132}

◆ reset() [1/2]

void dunedaq::timing::IONode::reset ( const ClockSource & clock_source) const
virtual

Reset IO, with clock file look up.

Reimplemented from dunedaq::timing::IONode.

Definition at line 179 of file IONode.cpp.

315{
316 // Find the right pll config file
317 std::string clock_config = get_full_clock_config_file_path(clock_source);
318 reset(clock_config);
319}
virtual std::string get_full_clock_config_file_path(const ClockSource &clock_source) const
Get the full config path.
Definition IONode.cpp:167
void reset(const std::string &clock_config_file) const override
Reset pc059 node.

◆ reset() [2/2]

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

Reset pc059 node.

Implements dunedaq::timing::IONode.

Definition at line 54 of file PC059IONode.cpp.

55{
56 // Soft reset
58
59 millisleep(1000);
60
61 // Reset PLL and I2C
62 getNode("csr.ctrl.pll_rst").write(0x1);
63 getNode("csr.ctrl.pll_rst").write(0x0);
64
65 getNode("csr.ctrl.rst_i2c").write(0x1);
66 getNode("csr.ctrl.rst_i2c").write(0x0);
67
68 getNode("csr.ctrl.rst_i2cmux").write(0x1);
69 getNode("csr.ctrl.rst_i2cmux").write(0x0);
70
71 getClient().dispatch();
72
73 // enclustra i2c switch stuff
74 try {
75 getNode<I2CMasterNode>(m_uid_i2c_bus).get_slave("AX3_Switch").write_i2c(0x01, 0x7f);
76 } catch (const std::exception& e) {
77 ers::warning(EnclustraSwitchFailure(ERS_HERE, e));
78 }
79
80 // Upload config file to PLL
81 configure_pll(clock_config_file);
82
83 // Reset mmcm
84 getNode("csr.ctrl.rst").write(0x1);
85 getNode("csr.ctrl.rst").write(0x0);
86 getClient().dispatch();
87
88 getNode("csr.ctrl.mux").write(0);
89 getClient().dispatch();
90
91 auto sfp_expander = get_i2c_device<I2CExpanderSlave>(m_uid_i2c_bus, "SFPExpander");
92
93 // Set invert registers to default for both banks
94 sfp_expander->set_inversion(0, 0x00);
95 sfp_expander->set_inversion(1, 0x00);
96
97 // Bank 0 output, bank 1 input
98 sfp_expander->set_io(0, 0x00);
99 sfp_expander->set_io(1, 0xff);
100
101 // Bank 0 - enable all SFPGs (enable low)
102 sfp_expander->set_outputs(0, 0x00);
103 TLOG_DEBUG(0) << "SFPs 0-7 enabled";
104
105 // To be removed from firmware address maps also
106 //getNode("csr.ctrl.rst_lock_mon").write(0x1);
107 //getNode("csr.ctrl.rst_lock_mon").write(0x0);
108 //getClient().dispatch();
109
110 TLOG() << "Reset done";
111}
virtual void write_soft_reset_register() const
Write soft reset register.
Definition IONode.cpp:296
const std::string m_uid_i2c_bus
Definition IONode.hpp:200
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
void warning(const Issue &issue)
Definition ers.hpp:115

◆ switch_sfp_i2c_mux_channel()

void dunedaq::timing::PC059IONode::switch_sfp_i2c_mux_channel ( uint32_t sfp_id) const

Switch the SFP I2C mux channel.

Definition at line 137 of file PC059IONode.cpp.

138{
139
140 getNode("csr.ctrl.rst_i2cmux").write(0x1);
141 getClient().dispatch();
142 getNode("csr.ctrl.rst_i2cmux").write(0x0);
143 getClient().dispatch();
144 millisleep(100);
145
146 uint8_t channel_select_byte = 1UL << sfp_id; // NOLINT(build/unsigned)
147 getNode<I2CMasterNode>(m_pll_i2c_bus).get_slave("SFP_Switch").write_i2cPrimitive({ channel_select_byte });
148 TLOG_DEBUG(3) << "PC059 SFP I2C mux set to " << format_reg_value(sfp_id);
149}
const std::string m_pll_i2c_bus
Definition IONode.hpp:201

◆ switch_sfp_mux_channel()

void dunedaq::timing::PC059IONode::switch_sfp_mux_channel ( uint32_t mux_channel) const
overridevirtual

Switch the SFP mux channel.

Implements dunedaq::timing::SFPMuxIONode.

Definition at line 116 of file PC059IONode.cpp.

117{
118 getNode("csr.ctrl.mux").write(mux_channel);
119 getClient().dispatch();
120
121 TLOG_DEBUG(3) << "SFP input mux set to " << format_reg_value(read_active_sfp_mux_channel());
122}
uint32_t read_active_sfp_mux_channel() const override
Read the active SFP mux channel.

◆ switch_sfp_soft_tx_control_bit()

void dunedaq::timing::PC059IONode::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 197 of file PC059IONode.cpp.

198{
199 // on this board the upstream sfp has its own i2c bus, and the 8 downstream sfps are muxed onto the main i2c bus
200 uint32_t sfp_bus_index; // NOLINT(build/unsigned)
201 if (sfp_id == 0) {
202 sfp_bus_index = 0;
203 } else if (sfp_id > 0 && sfp_id < 9) {
204 switch_sfp_i2c_mux_channel(sfp_id - 1);
205 sfp_bus_index = 1;
206 } else {
207 throw InvalidSFPId(ERS_HERE, format_reg_value(sfp_id));
208 }
209 auto sfp = get_i2c_device<I2CSFPSlave>(m_sfp_i2c_buses.at(sfp_bus_index), "SFP_EEProm");
210 sfp->switch_soft_tx_control_bit(turn_on);
211}

◆ switch_sfp_tx()

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

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

Implements dunedaq::timing::IONode.

Definition at line 216 of file PC059IONode.cpp.

216 { // NOLINT(build/unsigned)
217
218 validate_sfp_id(sfp_id);
219
220 auto sfp_expander = get_i2c_device<I2CExpanderSlave>(m_uid_i2c_bus, "SFPExpander");
221 uint8_t current_sfp_tx_control_flags = sfp_expander->read_outputs_config(0); // NOLINT(build/unsigned)
222
223 uint8_t new_sfp_tx_control_flags; // NOLINT(build/unsigned)
224 if (turn_on)
225 {
226 new_sfp_tx_control_flags = current_sfp_tx_control_flags & ~(1UL << sfp_id);
227 }
228 else
229 {
230 new_sfp_tx_control_flags = current_sfp_tx_control_flags | (1UL << sfp_id);
231 }
232
233 sfp_expander->set_outputs(0, new_sfp_tx_control_flags);
234}
void validate_sfp_id(uint32_t sfp_id) const
Fill hardware monitoring structure.

◆ validate_sfp_id()

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

Fill hardware monitoring structure.

Give info to collector.

Definition at line 239 of file PC059IONode.cpp.

240{
241 // on this board we have 8 downstream SFPs
242 if (sfp_id > 7)
243 {
244 throw InvalidSFPId(ERS_HERE, format_reg_value(sfp_id));
245 }
246}

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