DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
afc.crossbar Namespace Reference

Functions

 crossbar (obj)
 
 configure (obj, tx_enable_flag, xpt_map0, xpt_map1, active_xpt_map)
 
 read_config (obj)
 
 applyCrossbarTxConfig (ipmi_connection, tx_enable_flag)
 
 applyCrossbarXPTMapConfig (ipmi_connection, xpt_map, map_number)
 
 readCrossbarXPTMapConfig (ipmi_connection, map_number)
 
 readCrossbarTxConfig (ipmi_connection)
 
 formatCrossbarConfigTable (map_0, map_1, tx, active_map)
 

Function Documentation

◆ applyCrossbarTxConfig()

afc.crossbar.applyCrossbarTxConfig ( ipmi_connection,
tx_enable_flag )

Definition at line 67 of file crossbar.py.

67def applyCrossbarTxConfig(ipmi_connection, tx_enable_flag):
68 tx_control_ctrl_reg_start = 0x20
69
70 for i in range(16):
71 reg_adr = tx_control_ctrl_reg_start+i
72
73 # TX Basic Control Register flags:
74 # [6] TX CTL SELECT - 0: PE and output level control is derived from common lookup table
75 # 1: PE and output level control is derived from per port drive control registers
76 # [5:4] TX EN[1:0] - 00: TX disabled, lowest power state
77 # 01: TX standby
78 # 10: TX squelched
79 # 11: TX enabled
80 # [3] Reserved - Set to 0
81 # [2:1] PE[2:0] - If TX CTL SELECT = 0,
82 # 000: Table Entry 0
83 # 001: Table Entry 1
84 # 010: Table Entry 2
85 # 011: Table Entry 3
86 # 100: Table Entry 4
87 # 101: Table Entry 5
88 # 110: Table Entry 6
89 # 111: Table Entry 7
90 # - If TX CTL SELECT = 1, PE[2:0] are ignored
91 tx_state = 0b0110000 if tx_enable_flag & (1 << i) else 0b0000000
92 #print("tx state for output {} at adr {}: ".format(i,hex(reg_adr)) +hex(tx_state))
93 ipmi.writeRegOverIPMI(ipmi_connection, reg_adr, tx_state)
94# ------------------------------------------------------------------------------
95
96
97# ------------------------------------------------------------------------------

◆ applyCrossbarXPTMapConfig()

afc.crossbar.applyCrossbarXPTMapConfig ( ipmi_connection,
xpt_map,
map_number )

Definition at line 98 of file crossbar.py.

98def applyCrossbarXPTMapConfig(ipmi_connection, xpt_map, map_number):
99 xpt_reg_values=[]
100 for i in range(2,18,2):
101 map_value_str = xpt_map[i-2:i]
102 map_value=int(map_value_str, 16)
103 reg_value_lo = int('{:08b}'.format(map_value)[4:], 2) << 4
104 reg_value_hi = int('{:08b}'.format(map_value)[:4], 2)
105 reg_value = reg_value_lo | reg_value_hi
106 xpt_reg_values.append(reg_value)
107
108 xpt_map_reg_adrs_start=[0x90, 0x98]
109
110 for i in range(len(xpt_reg_values)):
111 reg_adr = xpt_map_reg_adrs_start[map_number]+i
112 reg_value = xpt_reg_values[i]
113 ipmi.writeRegOverIPMI(ipmi_connection, reg_adr, reg_value)
114# ------------------------------------------------------------------------------
115
116
117# ------------------------------------------------------------------------------

◆ configure()

afc.crossbar.configure ( obj,
tx_enable_flag,
xpt_map0,
xpt_map1,
active_xpt_map )

Definition at line 24 of file crossbar.py.

24def configure(obj, tx_enable_flag, xpt_map0, xpt_map1, active_xpt_map):
25
26 if (len(xpt_map0) != 16 or len(xpt_map1) != 16):
27 raise click.ClickException("XPT map length must be 16. Lenghts of provided maps are, 0: {}, 1: {}".format(len(xpt_map0), len(xpt_map1)))
28
29 # reset clock cross-bar
30 ipmi.writeRegOverIPMI(obj.ipmi_connection, 0x0, 0x01)
31
32 # input->output map in output order of 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
33 applyCrossbarXPTMapConfig(obj.ipmi_connection, xpt_map0, 0)
34 applyCrossbarXPTMapConfig(obj.ipmi_connection, xpt_map1, 1)
35
36 # select which map is active
37 ipmi.writeRegOverIPMI(obj.ipmi_connection, 0x81, active_xpt_map)
38
39 #enable new config
40 ipmi.writeRegOverIPMI(obj.ipmi_connection, 0x80, 0x01)
41
42 # output tx enable flags in order of 15 -> 0
43 applyCrossbarTxConfig(obj.ipmi_connection, tx_enable_flag)
44
45 print("Crossbar config applied")
46 obj.ipmi_connection.session.close()
47# ------------------------------------------------------------------------------
48
49
50# ------------------------------------------------------------------------------
51@crossbar.command('read-config', short_help='Reads the config of the clock cross-bar on the AFC')
52@click.pass_obj

