Esempio n. 1
0
    def __init__(self, in1, in2, out):
        self.in1 = gs.sc_signal(in1)
        self.in2 = gs.sc_signal(in2)
        gs.spawn(self.doit)

        self.h = gs.param("hello")
        self.m = gs.param("message")
Esempio n. 2
0
    def __init__(self, in1, in2, out):
        self.in1 = gs.sc_signal(in1)
        self.in2 = gs.sc_signal(in2)
        gs.spawn(self.doit)

        self.h = gs.param("hello")
        self.m = gs.param("message")
Esempio n. 3
0
 def __init__(self):
     self.msg1fifo = gs.msgfifo("receiver")
     self.msg2fifo = gs.msgfifo()
     self.msg3fifo = gs.msgfifo("second_rx")
     gs.spawn(self.sender)
     gs.spawn(self.receiver)
     gs.spawn(self.internal)
     gs.spawn(self.rx2)
     gs.end_of_simulation(self.cb, args=("end-of-sim",))
     gs.end_of_elaboration(self.cb, args=("end-of-elab",))
     gs.start_of_simulation(self.cb, args=("start-of-sim",))
     tmp = no_process()
     print tmp.name, tmp.full_name
     tmp1 = no_process()
     print tmp1.name, tmp1.full_name
     tmp2 = no_process()
     print tmp2.name, tmp2.full_name
Esempio n. 4
0
# signal with initial value
prod = gs.signal(123)
# signal without initial value, defaults to False
cons = gs.signal()

def producer():
    print "producer:", gs.time(), "start"
    print "producer:", gs.time(), "write 3 to prod"
    prod.write(3)
    print "producer:", gs.time(), "read signal cons default:", cons.read()
    print "producer:", gs.time(), "wait for reply (write_event on cons)"
    gs.wait(cons.write_event())
    print "producer:", gs.time(), "read signal cons again:", cons.read()
    print "producer:", gs.time(), "end"

def consumer():
    print "consumer:", gs.time(), "start"
    print "consumer:", gs.time(), "read signal prod default:", prod.read()
    print "consumer:", gs.time(), "wait for input (write_event on prod)"
    gs.wait(prod.write_event())
    print "consumer:", gs.time(), "read signal prod again:", prod.read()
    print "consumer:", gs.time(), "double the input value and write back"
    cons.write(prod.read()*2)
    print "consumer:", gs.time(), "end"

gs.spawn(producer,"producer")
gs.spawn(consumer,"consumer")

gs.start()
Esempio n. 5
0
 def __init__(self):
     self.msgfifo = gs.msgfifo()
     gs.spawn(self.doit)
Esempio n. 6
0
 def __init__(self, out1, out2, in1):
     self.out1 = gs.sc_signal(out1)
     self.out2 = gs.sc_signal(out2)
     self.in1 = gs.sc_signal(in1)
     gs.spawn(self.generate)
     gs.spawn(self.compare)
Esempio n. 7
0
 def __init__(self, in1, out):
     self.in1 = in1
     self.out = out
     gs.spawn(self.doit)
     # Get memory contents as a parameter
     self.MEM = gs.param("MEM")
Esempio n. 8
0
    e3.notify(3)
    print "producer:", gs.time(), "notify e4 after 10ns"
    e4.notify(10)
    print "producer:", gs.time(), "end"


def consumer():

    tests = [ \
"(e1 & e2)",
    "((e1 | e2) & e3)",
    "(e1 & (e2 | e3))",
    "(e0 | e1 & e2 & e3 | e4)",
    "((e1 | e2) | (e3 & e4))",
             ]

    try:
        test = tests[int(sys.argv[1])]
    except:
        test = tests[1]

    print "consumer", gs.time(), "waiting for", test
    exec "gs.wait" + test
    print "consumer", gs.time(), "end"


gs.spawn(producer)
gs.spawn(consumer)

gs.start()
Esempio n. 9
0
    gs.wait(4, gs.US)
    print "test1:", gs.time(), "at this time e3 wasn't notifyed yet"
    print "test1:", gs.time(), "wait for 10 default units (ns)"
    gs.wait(10)

    print "test1:", gs.time(), "end"


def test2():
    print "test2:", gs.time(), "          start"

    print "test2:", gs.time(), "          waiting for e1"
    gs.wait(e1)
    print "test2:", gs.time(), "          e1 fired"

    print "test2:", gs.time(), "          waiting for e2"
    gs.wait(e2)
    print "test2:", gs.time(), "          e2 fired"

    print "test2:", gs.time(), "          waiting for e3"
    gs.wait(e3)
    print "test2:", gs.time(), "          e3 fired"

    print "test2:", gs.time(), "          end"


gs.spawn(test1, "test1")
gs.spawn(test2, "test2")

gs.start()
Esempio n. 10
0
gs.config_lua("test_gs_param.cfg.lua")

# Describe the system
addr = gs.fifo()
data = gs.fifo()
cpu1 = cpu(addr,data)
memory1 = memory(addr,data)

# Try an Array Parameter
ap = gs.param("test_array")
print ap
for a in ap: print a()+20

# Test the callbacks
def pp(x): print x
gs.end_of_elaboration(lambda: pp("eoe"))
gs.end_of_simulation(lambda: pp("ssss"))
gs.end_of_simulation(lambda: pp("eos"))

# A simple process to keep the kernel alive a bit
def goon():
  for i in range(4):
    gs.wait(25+25*i,gs.NS)
    print gs.simulation_time()
gs.spawn(goon)

# Start!
gs.start(100,gs.NS)
#gs.start()

Esempio n. 11
0
import gs
from IPython.Shell import IPShellEmbed

gs.spawn(IPShellEmbed())
Esempio n. 12
0
 def __init__(self):
     self.msgfifo = gs.msgfifo()
     gs.spawn(self.doit)
Esempio n. 13
0
 def __init__(self):
   gs.spawn(self.receiver)
   gs.spawn(self.sender)
Esempio n. 14
0
 def __init__(self):
     self.msgfifo = gs.msgfifo("sender")
     gs.spawn(self.doit)
Esempio n. 15
0
    gs.wait(4, gs.US)
    print "test1:", gs.time(), "at this time e3 wasn't notifyed yet"
    print "test1:", gs.time(), "wait for 10 default units (ns)"
    gs.wait(10)

    print "test1:", gs.time(), "end"


def test2():
    print "test2:", gs.time(), "          start"

    print "test2:", gs.time(), "          waiting for e1"
    gs.wait(e1)
    print "test2:", gs.time(), "          e1 fired"

    print "test2:", gs.time(), "          waiting for e2"
    gs.wait(e2)
    print "test2:", gs.time(), "          e2 fired"

    print "test2:", gs.time(), "          waiting for e3"
    gs.wait(e3)
    print "test2:", gs.time(), "          e3 fired"

    print "test2:", gs.time(), "          end"


gs.spawn(test1,"test1")
gs.spawn(test2,"test2")

gs.start()
Esempio n. 16
0
 def __init__(self, req, ack):
     self.req = req
     self.ack = ack
     gs.spawn(self.doit)
     self.testparam = gs.param("foo.bar.zoo")
Esempio n. 17
0
# Try an Array Parameter
ap = gs.param("test_array")
print ap
for a in ap:
    print a() + 20


# Test the callbacks
def pp(x):
    print x


gs.end_of_elaboration(lambda: pp("eoe"))
gs.end_of_simulation(lambda: pp("ssss"))
gs.end_of_simulation(lambda: pp("eos"))


# A simple process to keep the kernel alive a bit
def goon():
    for i in range(4):
        gs.wait(25 + 25 * i, gs.NS)
        print gs.simulation_time()


gs.spawn(goon)

# Start!
gs.start(100, gs.NS)
#gs.start()
Esempio n. 18
0
 def __init__(self, in1, out):
     self.in1 = in1
     self.out = out
     gs.spawn(self.doit)
     # Get memory contents as a parameter
     self.MEM = gs.param("MEM")
Esempio n. 19
0
# signal without initial value, defaults to False
cons = gs.signal()


def producer():
    print "producer:", gs.time(), "start"
    print "producer:", gs.time(), "write 3 to prod"
    prod.write(3)
    print "producer:", gs.time(), "read signal cons default:", cons.read()
    print "producer:", gs.time(), "wait for reply (write_event on cons)"
    gs.wait(cons.write_event())
    print "producer:", gs.time(), "read signal cons again:", cons.read()
    print "producer:", gs.time(), "end"


def consumer():
    print "consumer:", gs.time(), "start"
    print "consumer:", gs.time(), "read signal prod default:", prod.read()
    print "consumer:", gs.time(), "wait for input (write_event on prod)"
    gs.wait(prod.write_event())
    print "consumer:", gs.time(), "read signal prod again:", prod.read()
    print "consumer:", gs.time(), "double the input value and write back"
    cons.write(prod.read() * 2)
    print "consumer:", gs.time(), "end"


gs.spawn(producer, "producer")
gs.spawn(consumer, "consumer")

gs.start()
Esempio n. 20
0
import gs
from code import InteractiveConsole

gs.spawn(InteractiveConsole().interact)
Esempio n. 21
0
 def __init__(self, name = None):
   gs.writeif_base.__init__(self, name)
   self.nf = 2
   self.nu = 0
   if not name is None:  gs.spawn(self.pop)
Esempio n. 22
0
 def __init__(self, in1, in2, out):
     self.in1 = gs.sc_signal(in1)
     self.in2 = gs.sc_signal(in2)
     self.out = gs.sc_signal(out)
     gs.spawn(self.doit)
Esempio n. 23
0
        print gs.time(), name+"\t", num
        if num <> last: gs.wait(1)
    print gs.time(), name+"\t", "finished"


def fork_example():
    print "fork_example:", gs.time(), "     start"
    gs.fork( [lambda: counter("a",9),
              lambda: counter("bb",5),
              lambda: counter("ccc",7),
              lambda: counter("dddd",15),
              ],
             wait_for = 2,
             kill = True,
             debug = False)
    print "fork_example:", gs.time(), "     finish"

def fork_example_args():
    gs.wait(100)
    print "fork_example_args:", gs.time(), "     start"
    gs.fork([counter]*4,
      args=[("a",9),("bb",5),(),()],
      keyargs=[{},{},dict(name="ccc",last=7),dict(name="dddd",last=15)])
    print "fork_example_args:", gs.time(), "     finish"


gs.spawn(fork_example)
gs.spawn(fork_example_args)

gs.start()
Esempio n. 24
0
 def __init__(self, req, ack):
     self.req = req
     self.ack = ack
     gs.spawn(self.doit)
     self.testparam = gs.param("foo.bar.zoo")
Esempio n. 25
0
 def __init__(self, input_p=None, output_p=None):
     self.input = input_p
     self.output = output_p
     gs.spawn(self.doit)
Esempio n. 26
0
def fork_example():
    print "fork_example:", gs.time(), "     start"
    gs.fork([
        lambda: counter("a", 9),
        lambda: counter("bb", 5),
        lambda: counter("ccc", 7),
        lambda: counter("dddd", 15),
    ],
            wait_for=2,
            kill=True,
            debug=False)
    print "fork_example:", gs.time(), "     finish"


def fork_example_args():
    gs.wait(100)
    print "fork_example_args:", gs.time(), "     start"
    gs.fork([counter] * 4,
            args=[("a", 9), ("bb", 5), (), ()],
            keyargs=[{}, {},
                     dict(name="ccc", last=7),
                     dict(name="dddd", last=15)])
    print "fork_example_args:", gs.time(), "     finish"


gs.spawn(fork_example)
gs.spawn(fork_example_args)

gs.start()
Esempio n. 27
0
 def __init__(self, in1, in2, out):
     self.in1 = gs.sc_signal(in1)
     self.in2 = gs.sc_signal(in2)
     self.out = gs.sc_signal(out)
     gs.spawn(self.doit)
Esempio n. 28
0
def consumer():
    print "consumer:", gs.time(), "start"
    data = f.read()
    print "consumer:", gs.time(), "read ", data
    data = f.read()
    print "consumer:", gs.time(), "read ", data
    data = f.read()
    print "consumer:", gs.time(), "read ", data
    data = f.read()
    print "consumer:", gs.time(), "read ", data
    print "consumer:", gs.time(), "end"

    # cons_unlim()


gs.spawn(producer, "producer", False)
gs.spawn(consumer, "consumer", False)


unlimited = gs.fifo()

def prod_unlim():
  x = 100
  while x < 1000:
    gs.wait(1,gs.US)
    nr_to_write = x + random.randint(1,50)
    print "P Load now", unlimited.num_available()
    print "Writing to", nr_to_write-1
    while x < nr_to_write:
      unlimited.write(x)
      x += 1
Esempio n. 29
0
 def __init__(self, req, ack):
     self.req = req
     self.ack = ack
     gs.spawn(self.doit)
     self.configure_gav_output()
Esempio n. 30
0
 def __init__(self, input_p=None, output_p=None):
     self.input = input_p
     self.output = output_p
     gs.spawn(self.doit)
Esempio n. 31
0
 def __init__(self):
     gs.spawn(self.receiver)
     gs.spawn(self.sender)
Esempio n. 32
0
    print "controler:", gs.time(), "start"

    print "controler:", gs.time(), "waiting 5 ns to pause thread", thread.name
    gs.wait(5, gs.NS)
    print "controler:", gs.time(), "pausing thread", thread.name, "NOW!"
    thread.pause()
    print "controler:", gs.time(), "waiting 3 ns to resume thread", thread.name
    gs.wait(3)
    print "controler:", gs.time(), "resuming thread", thread.name, "NOW!"
    thread.resume()

    print "controler:", gs.time(), "waiting 5 ns to pause thread", thread.name
    gs.wait(5, gs.NS)
    print "controler:", gs.time(), "pausing thread", thread.name, "NOW!"
    thread.pause()
    print "controler:", gs.time(), "waiting 3 ns to resume thread", thread.name
    gs.wait(3)
    print "controler:", gs.time(), "resuming thread", thread.name, "NOW!"
    thread.resume()

    print "controler:", gs.time(), "waiting 10 ns to kill thread", thread.name
    gs.wait(10)
    print "controler:", gs.time(), "killing thread", thread.name, "NOW!"
    thread.kill()


prod = gs.spawn(producer)
gs.spawn(lambda:controler(prod))

gs.start()
Esempio n. 33
0
 def __init__(self):
     self.msgfifo = gs.msgfifo("sender")
     gs.spawn(self.doit)
Esempio n. 34
0
 def __init__(self):
     self.msgfifo = gs.msgfifo("receiver")
     gs.spawn(self.doit)
Esempio n. 35
0
    e2.notify(5)
    print "producer:", gs.time(), "notify e3 after 3ns"
    e3.notify(3)
    print "producer:", gs.time(), "notify e4 after 10ns"
    e4.notify(10)
    print "producer:", gs.time(), "end"


def consumer():

    tests = [ \
"(e1 & e2)",
"((e1 | e2) & e3)",
"(e1 & (e2 | e3))",
"(e0 | e1 & e2 & e3 | e4)",
"((e1 | e2) | (e3 & e4))",
]

    try:  test = tests[int(sys.argv[1])]
    except:  test = tests[1]

    print "consumer", gs.time(), "waiting for", test
    exec "gs.wait" + test
    print "consumer", gs.time(), "end"


gs.spawn(producer)
gs.spawn(consumer)

gs.start()
Esempio n. 36
0
 def __init__(self, req, ack):
     self.req = req
     self.ack = ack
     gs.spawn(self.doit)
     self.configure_gav_output()
Esempio n. 37
0
 def __init__(self):
     self.msgfifo = gs.msgfifo("receiver")
     gs.spawn(self.doit)
Esempio n. 38
0
    print "controler:", gs.time(), "start"

    print "controler:", gs.time(), "waiting 5 ns to pause thread", thread.name
    gs.wait(5, gs.NS)
    print "controler:", gs.time(), "pausing thread", thread.name, "NOW!"
    thread.pause()
    print "controler:", gs.time(), "waiting 3 ns to resume thread", thread.name
    gs.wait(3)
    print "controler:", gs.time(), "resuming thread", thread.name, "NOW!"
    thread.resume()

    print "controler:", gs.time(), "waiting 5 ns to pause thread", thread.name
    gs.wait(5, gs.NS)
    print "controler:", gs.time(), "pausing thread", thread.name, "NOW!"
    thread.pause()
    print "controler:", gs.time(), "waiting 3 ns to resume thread", thread.name
    gs.wait(3)
    print "controler:", gs.time(), "resuming thread", thread.name, "NOW!"
    thread.resume()

    print "controler:", gs.time(), "waiting 10 ns to kill thread", thread.name
    gs.wait(10)
    print "controler:", gs.time(), "killing thread", thread.name, "NOW!"
    thread.kill()


prod = gs.spawn(producer)
gs.spawn(lambda: controler(prod))

gs.start()
Esempio n. 39
0
  it = 0
  while True:
    print "faster", "reached iteration", it
    gs.wait(33,gs.NS)
    it = it + 1
    print "loop starts"
    for i in range(40):
      print 'p',
      for j in range(1000): pass
    print
    print "signal is now", mysig.read()


if use_wind:  gs.use_winpdb()

gs.spawn(lambda : f(100, "slow"), debug = to_debug[0])
gs.spawn(lambda : f(55, "fast"), "fast", to_debug[1], time_unit = gs.MS)
gs.spawn(g, "faster", to_debug[2], time_unit = gs.MS)

def hello():
  print "hello there at end of elab"
  print "and start of sim"
gs.end_of_elaboration(hello)
gs.start_of_simulation(hello)

def goodbye():
  print "goodbye at end of sim"
gs.end_of_simulation(goodbye)

print "processes declared"