Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Schedules
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
Software for White Rabbit PTP Core
Commits
03433833
Commit
03433833
authored
Jul 13, 2023
by
Tomasz Wlostowski
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
softpll: enable dithering for the helper PLL
parent
284ea791
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
19 deletions
+22
-19
softpll_ng.c
softpll/softpll_ng.c
+4
-0
spll_common.c
softpll/spll_common.c
+9
-12
spll_helper.c
softpll/spll_helper.c
+6
-5
spll_helper.h
softpll/spll_helper.h
+1
-0
spll_main.c
softpll/spll_main.c
+2
-2
No files found.
softpll/softpll_ng.c
View file @
03433833
...
...
@@ -291,6 +291,10 @@ void spll_very_init(void)
spll_n_chan_out
=
3
;
softpll
.
mpll
.
gain_sched
=
NULL
;
helper_very_init
((
struct
spll_helper_state
*
)
&
softpll
.
helper
);
// set up default PI gains/lock thresholds
}
void
spll_init
(
int
mode
,
int
slave_ref_channel
,
int
flags
)
...
...
softpll/spll_common.c
View file @
03433833
...
...
@@ -14,25 +14,22 @@
#include <wrc.h>
#include "softpll_ng.h"
static
int
gen_dither
(
int
pi_shift
)
static
int
gen_dither
_lfsr
(
int
pi_shift
)
{
static
const
uint32_t
lcg_m
=
1103515245
;
static
const
uint32_t
lcg_i
=
12345
;
static
uint32_t
seed
=
0
;
static
uint16_t
lfsr
=
0xACE1u
;
uint16_t
bit
;
/* Must be 16-bit to allow bit<<15 later in the code */
seed
*=
lcg_m
;
seed
+=
lcg_i
;
seed
&=
0x7fffffffUL
;
/* taps: 16 14 13 11; feedback polynomial: x^16 + x^14 + x^13 + x^11 + 1 */
bit
=
((
lfsr
>>
0
)
^
(
lfsr
>>
2
)
^
(
lfsr
>>
3
)
^
(
lfsr
>>
5
))
&
1u
;
lfsr
=
(
lfsr
>>
1
)
|
(
bit
<<
15
)
;
int
d
=
seed
&
((
1
<<
pi_shift
)
-
1
);
if
(
seed
&
(
1
<<
pi_shift
))
int
d
=
(
uint32_t
)
lfsr
&
((
1
<<
pi_shift
)
-
1
);
if
(
lfsr
&
(
1
<<
pi_shift
))
return
-
d
;
else
return
d
;
}
int
pi_update
(
spll_pi_t
*
pi
,
int
x
)
{
int64_t
i_new
;
...
...
@@ -42,7 +39,7 @@ int pi_update(spll_pi_t *pi, int x)
int64_t
y_preround
=
(
i_new
+
(
int64_t
)
x
*
pi
->
kp
)
+
(
1
<<
(
pi
->
shift
-
1
)
);
int
dither
=
pi
->
dithered
?
gen_dither
(
pi
->
shift
)
:
0
;
int
dither
=
pi
->
dithered
?
gen_dither
_lfsr
(
pi
->
shift
-
1
)
:
0
;
y
=
(
(
y_preround
+
dither
)
>>
pi
->
shift
)
+
pi
->
bias
;
/* clamping (output has to be in <y_min, y_max>) and
...
...
softpll/spll_helper.c
View file @
03433833
...
...
@@ -9,13 +9,11 @@
/* spll_helper.c - implmentation of the Helper PLL servo algorithm. */
#include <wrc.h>
#include "softpll_ng.h"
void
helper_
init
(
struct
spll_helper_state
*
s
,
int
ref_channel
)
void
helper_
very_init
(
struct
spll_helper_state
*
s
)
{
/* Phase branch PI controller */
/* Phase branch PI controller */
s
->
pi
.
y_min
=
5
;
s
->
pi
.
y_max
=
(
1
<<
DAC_BITS
)
-
5
;
#if defined(CONFIG_WR_NODE)
...
...
@@ -32,6 +30,10 @@ void helper_init(struct spll_helper_state *s, int ref_channel)
s
->
ld
.
threshold
=
200
;
s
->
ld
.
lock_samples
=
10000
;
s
->
ld
.
delock_samples
=
100
;
}
void
helper_init
(
struct
spll_helper_state
*
s
,
int
ref_channel
)
{
s
->
ref_src
=
ref_channel
;
}
...
...
@@ -106,7 +108,6 @@ void helper_start(struct spll_helper_state *s)
s
->
sample_n
=
0
;
s
->
tag_d0
=
-
1
;
board_dbg
(
"Helper PLL PI Values: Kp %i
\t
Ki %i
\n
"
,
s
->
pi
.
kp
,
s
->
pi
.
ki
);
pi_init
((
spll_pi_t
*
)
&
s
->
pi
);
ld_init
((
spll_lock_det_t
*
)
&
s
->
ld
);
...
...
softpll/spll_helper.h
View file @
03433833
...
...
@@ -35,6 +35,7 @@ struct spll_helper_state {
spll_lock_det_t
ld
;
};
void
helper_very_init
(
struct
spll_helper_state
*
s
);
void
helper_init
(
struct
spll_helper_state
*
s
,
int
ref_channel
);
void
helper_update
(
struct
spll_helper_state
*
s
,
int
tag
,
int
source
);
...
...
softpll/spll_main.c
View file @
03433833
...
...
@@ -69,6 +69,7 @@ void mpll_init(struct spll_main_state *s, int id_ref, int id_out)
}
pi_init
((
spll_pi_t
*
)
&
s
->
pi
);
s
->
pi
.
dithered
=
0
;
ld_init
((
spll_lock_det_t
*
)
&
s
->
ld
);
}
...
...
@@ -116,7 +117,6 @@ static inline void mpll_handle_gain_schedule( struct spll_main_state *s )
s
->
ld
.
lock_changed
=
0
;
s
->
ld
.
locked
=
0
;
s
->
gain_sched
->
locked_d
=
0
;
board_dbg
(
"Gain schedule stage: %d, Kp: %d, ki: %d, shift: %d
\n
"
,
s
->
gain_sched
->
current_stage
,
stage
->
kp
,
stage
->
ki
,
stage
->
shift
);
}
s
->
gain_sched
->
locked_d
=
s
->
ld
.
locked
;
...
...
@@ -159,8 +159,8 @@ void mpll_start(struct spll_main_state *s)
s
->
ld
.
lock_cnt
=
0
;
}
board_dbg
(
"Main PLL PI Values: Kp %i
\t
Ki %i
\n
"
,
s
->
pi
.
kp
,
s
->
pi
.
ki
);
pi_init
((
spll_pi_t
*
)
&
s
->
pi
);
s
->
pi
.
dithered
=
0
;
ld_init
((
spll_lock_det_t
*
)
&
s
->
ld
);
spll_enable_tagger
(
s
->
id_ref
,
1
);
...
...
Peter Jansweijer
@peterj
mentioned in merge request
!9 (merged)
·
Aug 18, 2023
mentioned in merge request
!9 (merged)
mentioned in merge request !9
Toggle commit list
Peter Jansweijer
@peterj
mentioned in commit
dafc0629
·
Aug 18, 2023
mentioned in commit
dafc0629
mentioned in commit dafc06294362aee65f83c84af70c03a50b4059c9
Toggle commit list
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