3 from collections
import namedtuple, OrderedDict
as odict
5 from AthenaCommon.Logging
import logging
6 log = logging.getLogger(__name__)
8 MC = namedtuple(
'MC',
"target_bit, topo_board, source_bit, signals")
13 MC(target_bit = 0, topo_board = 0, source_bit = 0, signals = (
"900INVM9999-AJ30s6-AJ20s6",
None )),
14 MC(target_bit = 1, topo_board = 0, source_bit = 1, signals = (
"800INVM9999-AJ30s6-AJ20s6",
None )),
15 MC(target_bit = 2, topo_board = 0, source_bit = 2, signals = (
"700INVM9999-AJ30s6-AJ20s6",
"ZEE-EM20shi2" )),
16 MC(target_bit = 3, topo_board = 0, source_bit = 3, signals = (
"500INVM9999-AJ30s6-AJ20s6",
None )),
17 MC(target_bit = 4, topo_board = 0, source_bit = 4, signals = (
"400INVM9999-AJ30s6-AJ20s6",
"0DR03-EM7ab-CJ15ab" )),
18 MC(target_bit = 5, topo_board = 0, source_bit = 5, signals = (
"300INVM9999-AJ30s6-AJ20s6",
"10MINDPHI-J20s2-XE30" )),
19 MC(target_bit = 6, topo_board = 0, source_bit = 6, signals = (
"200INVM9999-AJ30s6-AJ20s6",
"10MINDPHI-J20s2-XE50" )),
20 MC(target_bit = 7, topo_board = 0, source_bit = 7, signals = (
"100INVM9999-AJ30s6-AJ20s6",
"100RATIO-0MATCH-TAU30si2-EMall" )),
21 MC(target_bit = 8, topo_board = 0, source_bit = 8, signals = (
"0INVM9-EM7ab-EMab",
"NOT-0MATCH-TAU30si1-EMall" )),
22 MC(target_bit = 9, topo_board = 0, source_bit = 9, signals = (
"HT150-J20s5pETA31",
None )),
23 MC(target_bit = 10, topo_board = 0, source_bit = 10, signals = (
"HT190-J15s5pETA21",
None )),
24 MC(target_bit = 11, topo_board = 0, source_bit = 11, signals = (
"1INVM5-EMs1-EMs6",
None )),
25 MC(target_bit = 12, topo_board = 0, source_bit = 12, signals = (
"1INVM5-EM7s1-EMs6",
"27DPHI32-EMs1-EMs6" )),
26 MC(target_bit = 13, topo_board = 0, source_bit = 13, signals = (
"1INVM5-EM12s1-EMs6",
None )),
27 MC(target_bit = 14, topo_board = 0, source_bit = 14, signals = (
None,
None )),
28 MC(target_bit = 15, topo_board = 0, source_bit = 15, signals = (
"400INVM9999-AJ30s6pETA31-AJ20s6p31ETA49",
None )),
29 MC(target_bit = 16, topo_board = 0, source_bit = 16, signals = (
None,
"DISAMB-30INVM-EM20his2-TAU12ab" )),
30 MC(target_bit = 17, topo_board = 0, source_bit = 17, signals = (
None,
None )),
31 MC(target_bit = 18, topo_board = 0, source_bit = 18, signals = (
None,
None )),
32 MC(target_bit = 19, topo_board = 0, source_bit = 19, signals = (
"1DISAMB-J25ab-0DR28-EM15his2-TAU12abi",
None)),
33 MC(target_bit = 20, topo_board = 0, source_bit = 28, signals = (
None,
"600INVM9999-J30s6-AJ20s6" )),
34 MC(target_bit = 21, topo_board = 0, source_bit = 29, signals = (
None,
"500INVM9999-J30s6-AJ20s6" )),
35 MC(target_bit = 22, topo_board = 0, source_bit = 30, signals = (
None,
"400INVM9999-J30s6-AJ20s6" )),
36 MC(target_bit = 23, topo_board = 0, source_bit = 31, signals = (
None,
"200INVM9999-J30s6-AJ20s6" )),
37 MC(target_bit = 24, topo_board = 1, source_bit = 10, signals = (
None,
None )),
38 MC(target_bit = 25, topo_board = 1, source_bit = 11, signals = (
None,
"SC111-CJ15abpETA26" )),
39 MC(target_bit = 26, topo_board = 1, source_bit = 18, signals = (
None,
"0DR28-TAU20abi-TAU12abi" )),
40 MC(target_bit = 27, topo_board = 1, source_bit = 19, signals = (
None,
"1DISAMB-J25ab-0DR28-TAU20abi-TAU12abi" )),
41 MC(target_bit = 28, topo_board = 1, source_bit = 20, signals = (
None,
"1DISAMB-TAU12abi-J25ab" )),
42 MC(target_bit = 29, topo_board = 1, source_bit = 21, signals = (
None,
None )),
43 MC(target_bit = 30, topo_board = 1, source_bit = 28, signals = (
"0DETA20-J50s1-Js2",
None )),
44 MC(target_bit = 31, topo_board = 1, source_bit = 29, signals = (
None,
None )),
50 legacyOccupation = [[32*[
None],32*[
None]],[32*[
None],32*[
None]]]
51 for boardNumber, board
in enumerate([legacyBoard0, legacyBoard1]):
52 for conn
in board[
"connectors"][0][
"algorithmGroups"]:
55 for topoAlgDef
in conn[
'algorithms']:
56 lines = topoAlgDef.outputlines
58 legacyOccupation[boardNumber][clock][ 16*fpga + topoAlgDef.outputbits] = lines[0]
60 for bit,line
in enumerate(lines):
61 legacyOccupation[boardNumber][clock][ 16*fpga + bit + topoAlgDef.outputbits[0]] = line
63 signals = [32*[
None], 32*[
None]]
66 algFromMapping = mc.signals[clock]
67 if algFromMapping
is None:
69 signals[clock][mc.target_bit] =
"R2TOPO_"+algFromMapping
70 algFromLegacyBoardDef = legacyOccupation[mc.topo_board][clock][mc.source_bit]
71 if algFromMapping != algFromLegacyBoardDef:
72 fpga = mc.source_bit // 16
73 bit = mc.source_bit % 16
74 msg = f
"Legacy board mapping expects line {algFromMapping} on LegacyBoard{mc.topo_board}, fpga {fpga}, " +\
75 f
"clock {clock}, bit {bit} but board defines {algFromLegacyBoardDef}"
77 raise RuntimeError(
"Mapping doesn't match LegacyBoard definition")
81 board[
"connectors"] = []
82 board[
"type"] =
"merger"
83 board[
"connectors"].
append({
84 "name" :
"LegacyTopoMerged",
87 "type" :
"electrical",
92 "signals" : signals[0]
96 "signals" : signals[1]
100 return odict( [(
"LegacyTopoMerger", board)] )