-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMSPIX28Spacely_Subroutines_A2_FW.py
64 lines (47 loc) · 2.07 KB
/
CMSPIX28Spacely_Subroutines_A2_FW.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
# spacely
from Master_Config import *
def fw_status_clear():
hex_lists = [
["4'h2", "4'hE", "11'h7ff", "1'h1", "1'h1", "5'h1f", "6'h3f"], # write op code E (status clear)
["4'h2", "4'h1", "11'h7ff", "1'h1", "1'h1", "5'h1f", "6'h3f"], # write op code 1 (firmware reset)
]
sw_write32_0(hex_lists)
def clk_divide():
# create hex lists
hex_lists = []
# 1st parameter of the hex code (right to left)
# this number divides the original 400 MHz down for the BxCLK_ana and BxCLK
# 400 MHz / clk_divide
clk_divides = range(10, 41)
# loop over clk_divides from 10 to 40
for divide in clk_divides:
# get clk_divide value
clk_divide = "6'h" + hex(divide)[2:] # removes the 0x prefix, ex. 0x28 -> 28
# create hex list
hex_list = ["4'h2", "4'h2", "11'h0", "1'h0", "1'h0", "5'h4", clk_divide]
hex_lists.append(hex_list)
print(f"Writing {len(hex_lists)} hex lists to register sw_write32_0")
# call sw_write32_0
sw_write32_0(hex_lists)
def clk_delay():
# create hex lists
hex_lists = []
# 2nd parameter of hex code (right to left)
# change the amount of the delay
delays = range(0,6)
# 3rd parameter of hex code (right to left)
# change the sign of the delay
# 1'h0 = positive offset of analog clock w.r.t digital clock = rising edge of analog clock and the rising egde of the digital clock
# 1'h1 = negative offset of analog clock w.r.t digital clock = rising edge of analog clock and the falling edge of the digital clock
signs = ["1'h0", "1'h1"]
# create hex list to be easy to see on the scope
for sign in signs:
for delay in delays:
# get clk_divide value
clk_delay = "5'h" + hex(delay)[2:] # removes the 0x prefix, ex. 0x28 -> 28
# create hex list
hex_list = ["4'h2", "4'h2", "11'h0", "1'h0", sign, clk_delay, "6'h28"]
hex_lists.append(hex_list)
print(f"Writing {len(hex_lists)} hex lists to register sw_write32_0")
# call sw_write32_0
sw_write32_0(hex_lists)