pylab_ml.misc.registermaster.RegDB
- class RegDB(filename='')[source]
Bases:
objectClass to read the register master excel file and to build a database of registers.
- __init__(filename='')[source]
Initialize the class by reading the excel file and building the database.
- Parameters:
filename (str) – The path to the register master excel file.
Methods
__init__([filename])Initialize the class by reading the excel file and building the database.
Fill database with register master fields by iterating through all sheets and rows of the excel file.
get_row_data(bk, sh, rowx, colrange)Utility function to extract a single row out of an Excel sheet
- build_database()[source]
Fill database with register master fields by iterating through all sheets and rows of the excel file.
- The database is a list of dictionaries, each dictionary represents a register block and contains the following keys:
name: The name of the register block.
id: The row index of the block definition in the excel sheet.
cells: A dictionary mapping column indices to cell names (e.g., ‘blk’, ‘pos’, etc.).
types: A dictionary mapping cell names to type conversion definitions (e.g., ‘int’, ‘hex’, etc.).
checks: A dictionary mapping cell names to check definitions (e.g., ‘hu’, ‘bu’, etc.).
- registers: A list of dictionaries, each representing a register defined in the block, containing the following keys:
blk: The name of the register block.
pos: The position of the register within the block.
- slices: A list of dictionaries, each representing a bitslice defined for the register, containing the following keys:
posmin: The starting bit index of the bitslice.
posmax: The ending bit index of the bitslice.
poswidth: The width of the bitslice (posmax - posmin + 1).
posmask: A bitmask corresponding to the bitslice (e.g., for bits 3:1, posmask would be 0b1110).
other fields as defined in the excel sheet (e.g., type conversions, checks, etc.).
- get_row_data(bk, sh, rowx, colrange)[source]
Utility function to extract a single row out of an Excel sheet
- Parameters:
bk (xlrd.Book) – The workbook object.
sh (xlrd.Sheet) – The sheet object.
rowx (int) – The index of the row to extract.
colrange (range) – The range of column indices to extract.
- Returns:
result – A list of tuples containing the column index, cell type, cell value, and cell formatting index.
- Return type:
list