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
d7c37209
Commit
d7c37209
authored
Apr 11, 2012
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hdl/sim/timestamp.svh: nanoseconds to counters conversion bugfix
parent
c1a51eb0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
7 deletions
+31
-7
timestamp.svh
hdl/include/timestamp.svh
+31
-7
No files found.
hdl/include/timestamp.svh
View file @
d7c37209
`ifndef
__
TIMESTAMP_SVH
`define
__TIMESTAMP_SVH
class
Timestamp
;
`include
"wb/simdrv_defs.svh"
int
utc
,
coarse
,
frac
,
coarse_range
,
seq_id
;
class
Timestamp
;
uint64_t
utc
;
int
coarse
,
frac
,
coarse_range
,
seq_id
,
source
;
function
new
(
int
_u
tc
=
0
,
int
_
coarse
=
0
,
int
_
frac
=
0
,
int
_
seq_id
=
0
,
int
_
coarse_range
=
256
)
;
function
new
(
int
_u
tc
=
0
,
int
_
coarse
=
0
,
int
_
frac
=
0
,
int
_
seq_id
=
0
,
int
_
coarse_range
=
125000000
)
;
utc
=
_u
tc
;
coarse
=
_
coarse
;
frac
=
_
frac
;
coarse_range
=
_
coarse_range
;
seq_id
=
_
seq_id
;
source
=
0
;
endfunction
// new
function
real
flatten
()
;
...
...
@@ -25,20 +28,41 @@ class Timestamp;
frac
=
x
%
4096
;
x
=
x
-
frac
;
x
=
x
/
4096
;
coarse
=
x
%
256
;
coarse
=
x
%
coarse_range
;
x
=
x
-
coarse
;
x
=
x
/
256
;
x
=
x
/
coarse_range
;
utc
=
x
;
$
display
(
"Unflat: %d %d %d %d"
,
t
,
utc
,
coarse
,
frac
)
;
endtask
// unflatten
function
Timestamp
sub
(
Timestamp
b
)
;
function
Timestamp
add
(
Timestamp
b
)
;
Timestamp
r
=
new
;
r
.
frac
=
frac
+
b
.
frac
;
r
.
coarse
=
coarse
+
b
.
coarse
;
r
.
utc
=
utc
+
b
.
utc
;
if
(
r
.
frac
>=
4096
)
begin
r
.
frac
-=
4096
;
r
.
coarse
++;
end
if
(
r
.
coarse
>=
coarse_range
)
begin
r
.
utc
++;
r
.
coarse
-=
coarse_range
;
end
return
r
;
endfunction
endclass
`endif
// `ifndef __TIMESTAMP_SVH
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