Skip to content
Snippets Groups Projects
Commit 0aaeecc3 authored by Fredrik Bagge Carlson's avatar Fredrik Bagge Carlson
Browse files

add reference generator

parent 5fdd4935
No related branches found
No related tags found
No related merge requests found
......@@ -61,6 +61,7 @@ for (i,t) = enumerate(0:h:duration)
end
```
Often one finds the need to implement a stateful controller, i.e., a function
that has a memory or state. To this end, the function [`sysfilter`](@ref) is
provided. This function is used to implement control loops where a signal is
......
......@@ -9,6 +9,7 @@ include("interface_documentation.jl")
include("interface_implementations/ballandbeam.jl")
include("utilities.jl")
include("reference_generators.jl")
include("controllers.jl")
end # module
export PRBSGenerator
#PRBS
"""
r = PRBSGenerator(state = 1)
Generates a pseudo-random binary sequence. Call like `random_input = r()`.
"""
mutable struct PRBSGenerator
state::Int
end
PRBSGenerator() = PRBSGenerator(Int(1))
function (r::PRBSGenerator)(args...)
state = r.state
bit = ((state >> 0) (state >> 2) (state >> 3) (state >> 5) ) & 1
r.state = (state >> 1) | (bit << 15)
bit
end
using LabProcesses
using Base.Test
# write your own tests here
@test 1 == 2
# Reference generators
r = PRBSGenerator(Int(1))
seq = [r() for i = 1:10]
@test all(seq .== [0, 0, 1, 0, 0, 1, 1, 0, 0, 1])
foreach(r,1:10_000)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment