|
1 | 1 | using ModelingToolkitStandardLibrary.Electrical, ModelingToolkit, OrdinaryDiffEq, Test
|
2 |
| -using ModelingToolkitStandardLibrary.Electrical: Set, Reset, _and, _or, _not |
| 2 | +using ModelingToolkitStandardLibrary.Electrical: _and, _or, _not, _xor |
| 3 | +using ModelingToolkitStandardLibrary.Electrical: U, X, F0, F1, Z, W, L, H, DC |
| 4 | +using ModelingToolkitStandardLibrary.Electrical: convert_to_logic, get_logic_level |
| 5 | +# using ModelingToolkitStandardLibrary.Electrical: Set, Reset |
| 6 | + |
| 7 | +# Logic and helper functions |
| 8 | +@test length(instances(Logic)) == 9 |
| 9 | +@test convert_to_logic.([1, 0]) |> typeof == Vector{Logic} |
| 10 | +@test get_logic_level(Z) == 5 |
| 11 | + |
| 12 | +# Logic zeros and ones |
| 13 | +@test zero(Logic) == zero(U) == F0 |
| 14 | +@test one(Logic) == one(U) == F1 |
| 15 | +@test ones(Logic, 2, 2) == [F1 F1 |
| 16 | + F1 F1] |
| 17 | + |
| 18 | +# Logic vectors |
| 19 | +u_logic = StdULogicVector([U, W, X, 1]) |
| 20 | +@test typeof(u_logic.logic) == Vector{Logic} |
| 21 | +@test get_logic_level(u_logic) == [1, 6, 2, 4] |
| 22 | + |
| 23 | +logic = StdLogicVector([U, W, X, 1]) |
| 24 | +@test typeof(logic.logic) == Vector{Logic} |
| 25 | +@test get_logic_level(logic) == [1, 6, 2, 4] |
| 26 | + |
| 27 | +# Predefiend logic vectors |
| 28 | +@test std_ulogic.logic == [U, X, F0, F1, Z, W, L, H, DC] |
| 29 | +@test UX01.logic == [U, X, F0, F1] |
| 30 | +@test UX01Z.logic == [U, X, F0, F1, Z] |
| 31 | +@test X01.logic == [X, F0, F1] |
| 32 | +@test X01Z.logic == [X, F0, F1, Z] |
| 33 | + |
| 34 | +# logic tables and logic gate helpers |
| 35 | +@test AndTable[1, 1] = U |
| 36 | +@test OrTable[1, 1] = U |
| 37 | +@test NotTable[1, 1] = U |
| 38 | +@test XorTable[1, 1] = U |
| 39 | +@test size(AndTable) == size(OrTable) == size(NotTable) == size(XorTable) == (9, 9) |
| 40 | + |
| 41 | +@test _and(1, 1, 1, 1, 1, 1) == F1 |
| 42 | +@test _or(0, 1, 1, 1, 1, 1) == F0 |
| 43 | +@test _xor(0, 1, 1, 1, 1, 1) == F1 |
| 44 | +@test _not(1) == F0 |
| 45 | + |
| 46 | +# Logic helper functions |
| 47 | +@test get_logic_level.([U, X, F0, F1, Z, W, L, H, DC]) == 1:9 |
| 48 | +@test convert_to_logic.([1, 0, U]) == [F1, F0, U] |
| 49 | + |
| 50 | +#= |
3 | 51 |
|
4 | 52 | @parameters t
|
5 | 53 |
|
|
374 | 422 |
|
375 | 423 | u0 = []
|
376 | 424 | prob = ODEProblem(sys, u0, (0, 1.5))
|
377 |
| - # sol = solve(prob, Rosenbrock23()) |
| 425 | + # sol = solve(prob, Rosenbrock23()) |
378 | 426 | end
|
| 427 | +
|
| 428 | +=# |
0 commit comments