mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-23 03:32:32 +00:00
With a history of three pulses, this can track up a 10% sine variation in a 1010101 stream. So I guess this'll do for now?
This commit is contained in:
parent
6afd619791
commit
74817f6664
@ -39,4 +39,23 @@ class DPLLTests: XCTestCase {
|
|||||||
let pll = DigitalPhaseLockedLoopBridge(clocksPerBit: 100, tolerance: 20, historyLength: 5)
|
let pll = DigitalPhaseLockedLoopBridge(clocksPerBit: 100, tolerance: 20, historyLength: 5)
|
||||||
testRegularNibblesOnPLL(pll, bitLength: 110)
|
testRegularNibblesOnPLL(pll, bitLength: 110)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testTenPercentSinePattern() {
|
||||||
|
let pll = DigitalPhaseLockedLoopBridge(clocksPerBit: 100, tolerance: 20, historyLength: 3)
|
||||||
|
var angle = 0.0
|
||||||
|
|
||||||
|
// clock in two 1s, a 0, and a 1, 200 times over
|
||||||
|
for _ in 0 ..< 200 {
|
||||||
|
let bitLength: UInt = UInt(100 + 5 * sin(angle))
|
||||||
|
|
||||||
|
pll.runForCycles(bitLength/2)
|
||||||
|
pll.addPulse()
|
||||||
|
pll.runForCycles((bitLength*3)/2)
|
||||||
|
|
||||||
|
angle = angle + 0.1
|
||||||
|
}
|
||||||
|
|
||||||
|
let endOfStream = (pll.stream&0xffffff);
|
||||||
|
XCTAssert(endOfStream == 0xaaaaaa || endOfStream == 0x555555, "PLL should have synchronised and clocked repeating 0xa or 0x5 nibbles; got \(String(pll.stream, radix: 16, uppercase: false))")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user