Can be used to generate the wiki page table WpWiki-Doc
In [1]:
# bitdefs - elements for bit descriptions
# bitsz - size of register in bits
#
def reg_wiki(reg_name, reg_dir, reg_description, bitdefs, bitsz):
reg_size = str(bitsz)+"bit"
# part table definitions
#table pre part of row
title_pre_row = "^ ^ Register ^ Direction ^ Size ^ Description "
reg_pre_row = "| {0} | {1} | {2} | {3} | {4} ".format('', reg_name, reg_dir, reg_size, reg_description)
bit_pre_row = "| ::: | ::: | ::: | ::: | ::: "
#table post part of row
title_post_row = "^ Bit ^ Name ^ Hex ^ Bit Description ^"
bit_post_row = "| ''[{0:2}]'' |{2:19} | 0x{1:08X} | {3:30} |" # define a sub-row for bit description with parameter 0-3
print("=== "+reg_name+" definition ===")
print(title_pre_row + title_post_row)
for i in range(nbr):
desc = [0, '', ''] # empty element
for k in bitdefs:
if k[0] == i:
desc = k
if not desc[1] == '':
if i == 0:
print(reg_pre_row + bit_post_row.format(i,1<<i,desc[1],desc[2])) # for first line add register description
else:
print(bit_pre_row + bit_post_row.format(i,1<<i,desc[1],desc[2])) # for other liens add column concat
"""# use full row definitions for printing
tabtitle = "^ ^ Register ^ Direction ^ Size ^ Description ^ Bit ^ Name ^ Hex ^ Bit Description ^"
reg_row = "| {0} | {1} | {2} | {3} | {4} | | | | |".format('', reg_name, reg_dir, reg_size, reg_description)
bit_row = "| ::: | ::: | ::: | ::: | ::: | ''[{0:2}]'' |{2:19} | {1:08X} | {3:30} |" # define a row for bit description with parameter 0-3
print("==== ControlWord definition ====")
print(tabtitle)
print(reg_row)
for i in range(nbr):
desc = [0, '', '']
for k in register:
if k[0] == i:
desc = k
print(bit_row.format(i,1<<i,desc[1],desc[2]))"""
In [2]:
# print the register information as text (full)
def reg_text(register, nbr):
print("^ bit ^ Binary ^ Hex ^ Decimal ^ bit ^ Register name ^ Comment ^")
print("|------|----------------------------------|----------|------------|-----------|-----------------|-----------------|")
for i in range(nbr):
desc = [0, '', '']
for k in register:
if k[0] == i:
desc = k
print("|{0:4} | {1:032b} | {1:08X} | {1:10d} | ''[{0:3}]'' | {2:22} | {3:30} |".format(i,1<<i,desc[1],desc[2]))
In [3]:
nbr = 32
register = ([ 0 , 'CMD_PREPARE' , '-'],)
register += ([ 1 , 'CMD_START' , '-'],)
register += ([ 2 , 'CMD_STOP' , '-'],)
register += ([ 3 , 'CMD_ABORT' , '-'],)
register += ([ 4 , 'CMD_SYNC' , '-'],)
register += ([ 5 , 'CMD_FINISH' , '-'],)
register += ([ 6 , 'CMD_PAUSE' , '-'],)
register += ([ 7 , 'CMD_TRANSFER_ABORT', '-'],)
register += ([ 8 , 'CMD_RESTART' , '-'],)
register += ([ 16 , 'CMD_INLET_VALVE' , '-'],)
register += ([ 17 , 'CMD_OUTLET_VALVE' , '-'],)
register += ([ 18 , 'CMD_FIRE_VOLTAGE' , '-'],)
register += ([ 19 , 'CMD_PH_HEATER' , '-'],)
register += ([ 24 , 'CMD_MANUAL_FIRE' , '-'],)
register += ([ 25 , 'CMD_MANUAL_DATA' , '-'],)
register += ([ 28 , 'CMD_PH_SELECT1' , '-'],)
register += ([ 29 , 'CMD_PH_SELECT2' , '-'],)
register += ([ 30 , 'CMD_PH_SELECT3' , '-'],)
register += ([ 31 , 'CMD_PH_SELECT4' , '-'],)
reg_wiki("ControlWord", "Input", "PDI ControlWord", register, nbr)
#print("\n")
#print("... and in text format")
#reg_text("ControlWord", "Input", "PDI ControlWord", register, nbr)
In [5]:
nbr = 32
# =====================================================================
register = ([ 0, 'STATUS_ERROR' , '-'],)
register += ([ 1, 'STATUS_1' , '-'],)
register += ([ 2, 'STATUS_2' , '-'],)
register += ([ 3, 'STATUS_3' , '-'],)
register += ([ 4, 'STATUS_IDLE' , 'PrintControl StateMachine - IDLE'],)
register += ([ 5, 'STATUS_PREPARING' , 'PrintControl StateMachine - PREPARING'],)
register += ([ 6, 'STATUS_READY' , 'PrintControl StateMachine - READY'],)
register += ([ 7, 'STATUS_PRINTING' , 'PrintControl StateMachine - PRINTING'],)
register += ([ 8, 'STATUS_DONE' , 'PrintControl StateMachine - DONE'],)
register += ([ 12, 'STATUS_MOVING' , 'interpolator/pulsegenerator'],)
register += ([ 13, 'STATUS_SYNC_WARNING' , 'interpolator/pulsegenerator'],)
register += ([ 14, 'STATUS_BUSY' , 'interpolator/pulsegenerator busy flag, one ph is printing (generating pulses) \\ [[http://wpwiki/doku.php?id=internal:vhdl:components:interpolator:vhdl&#pulsegeneratorvhd]]'],)
register += ([ 15, 'STATUS_ACTIVE' , 'interpolator/pulsegenerator active flag, on ph is started (received start signal) \\ [[http://wpwiki/doku.php?id=internal:vhdl:components:interpolator:vhdl&#pulsegeneratorvhd]]'],)
register += ([ 16, 'STATUS_PH_PRESENT' , 'Printhead is present for all connected HIB'],)
register += ([ 17, 'STATUS_PH_WARNING' , 'Warning or Error for one PH is present'],)
register += ([ 18, 'STATUS_PH_WAVEFORM' , '[Ricoh only] printhead waveform load request'],)
register += ([ 19, 'STATUS_PH_TEMPERATURE' , 'Temperature of one PH is not ok'],)
register += ([ 20, 'STATUS_IMAGEEND' , 'jetmapping - image print end event'],)
register += ([ 21, 'STATUS_LINK_LOSS' , 'HIB link loss indication on one enabled ph [HIB products only]'],)
register += ([ 24, 'STATUS_JOBQUEUEEMPTY' , '-'],)
register += ([ 25, 'STATUS_JOBTRANSFER' , '-'],)
register += ([ 28, 'STATUS_STEPPERMOTOR_BUSY' , '[Kyocera only]'],)
reg_wiki("StatusWord", "Output", "PDI StatusWord", register, nbr)
#print("\n")
#print("... and in text format")
#reg_text("ControlWord", "Input", "PDI ControlWord", register, nbr)