Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 4cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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 4cha
Commits
b4495e8a
Commit
b4495e8a
authored
Jun 08, 2012
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/python: library based on SPEC driver
parent
e9ab8ca8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
49 deletions
+47
-49
demo.py
software/python/demo.py
+1
-6
fdelay_lib.py
software/python/fdelay_lib.py
+46
-43
No files found.
software/python/demo.py
View file @
b4495e8a
...
...
@@ -74,12 +74,7 @@ if __name__ == "__main__":
print
(
"Sorry, I must be run as root..."
);
sys
.
exit
(
-
1
)
fd
=
os
.
open
(
"/dev/rawrabbit"
,
os
.
O_SYNC
)
if
(
fd
<
0
):
print
(
"Can't open the rawrabbit device. Is the rawrabbit driver installed?"
)
sys
.
exit
(
-
1
)
card
=
FineDelay
(
fd
)
card
=
FineDelay
()
app
=
QApplication
(
sys
.
argv
)
...
...
software/python/fdelay_lib.py
View file @
b4495e8a
...
...
@@ -22,41 +22,51 @@ class fd_timestamp(Structure):
return
"
%
d:
%
d"
%
(
self
.
utc
,
self
.
nsecs
())
class
FineDelay
:
BASE_ADDR
=
0x80000
BASE_ADDR
=
0x80000
def
__init__
(
self
,
bus
=
-
1
):
self
.
fdelay
=
CDLL
(
'../lib/libfinedelay.so'
)
FREE_RUNNING
=
0x10
WR_OFFLINE
=
0x8
WR_READY
=
0x1
WR_SYNCING
=
0x2
WR_SYNCED
=
0x4
SYNC_LOCAL
=
0x1
SYNC_WR
=
0x2
# load the firmware for the SPEC:
self
.
card
=
self
.
fdelay
.
spec_open
(
c_int
(
bus
),
c_int
(
-
1
));
def
__init__
(
self
,
fd
):
cwd
=
os
.
path
.
dirname
(
__file__
)
self
.
fdelay
=
CDLL
(
cwd
+
'/../lib/libfinedelay.so'
)
self
.
handle
=
c_voidp
(
self
.
fdelay
.
fdelay_create_rawrabbit
(
c_int
(
fd
),
c_ulong
(
self
.
BASE_ADDR
)));
if
(
self
.
card
==
0
):
print
(
"SPEC enumeration failed"
);
sys
.
exit
(
-
1
)
if
~
os
.
path
.
isfile
(
"spec_top_fd.bin"
):
print
(
"No firmware file found. Attempting to download one from OHWR"
)
import
urllib
urllib
.
urlretrieve
(
"http://www.ohwr.org/attachments/download/1350/spec_top.bin"
,
"spec_top_fd.bin"
)
if
(
c_int
(
self
.
fdelay
.
fdelay_load_firmware
(
"../spec_top_wr.bin"
))
<
0
):
print
(
"Firmware loader failed..."
);
sys
.
exit
(
-
1
)
cwd
=
os
.
getcwd
();
if
(
self
.
fdelay
.
spec_load_bitstream
(
c_voidp
(
self
.
card
),
c_char_p
(
cwd
+
"/spec_top_fd.bin"
))
<
0
):
print
(
"Firmware loader failure"
);
sys
.
exit
(
-
1
)
self
.
fdelay
.
spec_close
(
c_voidp
(
self
.
card
))
print
"Initialising Fine Delay board..."
if
(
self
.
fdelay
.
fdelay_init
(
self
.
handle
)
<
0
):
print
(
"Init failed.."
);
sys
.
exit
(
-
1
)
self
.
handle
=
pointer
(
create_string_buffer
(
'
\000
'
*
16384
))
#allocate some memory for the fdelay_device_t
if
(
self
.
fdelay
.
spec_fdelay_create_bd
(
self
.
handle
,
c_int
(
bus
),
c_int
(
-
1
),
c_ulong
(
self
.
BASE_ADDR
))
<
0
):
print
(
"FD enumeration failed"
)
sys
.
exit
(
-
1
)
print
"Initializing Fine Delay board..."
if
(
self
.
fdelay
.
fdelay_init
(
self
.
handle
)
<
0
):
print
(
"Init failed.."
);
sys
.
exit
(
-
1
)
def
conf_trigger
(
self
,
enable
,
termination
):
self
.
fdelay
.
fdelay_configure_trigger
(
self
.
handle
,
c_int
(
enable
),
c_int
(
termination
))
def
conf_trigger
(
self
,
enable
,
termination
):
self
.
fdelay
.
fdelay_configure_trigger
(
self
.
handle
,
c_int
(
enable
),
c_int
(
termination
))
def
conf_output
(
self
,
channel
,
enable
,
delay
,
width
):
self
.
fdelay
.
fdelay_configure_output
(
self
.
handle
,
c_int
(
channel
),
c_int
(
enable
),
c_ulonglong
(
delay
),
c_ulonglong
(
width
),
c_ulonglong
(
200000
),
c_int
(
1
))
def
conf_output
(
self
,
channel
,
enable
,
delay
,
width
):
self
.
fdelay
.
fdelay_configure_output
(
self
.
handle
,
c_int
(
channel
),
c_int
(
enable
),
c_ulonglong
(
delay
),
c_ulonglong
(
width
),
c_ulonglong
(
200000
),
c_int
(
1
))
def
conf_readout
(
self
,
enable
):
self
.
fdelay
.
fdelay_configure_readout
(
self
.
handle
,
enable
)
def
conf_readout
(
self
,
enable
):
self
.
fdelay
.
fdelay_configure_readout
(
self
.
handle
,
enable
)
# def conf_sync(self, mode):
# self.fdelay.fdelay_configure_sync(self.handle, mode)
...
...
@@ -76,21 +86,14 @@ class FineDelay:
self
.
fdelay
.
fdelay_get_time
(
self
.
handle
,
byref
(
t
))
return
t
def
get_sync_status
(
self
):
htab
=
{
self
.
FREE_RUNNING
:
"oscillator free-running"
,
self
.
WR_OFFLINE
:
"WR core offline"
,
self
.
WR_READY
:
"WR core ready"
,
self
.
WR_SYNCING
:
"Syncing local clock with WR"
,
self
.
WR_SYNCED
:
"Synced with WR"
}
# status = c_int(self.fdelay.fdelay_get_sync_status(self.handle));
# print("GetSyncStatus %x" % status.value);
return
"none"
;
#htab[status.value]
def
read_ts
(
self
):
buf
=
(
fd_timestamp
*
256
)();
ptr
=
pointer
(
buf
)
n
=
self
.
fdelay
.
fdelay_read
(
self
.
handle
,
ptr
,
256
)
arr
=
[];
for
i
in
range
(
0
,
n
):
arr
.
append
(
buf
[
i
])
return
arr
def
get_sync_status
(
self
):
return
"none"
;
#fixme: new WR state machine
def
read_ts
(
self
):
buf
=
(
fd_timestamp
*
256
)();
ptr
=
pointer
(
buf
)
n
=
self
.
fdelay
.
fdelay_read
(
self
.
handle
,
ptr
,
256
)
arr
=
[];
for
i
in
range
(
0
,
n
):
arr
.
append
(
buf
[
i
])
return
arr
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