◆ crossbar()

afc.crossbar.crossbar ( obj)

Definition at line 12 of file crossbar.py.

12def crossbar(obj):
13 # make ipmi connecfon
14 obj.ipmi_connection = ipmi.establishIPMIConnectionToAMC(obj.mch_ip_adr, obj.amc_slot)
15# ------------------------------------------------------------------------------
16
17# ------------------------------------------------------------------------------
18@crossbar.command('configure', short_help='Configures the clock cross-bar on the AFC')
19@click.option('--tx-enable-flag', 'tx_enable_flag', required=False, type=toolbox.IntRange(0x0,0xffff), default=0b0000000000100000, help='Output tx enable flags')
20@click.option('--xpt-map0', 'xpt_map0', required=False, type=str, default="77777d7777777777", help='Input->output crossbar map 0')
21@click.option('--xpt-map1', 'xpt_map1', required=False, type=str, default="7777777777777777", help='Input->output crossbar map 1')
22@click.option('--active-xpt-map', 'active_xpt_map', required=False, type=toolbox.IntRange(0x0,0x1), default=0x0, help='Active xpt map')
23@click.pass_obj

◆ formatCrossbarConfigTable()

afc.crossbar.formatCrossbarConfigTable ( map_0,
map_1,
tx,
active_map )

Definition at line 149 of file crossbar.py.

149def formatCrossbarConfigTable(map_0, map_1, tx, active_map):
150
151 map_0_colour='green'
152 map_1_colour='white'
153 if active_map == 1:
154 map_0_colour='white'
155 map_1_colour='green'
156
157 configTable = Texttable(max_width=0)
158 configTable.set_deco(Texttable.VLINES | Texttable.BORDER | Texttable.HEADER)
159 configTable.set_cols_align(["l", "l", "l", "l"])
160 configTable.set_chars(['-', '|', '+', '-'])
161 configTable.header( ['Output', style('Map 0', fg=map_0_colour), style('Map 1', fg=map_1_colour), 'Tx state'] )
162
163 for i in range(len(map_0)):
164 tx_state = (tx[i] & 0b0110000) >> 4
165 tx_state_names = ["Disabled", "Standby", "Squelched", "Enabled"]
166 tx_state_colours=['red', 'white', 'blue', 'green']
167 configTable.add_row( [i, style(str(map_0[i]), fg=map_0_colour), style(str(map_1[i]), fg=map_1_colour), style(tx_state_names[tx_state], fg=tx_state_colours[tx_state])] )
168
169 return configTable.draw()
170# ------------------------------------------------------------------------------

◆ read_config()

afc.crossbar.read_config ( obj)

Definition at line 53 of file crossbar.py.

53def read_config(obj):
54
55 xpt_map_0 = readCrossbarXPTMapConfig(obj.ipmi_connection, 0)
56 xpt_map_1 = readCrossbarXPTMapConfig(obj.ipmi_connection, 1)
57 tx_states = readCrossbarTxConfig(obj.ipmi_connection)
58
59 active_map = ipmi.readRegOverIPMI(obj.ipmi_connection, 0x81)
60 print("Active map: ",active_map)
61 echo ( formatCrossbarConfigTable(xpt_map_0, xpt_map_1, tx_states,active_map) )
62 obj.ipmi_connection.session.close()
63# ------------------------------------------------------------------------------
64
65
66# ------------------------------------------------------------------------------

◆ readCrossbarTxConfig()

afc.crossbar.readCrossbarTxConfig ( ipmi_connection)

Definition at line 135 of file crossbar.py.

135def readCrossbarTxConfig(ipmi_connection):
136 tx_states=[]
137
138 tx_control_ctrl_reg_start = 0x20
139
140 for i in range(16):
141 reg_adr = tx_control_ctrl_reg_start+i
142 reg_value = ipmi.readRegOverIPMI(ipmi_connection, reg_adr)
143 tx_states.append(reg_value)
144 return tx_states
145# ------------------------------------------------------------------------------
146
147
148# ------------------------------------------------------------------------------

◆ readCrossbarXPTMapConfig()

afc.crossbar.readCrossbarXPTMapConfig ( ipmi_connection,
map_number )

Definition at line 118 of file crossbar.py.

118def readCrossbarXPTMapConfig(ipmi_connection, map_number):
119 xpt_map=[]
120
121 xpt_map_reg_adrs_start=[0x90, 0x98]
122
123 for i in range(8):
124 reg_adr = xpt_map_reg_adrs_start[map_number]+i
125 reg_value = ipmi.readRegOverIPMI(ipmi_connection, reg_adr)
126 reg_value_lo = reg_value & 0x0f
127 reg_value_hi = (reg_value >> 4) & 0x0f
128 xpt_map.append(reg_value_lo)
129 xpt_map.append(reg_value_hi)
130 return xpt_map
131# ------------------------------------------------------------------------------
132
133
134# ------------------------------------------------------------------------------