-
Notifications
You must be signed in to change notification settings - Fork 0
/
setfem.py
executable file
·73 lines (58 loc) · 1.99 KB
/
setfem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/python
# Setup FEM
csr=0x50032000 # default CSR
# for details see MPCEX FEM User Guide:
# https://docs.google.com/document/d/1Af5qRmYUNsfU-TkVpd8vJxEkcIqnKi_7xnJf8nlslEY/edit#heading=h.bjsg1osbwivb
#
version='v3'
# Modifications: 'trigint' instead of 'ped'
import sys
import subprocess
def print_usage():
print('Usage: '+sys.argv[0]+' a/b[Carriers] [trigext/trigint] [-gray] [cbtest] [femtest] [beamclk]')
if len(sys.argv) < 2:
print('Setup the FEM. Version '+version)
print_usage()
print('Example for FEM a: carriers 0,2,3, master carrier 2, external trigger:')
print(sys.argv[0]+' a203 trig```')
exit()
splayer_option = ''
if sys.argv[1][0] == 'b':
splayer_option = '-g'
elif sys.argv[1][0] != 'a':
print('First letter should be a or b')
exit()
if len(sys.argv[1])<2:
print('Master is not specified')
exit()
trig_source=0
for s in sys.argv[2:]:
if s == 'trigext':
csr |= 0x00000000
elif s == 'trigint':
csr |= 0x000000C0
elif s == '-gray':
csr |= 0x00001000 # disable Gray decoding
elif s == "cbtest":
csr |= 0x00100000 # force all chains into simulation mode by setting BClk=1
elif s == "femtest":
csr |= 0x00100004 # FEM simulation mode
elif s == "beamclk":
csr |= 0x00000008 # Work from the beam clock
else:
print('Unknown argument: '+s)
print_usage()
exit()
master = int(sys.argv[1][1])
carmask = 0
for b in sys.argv[1][1:]:
carmask |= 1<<int(b)
print('cm='+hex(carmask)+', m='+hex(master)+',='+hex((carmask | master)<<4))
csr |= (carmask<<8) | (master<<4)
cmdline = 'Play_stapl.py '+splayer_option+' i10 ' + hex(csr)[2:]
print('Executing: '+cmdline)
p = subprocess.Popen(cmdline, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in p.stdout.readlines():
print line,
retval = p.wait()
exit()