Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Martin Heyden
LabProcesses.jl
Commits
0aaeecc3
Commit
0aaeecc3
authored
Aug 23, 2017
by
Fredrik Bagge Carlson
Browse files
add reference generator
parent
5fdd4935
Changes
4
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
0aaeecc3
...
...
@@ -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
...
...
src/LabProcesses.jl
View file @
0aaeecc3
...
...
@@ -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
src/reference_generators.jl
0 → 100644
View file @
0aaeecc3
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
test/runtests.jl
View file @
0aaeecc3
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
)
Write
Preview
Supports
Markdown
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