Beispiel #1
0
        class main(model.Module):

            J = model.Var(model.Boolean(), "J")
            K = model.Var(model.Boolean(), "K")
            Q = model.Var(model.Boolean(), "Q")

            INIT = [(Q == model.Falseexp())]

            ASSIGN = {model.Next(Q): model.Case(((J & K, ~Q),
                                                 (J, model.Trueexp()),
                                                 (K, model.Falseexp()),
                                                 (model.Trueexp(), Q)))}
Beispiel #2
0
 class main(model.Module):
     v = model.Var(model.Boolean())
     i = model.IVar(model.Boolean())
     INIT = [model.Case(((model.Trueexp(),
                          model.Comment(~v, "Initially FALSE")),))]
     TRANS = [model.Case(((v,
                           model.Comment(
                           model.Comment(v.next(), "Stay true"),
                           "when v is already true")),
                          (~i, model.Comment(v.next() == v,
                                             "Stay the same")),
                          (~v & i, v.next()),
                          (v & i, model.Comment(~v.next(),
                                                "Change to false"))))]
Beispiel #3
0
    def test_variables_comment(self):
        variables = model.Variables(collections.OrderedDict(
                                    ((model.Identifier("v"),
                                      model.Comment(model.Boolean(),
                                                    "The variable")),
                                     (model.Identifier("w"),
                                      model.Comment(
                                      model.Comment(model.Boolean(),
                                                    "Another variable"),
                                      "and a new name!")))))
        expected = """
VAR
    v: boolean; -- The variable
    w: 
        boolean; -- Another variable
        -- and a new name!
"""
        self.assertEqual(str(variables), expected.strip())
Beispiel #4
0
        class main(model.Module):
            COMMENT = "This is the main module"

            myvar = model.Var(model.Comment(model.Boolean(), "My variable"))

            var2 = model.Identifier("var2")
            VAR = {var2: model.Comment(model.Range(0, 3), "The counter")}

            INIT = [model.Comment(~myvar, "myvar is false") &
                    model.Comment(var2 == 0, "we start at 0")]

            TRANS = [
                     model.Case(((myvar,
                                  model.Comment(
                                  model.Comment(var2.next() ==
                                                ((var2 + 1) % 4),
                                          "Increase var2"),
                                  "Only when myvar is true"
                                  )
                                 ),
                                 (model.Trueexp(),
                                  model.Comment(var2.next() == var2,
                                          "otherwise do nothing"))))
                    ]
 class agent(md.Module):
     v = md.Var(md.Boolean())
     a = md.IVar(md.Boolean())
     INIT = v
     TRANS = (v.next() == a)
Beispiel #6
0
 class main(md.Module):
     c = md.Var(md.Boolean())
     INIT = c
     TRANS = (c.next() == ~c)
     FAIRNESS = [c, ~c]
Beispiel #7
0
 class main(model.Module):
     v = model.Var(model.Comment(model.Boolean(), "The variable"))
     w = model.Var(model.Comment(model.Comment(model.Boolean(),
                                 "Another variable"),
                   "and a new name!"))
Beispiel #8
0
 class main(model.Module):
     v = model.Var(model.Boolean())
     INIT = [model.Comment(~v, "Initially FALSE") | v]
Beispiel #9
0
 class main(model.Module):
     COMMENT = "This is the main module"
     v = model.Var(model.Boolean())
Beispiel #10
0
 class main(model.Module):
     run = model.IVar(model.Boolean())
     c1 = model.Var(Counter(run))