pflib v2.7.0-1-gd371ab6a
Polarfire Interaction Library
|
Polarfire Interaction Library. More...
Namespaces | |
namespace | detail |
Hidden functions to avoid misuse. | |
Classes | |
class | Backend |
Abstract interface for various backend manipulations. More... | |
class | Bias |
The HGC ROC has 4 MAX5825 chips doing the DAC for the bias voltages. More... | |
class | DAQ |
Interface with DAQ via a WishboneInterface. More... | |
class | DetectorConfiguration |
object for parsing a detector configuration file and (potentially) executing it More... | |
class | Elinks |
WishboneTarget for configuring the elinks. More... | |
class | Exception |
PFlib. More... | |
class | FastControl |
Representation of FastControl controller in the Polarfire. More... | |
class | GPIO |
Representation of GPIO controller in the Polarfire. More... | |
class | Hcal |
representing a standard HCAL motherboard More... | |
class | I2C |
Class which encapsulates the I2C controller in the Polarfire. More... | |
class | MAX5825 |
Class representing communication with the Digital-Analog Converter on the HGC ROC. More... | |
struct | Parameter |
A parameter for the HGC ROC includes one or more register locations and a default value defined in the manual. More... | |
struct | PolarfireTarget |
Interface to a single polarfire. More... | |
struct | RegisterLocation |
Structure holding a location in the registers. More... | |
class | ROC |
class | WishboneInterface |
Abstract interface for wishbone transactions, used by ~all classes in pflib. More... | |
class | WishboneTarget |
Parent class for standard wishbone targets providing some utilities. More... | |
Enumerations | |
enum | StandardWishboneTargets { tgt_COMMON = 0 , tgt_FastControl = 1 , tgt_GPIO = 2 , tgt_I2C = 3 , tgt_Elinks = 4 , tgt_DAQ_Control = 8 , tgt_DAQ_Inbuffer = 9 , tgt_DAQ_LinkFmt = 10 , tgt_DAQ_Outbuffer = 11 } |
common targets for the wishbone connection | |
Functions | |
int | str_to_int (std::string str) |
Get an integer from the input string. More... | |
std::string | upper_cp (const std::string &str) |
Get a copy of the input string with all caps. | |
void | compile (const std::string &page, const std::string ¶m, const int &val, std::map< int, std::map< int, uint8_t > > ®isters) |
Overlay a single parameter onto the input register map. More... | |
std::map< int, std::map< int, uint8_t > > | compile (const std::string &page_name, const std::string ¶m_name, const int &val) |
Compile a single parameter into the (potentially several) registers that it should set. More... | |
std::map< int, std::map< int, uint8_t > > | compile (const std::map< std::string, std::map< std::string, int > > &settings) |
Compiling which translates parameter values for the HGCROC into register values that can be written to the chip. More... | |
std::map< std::string, std::map< std::string, int > > | decompile (const std::map< int, std::map< int, uint8_t > > &compiled_config, bool be_careful) |
unpack register values into the page names, parameter names and parameter values mapping More... | |
std::vector< std::string > | parameters (const std::string &page) |
get the parameter names for the input page-type More... | |
std::map< std::string, std::map< std::string, int > > | defaults () |
get the default parameter values as specified in the manual More... | |
void | extract (const std::vector< std::string > &setting_files, std::map< std::string, std::map< std::string, int > > &settings) |
Extract the page name, parameter name, and parameter values from the YAML files into the passed settings map. More... | |
std::map< int, std::map< int, uint8_t > > | compile (const std::vector< std::string > &setting_files, bool prepend_defaults=true) |
compile a series of yaml files More... | |
std::map< int, std::map< int, uint8_t > > | compile (const std::string &setting_file, bool prepend_defaults=true) |
short hand for a single setting file More... | |
static std::vector< int > | getNextLineAndExtractValues (std::istream &ss) |
Modern RAII-styled CSV extractor taken from https://stackoverflow.com/a/1120224/17617632 this allows us to discard white space within the cells making the CSV more human readable. More... | |
static bool | endsWith (const std::string &full, const std::string &ending) |
Check if a given string has a specific ending. | |
Variables | |
const std::map< std::string, Parameter > | GLOBAL_ANALOG_LUT |
The Look Up Table of for the Global Analog sub-blocks of an HGC ROC. | |
const std::map< std::string, Parameter > | REFERENCE_VOLTAGE_LUT |
The Look Up Table of for the Reference Voltage sub-blocks of an HGC ROC. More... | |
const std::map< std::string, Parameter > | MASTER_TDC_LUT |
The Look Up Table of for the Master TDC sub-blocks` of an HGC ROC. | |
const std::map< std::string, Parameter > | CHANNEL_WISE_LUT |
The Look Up Table of for the individual channel sub-blocks` of an HGC ROC. | |
const std::map< std::string, Parameter > | DIGITAL_HALF_LUT |
The Look Up Table of for the Digital Half sub-blocks` of an HGC ROC. More... | |
const std::map< std::string, Parameter > | TOP_LUT |
The Look Up Table of for the Top sub-block of an HGC ROC. More... | |
const std::map< std::string, std::pair< int, std::map< std::string, Parameter > > > | PARAMETER_LUT |
Entire parameter Look Up Table. | |
static const int | CTL_OCCUPANCY_REG = 4 |
static const uint32_t | CTL_OCCUPANCY_MASK = 0x3F |
static const int | CTL_OCCUPANCY_CURRENT_SHIFT = 8 |
static const int | CTL_OCCUPANCY_MAXIMUM_SHIFT = 0 |
static const int | CTL_CONTROL_REG = 1 |
static const uint32_t | CTL_RESET = 0x20000000 |
static const uint32_t | CTL_LINK_COUNT_MASK = 0xFF00 |
static const int | CTL_LINK_COUNT_SHIFT = 8 |
static const int | CTL_FPGAID_REG = 3 |
static const int | CTL_FPGAID_MASK = 0xFF |
static const uint32_t | CTL_LINK_ENABLE = 0x0001 |
static const uint32_t | CTL_LINK_ZS_ENABLE = 0x0002 |
static const uint32_t | CTL_LINK_ZS_FULLSUPPRESS = 0x0004 |
static const int | REG_CONTROL = 1 |
static const int | CTL_SPYSTART = 0x10000000 |
static const int | CTL_SPYPICK_MASK = 0x00001F00 |
static const int | CTL_SPYPICK_SHIFT = 8 |
static const uint32_t | CTL_RESET_HARD = 0x20000000 |
static const uint32_t | CTL_AUTOALIGN_THRESHOLD_MASK = 0xF00 |
static const int | CTL_AUTOALIGN_THRESHOLD_SHIFT = 8 |
static const int | LINK_CTL_BASE = 0x40 |
static const int | LINK_CTL_BITSLIP_MASK = 0x70 |
static const int | LINK_CTL_BITSLIP_SHIFT = 4 |
static const int | LINK_CTL_AUTO_ENABLE = 0x80 |
static const int | LINK_CTL_DELAY_DIR = 0x00000001 |
static const int | LINK_CTL_EYE_CLEAR = 0x00010000 |
static const int | LINK_CTL_DELAY_MOVE = 0x00040000 |
static const int | LINK_CTL_DELAY_LOAD = 0x00080000 |
static const int | LINK_CTL_CLEAR_COUNTERS = 0x00100000 |
static const int | LINK_CTL_RESET_AUTO = 0x00200000 |
static const int | LINK_STATUS_BASE = 0x80 |
static const int | LINK_STATUS_DELAYRANGE = 0x01 |
static const int | LINK_STATUS_EYE_EARLY = 0x02 |
static const int | LINK_STATUS_EYE_LATE = 0x04 |
static const int | LINK_STATUS_ALIGNED = 0x10 |
static const int | LINK_STATUS_AUTOLOCK = 0x20 |
static const int | LINK_STATUS_AUTOPHASE_MASK = 0x700 |
static const int | LINK_STATUS_AUTOPHASE_SHIFT = 8 |
static const int | LINK_STATUS_BADIDLE_MASK = 0xFFF0000 |
static const int | LINK_STATUS_BADIDLE_SHIFT = 16 |
static const int | LINK_STATUS_AUTOCYCLE_MASK = 0xF0000000u |
static const int | LINK_STATUS_AUTOCYCLE_SHIFT = 28 |
static const int | BIGSPY_REG = 2 |
static const int | BIGSPY_LINK_MASK = 0x000000F0 |
static const int | BIGSPY_LINK_SHIFT = 4 |
static const int | BIGSPY_MODE_MASK = 0x0000000F |
static const int | BIGSPY_MODE_SHIFT = 0 |
static const int | BIGSPY_NAFTER_MASK = 0x03FF0000 |
static const int | BIGSPY_NAFTER_SHIFT = 16 |
static const int | BIGSPY_RESET = 0x80000000u |
static const int | BIGSPY_SW_TRIGGER = 0x40000000u |
static const int | BIGSPY_DONE = 0x20000000u |
static const int | SPY_WINDOW = 0xC0 |
static const int | BIGSPY_WINDOW = 0x400 |
static const int | REG_NLINKS = 9 |
static const int | REG_CONTROL1 = 1 |
static const uint32_t | CTL_COUNTER_CLEAR = 0x00000001u |
static const int | REG_CONTROL2 = 2 |
static const uint32_t | CTL_TX_PHASE_MASK = 0x0000000Fu |
static const int | CTL_TX_PHASE_SHIFT = 0 |
static const uint32_t | CTL_TX_DRIVE_RESET = 0x00000040u |
static const uint32_t | CTL_MULTISAMPLE_ENABLE = 0x00080000u |
static const uint32_t | CTL_MULTISAMPLE_MASK = 0x00070000u |
static const int | CTL_MULTISAMPLE_SHIFT = 16 |
static const int | REG_SINGLE_ERROR_COUNTER = 4 |
static const int | REG_DOUBLE_ERROR_COUNTER = 5 |
static const int | REG_CMD_COUNTER_BASE = 8 |
static const int | CMD_COUNT =8 |
static const uint32_t | REG_PORTCOUNTS = 1 |
static const uint32_t | MASK_PORTCOUNTS_INPUT = 0x0000ffffu |
static const uint32_t | SHFT_PORTCOUNTS_INPUT = 0 |
static const uint32_t | MASK_PORTCOUNTS_OUTPUT = 0xffff0000u |
static const uint32_t | SHFT_PORTCOUNTS_OUTPUT = 16 |
static const uint32_t | REG_INPUTS_BASE = 8 |
static const uint32_t | REG_OUTPUTS_BASE = 16 |
static const int | BITS_PER_REG = 32 |
static const int | GPO_BIT_SOFTRESET0 = 0 |
static const int | GPO_BIT_RESYNCLOAD0 = 4 |
static const int | GPO_BIT_HARDRESET = 8 |
static const int | N_ROC = 4 |
static const uint32_t | REG_BUS_SELECT = 2 |
static const uint32_t | MASK_BUS_SELECT = 0xFFFF |
static const uint32_t | REG_BUS_AVAILABLE = 1 |
static const uint32_t | MASK_BACKPLANE_HACK = 0x30000 |
static const uint32_t | MASK_BUS_AVAILABLE = 0x0FFFF |
static const uint32_t | REG_TRANSACTOR = 5 |
static const uint32_t | MASK_TRANSACTOR_READ = 0x1 |
static const uint32_t | MASK_TRANSACTOR_I2CADDR = 0xFE |
static const uint32_t | SHFT_TRANSACTOR_I2CADDR = 1 |
static const uint32_t | MASK_TRANSACTOR_ENABLE = 0x80000000 |
static const uint32_t | MASK_TRANSACTOR_START = 0x40000000 |
static const uint32_t | MASK_TRANSACTOR_BUSY = 0x04000000 |
static const uint32_t | MASK_TRANSACTOR_DONE = 0x02000000 |
static const uint32_t | MASK_TRANSACTOR_ERROR = 0x01000000 |
static const uint32_t | MASK_TRANSACTOR_TX = 0x0000FF00 |
static const uint32_t | SHFT_TRANSACTOR_TX = 8 |
static const uint32_t | MASK_TRANSACTOR_RX = 0x00FF0000 |
static const uint32_t | SHFT_TRANSACTOR_RX = 16 |
static const uint32_t | REG_PRESCALE0 = 8 |
static const uint32_t | REG_PRESCALE1 = 9 |
static const int | I2C_PRE0 = 0|8 |
static const int | I2C_PRE1 = 1|8 |
static const int | I2C_CTR = 2|8 |
static const int | I2C_TXR = 3|8 |
static const int | I2C_RXR = 3|8 |
static const int | I2C_CR = 4|8 |
static const int | I2C_SR = 4|8 |
static const int | I2C_STA = 0x80 |
static const int | I2C_STO = 0x40 |
static const int | I2C_RD = 0x20 |
static const int | I2C_WR = 0x10 |
static const int | I2C_NACK = 0x08 |
static const int | I2C_IACK = 0x01 |
static const int | block_for_chan [] |
static const std::string | INHERIT = "INHERIT" |
static const std::string | HGCROCS = "HGCROCS" |
Polarfire Interaction Library.
Implementation Layer Below, change carefully!
This library is designed to ease the burden of configuring HGC ROCs connected to a Polarfire FPGA as well as define some helpful debugging functionalities for determining the optimal configuration of an HGC ROC.
std::map< int, std::map< int, uint8_t > > pflib::compile | ( | const std::map< std::string, std::map< std::string, int > > & | settings | ) |
Compiling which translates parameter values for the HGCROC into register values that can be written to the chip.
The input settings map has an expected structure:
The pages that a specific parameter and its value are applied to are decided by if key1 is a substring of the full page name. This allows the user to specify a group of pages by just giving a partial page name that is a substring of the pages that you wish to apply the parameter to. For example,
[in] | settings | page names, parameter names, and parameter value settings |
void pflib::compile | ( | const std::string & | page, |
const std::string & | param, | ||
const int & | val, | ||
std::map< int, std::map< int, uint8_t > > & | registers | ||
) |
Overlay a single parameter onto the input register map.
This only overwrites the bits that need to be changed for the input parameter. Any registers that don't exist will be set to 0 before being written to.
implementation of compiling a single value for the input parameter specification into the list of registers.
This accesses the PARAMETER_LUT map, its submaps, and the register_values map without any checks so it may throw a std::out_of_range error. Do checking of names before calling this one.
Most of the parameters have the same names as the ones in the HGCROC Manual; however, a few parameters on the Top sub-block (page) different in format and so we have changed them here. The translations from the manual to what is used here are listed below.
[in] | page | name of page parameter is on |
[in] | param | name of parameter |
[in] | val | value parameter should be |
[in,out] | registers | page numbers, register numbers, and register values to apply parameter to |
std::map< int, std::map< int, uint8_t > > pflib::compile | ( | const std::string & | page_name, |
const std::string & | param_name, | ||
const int & | val | ||
) |
Compile a single parameter into the (potentially several) registers that it should set.
Any other bits in the register(s) that this parameter affects will be set to zero.
[in] | page_name | name of page parameter is on |
[in] | param_name | name of parameter |
[in] | val | value parameter should be set to |
std::map< int, std::map< int, uint8_t > > pflib::compile | ( | const std::string & | setting_file, |
bool | prepend_defaults = true |
||
) |
short hand for a single setting file
[in] | setting_file | YAML file to extract and compile |
[in] | prepend_defaults | start construction of settings map by including defaults from all parameter settings |
std::map< int, std::map< int, uint8_t > > pflib::compile | ( | const std::vector< std::string > & | setting_files, |
bool | prepend_defaults = true |
||
) |
compile a series of yaml files
[in] | setting_files | list of YAML files to extract in order and compile |
[in] | prepend_defaults | start construction of settings map by including defaults from all parameter settings |
std::map< std::string, std::map< std::string, int > > pflib::decompile | ( | const std::map< int, std::map< int, uint8_t > > & | compiled_config, |
bool | be_careful | ||
) |
unpack register values into the page names, parameter names and parameter values mapping
ret_map[page_name][parameter_name] == parameter_value
The decompilation simply interates through all parameters and attempts to deduce their values from the input compiled config.
If be_careful is true and any of the registers required to deduce a parameter are missing, warnings are printed to std::cerr and the parameter is skipped. Additionally, warnings are printed for entire pages that are skipped.
If be_careful is false, then no warnings are printed and parameters are only skipped if all of the registers that constitute it are missing.
[in] | compiled_config | page number, register number, register value settings |
[in] | be_careful | true if we should print warnings and skip partially-set params |
std::map< std::string, std::map< std::string, int > > pflib::defaults | ( | ) |
get the default parameter values as specified in the manual
This is a helpful command for simply printing a "template" YAML settings file although it will printout all pages individually.
void pflib::extract | ( | const std::vector< std::string > & | setting_files, |
std::map< std::string, std::map< std::string, int > > & | settings | ||
) |
Extract the page name, parameter name, and parameter values from the YAML files into the passed settings map.
Page names are allowed to be "globbed" so that multiple pages with the same parameters can be set in one chunk of YAML. The globbing is just checking for a prefix and you must end a globbing page with the *
character in order to signal that this chunk of YAML is to be used for all pages whose name start with the input prefix.
All matching is done case insensitively.
will match all channel pages and turn them off.
will throw an exception because no page is named 'channel_'.
will turn off channel_1 (and only channel 1)
will turn off all channels beginning with 1 (1, 10, 11, 12, etc...)
[in] | setting_files | list of YAML files to extract in order |
[in,out] | settings | page name, parameter name, parameter value settings extracted from YAML file(s) |
|
static |
Modern RAII-styled CSV extractor taken from https://stackoverflow.com/a/1120224/17617632 this allows us to discard white space within the cells making the CSV more human readable.
std stoi has a auto-detect base feature https://en.cppreference.com/w/cpp/string/basic_string/stol which we can enable by setting the pre-defined base to 0 (the third parameter) - this auto-detect base feature can handle hexidecial (prefix == 0x or 0X), octal (prefix == 0), and decimal (no prefix).
The second parameter is an address to put the number of characters processed, which I disregard at this time.
Do we allow empty cells?
std::vector< std::string > pflib::parameters | ( | const std::string & | page | ) |
get the parameter names for the input page-type
The page-types are as specified in the HGC ROC manual without spaces and case insensitive.
int pflib::str_to_int | ( | std::string | str | ) |
Get an integer from the input string.
The normal stoi (and similar) tools don't support binary inputs which are helpful in our case where sometimes the value is set in binary but each bit has a non-base-2 scale.
Supported prefixes:
0b
--> binary0x
--> hexidecimal0
--> octal[in] | str | string form of integer |
|
static |
const std::map<std::string,Parameter> pflib::DIGITAL_HALF_LUT |
The Look Up Table of for the Digital Half sub-blocks` of an HGC ROC.
const std::map<std::string,Parameter> pflib::REFERENCE_VOLTAGE_LUT |
The Look Up Table of for the Reference Voltage sub-blocks of an HGC ROC.
const std::map<std::string,Parameter> pflib::TOP_LUT |
The Look Up Table of for the Top sub-block of an HGC ROC.