Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 2cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC DEL 1ns 2cha
Commits
0c0a02a7
Commit
0c0a02a7
authored
Nov 03, 2016
by
Jan Pospisil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Python command line interface
parent
94b0fd86
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
136 additions
and
2 deletions
+136
-2
FFPG_CLI.py
sw/FFPG_CLI.py
+134
-0
FFPG_driver.py
sw/FFPG_driver.py
+2
-2
No files found.
sw/FFPG_CLI.py
0 → 100644
View file @
0c0a02a7
#!/usr/bin/env python
# coding: utf8
import
sys
# from Ffpg import *
def
myInt
(
s
):
if
s
.
isdigit
():
return
int
(
s
)
else
:
return
None
calibrationData
=
[
# -1 = uncalibrated
# channel 1, channel 2
[
-
1
,
-
1
],
# FMC slot 0
[
-
1
,
-
1
]
# FMC slot 1
]
print
(
"FFPG command line interface"
)
print
(
""
)
if
len
(
sys
.
argv
)
is
not
4
and
len
(
sys
.
argv
)
<
7
:
print
"Usage:"
print
" "
+
sys
.
argv
[
0
]
+
" <fmcSlot (LUN)> <channel> <polarity> <pulseWidth> <pulseDelay> <bunches>"
print
" Sets and starts selected channel on selected FMC mezzanine"
print
" or"
print
" "
+
sys
.
argv
[
0
]
+
" <fmcSlot (LUN)> <channel> stop"
print
" Stops selected channel on selected FMC mezzanine"
print
""
print
" <fmcSlot (LUN)> - 0 | 1"
print
" <channel> - 1 | 2"
print
" <polarity> - 0 | 1"
print
" <pulseWidth> - positive number in [ns]"
print
" <pulseDelay> - nonegative number in [ns]"
print
" <bunches> - space separated list of bunch numbers"
print
""
sys
.
exit
()
fmcSlot
=
myInt
(
sys
.
argv
[
1
])
channel
=
myInt
(
sys
.
argv
[
2
])
if
sys
.
argv
[
3
]
==
"stop"
:
polarity
=
"stop"
else
:
polarity
=
myInt
(
sys
.
argv
[
3
])
pulseWidth
=
myInt
(
sys
.
argv
[
4
])
pulseDelay
=
myInt
(
sys
.
argv
[
5
])
bunches
=
[]
for
i
in
range
(
6
,
len
(
sys
.
argv
)):
bunches
.
append
(
myInt
(
sys
.
argv
[
i
]))
print
(
"Configuration:"
)
print
(
" fmcSlot (LUN) = "
+
str
(
fmcSlot
))
print
(
" channel = "
+
str
(
channel
))
if
polarity
==
"stop"
:
print
(
" command = stop"
)
else
:
if
polarity
is
1
:
print
(
" polarity = "
+
str
(
polarity
)
+
" (positive pulses)"
)
else
:
print
(
" polarity = "
+
str
(
polarity
)
+
" (negative pulses)"
)
print
(
" pulseWidth = "
+
str
(
pulseWidth
)
+
" ns"
)
print
(
" pulseDelay = "
+
str
(
pulseDelay
)
+
" ns"
)
print
(
" bunches = "
+
str
(
bunches
))
print
(
""
)
if
fmcSlot
is
not
0
and
fmcSlot
is
not
1
:
raise
Exception
(
"fmcSlot (LUN) can be only 0 or 1!"
);
if
channel
is
not
1
and
channel
is
not
2
:
raise
Exception
(
"channel can be only 1 or 2!"
);
if
polarity
is
not
0
and
polarity
is
not
1
and
polarity
is
not
"stop"
:
raise
Exception
(
"polarity can be only 0 or 1!"
);
if
polarity
!=
"stop"
:
if
pulseWidth
<=
0
:
raise
Exception
(
"pulseWidth has to be > 0 ns!"
);
if
pulseDelay
<
0
:
raise
Exception
(
"pulseDelay has to be >= 0 ns!"
);
# TODO: assert for bunches?
def
PrintFrequency
(
pg
):
frequency
=
pg
.
GetFrequency
()
if
frequency
is
not
None
:
print
(
"RF clock frequency: "
+
str
(
frequency
/
1.0e6
)
+
" MHz"
)
else
:
print
(
"RF clock frequency: (unstable)"
)
# create FFPG driver for FMC slot
pg
=
Ffpg
(
fmcSlot
)
# activate low-level debug output
# pg.wb.SetDebug(True)
# activate SystemVerilog trace debug
# pg.wb.SetDebugSv("wb_trace.svh")
# stop and disable channel
if
polarity
==
"stop"
:
pg
.
StopChannel
(
channel
)
pg
.
DisableChannel
(
channel
)
sys
.
exit
();
# initialize the driver
pg
.
Reset
()
pg
.
SelectClock
(
"external"
,
400.789
)
pg
.
SetRatio
(
2
)
pg
.
SetOverflow
(
17820
)
pg
.
Ad9512Sync
()
pg
.
SetTriggerThreshold
(
0.5
)
pg
.
SetVcxoFrequency
(
-
0.2105
)
# 125.0000 MHz
# calibration
triggerPhase
=
calibrationData
[
fmcSlot
][
channel
-
1
]
print
(
"Calibrating channel "
+
str
(
channel
)
+
" on FMC slot "
+
str
(
fmcSlot
)
+
" to "
+
str
(
triggerPhase
)
+
" ns"
)
if
triggerPhase
>
-
1
:
pg
.
SetTriggerPhase
(
channel
,
triggerPhase
)
else
:
print
(
" (Skipping this calibration, no calibration data (-1) provided.)"
)
# print some info
pg
.
PrintVersion
()
# print("Actual temperature: "+str(pg.temp.ReadTemperature()) + " °C")
print
(
"Actual temperature: (temparature read-out disabled - it is too slow)"
)
PrintFrequency
(
pg
)
pg
.
PrintControl
()
pg
.
PrintStatus
()
pg
.
PrintDebug
()
# create bunched pulses
pg
.
ResetBadState
(
channel
)
pg
.
CreateBunchPulses
(
channel
,
pulseDelay
,
pulseWidth
,
bunches
,
polarity
)
pg
.
EnableChannel
(
channel
)
pg
.
StartChannel
(
channel
)
print
""
print
"Done."
print
""
sw/FFPG_driver.py
View file @
0c0a02a7
...
...
@@ -117,10 +117,10 @@ pg = Ffpg(fmcSlot)
Init
(
pg
)
# create single pulse
TestSinglePulse
(
pg
,
channel
)
#
TestSinglePulse(pg, channel)
# create bunched pulses
#
TestBunchPulses(pg, channel)
TestBunchPulses
(
pg
,
channel
)
# stop and disable channel
# StopAndDisable(pg, channel)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment