Exemple #1
0
def run(latency):
    @mint.proc()
    def sender():
        a.framer.send('\x12\x34\x56\x78')
        yield mint.end

    @mint.proc()
    def receiver():
        data = yield b.framer.recv()
        print 'bytes recv by {}: {}'.format(b, fmt(data, 'hex'))
        data = yield b.framer.recv()
        print 'bytes recv by {}: {}'.format(b, fmt(data, 'hex'))
        print 'bits ever received at {}: {}'.format(
                b.port,
                fmt(utils.unbitify(b.port.bits_received), 'bin'))
        print 'bits ever received at {} (shifted): {}'.format(
                b.port,
                fmt(utils.unbitify(b.port.bits_received[3:]), 'hex'))
        raise mint.Stop
        yield mint.end

    a = PC('a')
    b = PC('b')
    link = Link(a, b)
    link.latency = latency
Exemple #2
0
def run(sep, latency):
    @mint.proc()
    def sender():
        a.port.put('\xff')
        yield mint.env.timeout(sep)
        a.port.put('\xff')
        yield mint.end

    @mint.proc()
    def receiver():
        data = yield b.recv(4)
        print 'Received at {}: {}'.format(mint.env.now, fmt(data, 'hex'))
        print '                {}'.format(fmt(data, 'bin'))
        raise mint.Stop
        yield mint.end

    a = PC('a')
    b = PC('b')
    link = Link(a, b)
    link.latency = latency
Exemple #3
0
def link(*args, **kwargs):
    return Link(*args, **kwargs)
Exemple #4
0
threaded version simpy
entity and port as real thread

a sends 111
b sends 10101
latency == 3
b recv 000111
a recv 00010101
'''
import time
import mint
from mint.components import Endpoint, Link

a = Endpoint('a')
b = Endpoint('b')
link = Link(a, b)

a_data = '111'
b_data = '10101'
latency = 3
link.latency = latency

@mint.proc
def sender():
    a.port.send(a_data)
    print '{} recv: {}'.format(a, a.port.recv(len(b_data) + latency))
    print 'now is {}'.format(mint.env.now)

@mint.proc
def receiver():
    b.port.send(b_data)
Exemple #5
0
    print 'Now is {}'.format(net.env.now)
    print '{:1} -> {:<28} {:>2} >-> {:<2} {:>28} -> {:1}'.format(
        pc1.name, ''.join(list(reversed(pc1.port.obuffer))),
        ''.join(list(reversed(link.ports[0].ibuffer))),
        ''.join(list(reversed(link.ports[1].obuffer))),
        ''.join(list(reversed(pc2.port.ibuffer))), pc2.name)
    print '{:1} <- {:<28} {:>2} <-< {:<2} {:>28} <- {:1}'.format(
        pc1.name, pc1.port.ibuffer, link.ports[0].obuffer,
        link.ports[1].ibuffer, pc2.port.obuffer, pc2.name)
    raw_input()
    #import code
    #code.interact(local=globals())


@mint.proc()
def sender():
    pc1.port.put('\x01\x02')
    yield mint.end


@mint.proc()
def receiver():
    #print 'Received:', pc2.recv(2)
    yield mint.end


pc1 = PC('a')
pc2 = PC('b')
link = Link(pc1, pc2)
mint.run(monitor=monitor)