示例#1
0
def axil_write(axi, addr, data, timeout=100):
    yield from write_to_stream(axi.write_address, payload=addr)
    yield from write_to_stream(axi.write_data, payload=data)
    response = (yield from read_from_stream(axi.write_response,
                                            extract="resp",
                                            timeout=timeout))
    assert AxiResponse.OKAY.value == response
示例#2
0
def axil_read(axi, addr, timeout=100):
    yield from write_to_stream(axi.read_address, payload=addr)
    value, response = (yield from read_from_stream(axi.read_data,
                                                   extract=("payload", "resp"),
                                                   timeout=timeout))
    assert AxiResponse.OKAY.value == response
    return value
示例#3
0
 def write_process():
     yield from write_frame_to_stream(input, testdata, pause=True)
     yield Passive()
     while True:
         yield from write_to_stream(input,
                                    line_last=0,
                                    frame_last=0,
                                    payload=0)
示例#4
0
 def writer():
     last_count_gold = 0
     for i in range(50):
         last = (i % 5 == 0)
         last_count_gold += last
         yield from write_to_stream(input, payload=0, last=(i % 5 == 0))
         if i % 3 == 0:
             yield from do_nothing()
     self.assertEqual(last_count_gold, 10)
示例#5
0
 def writer():
     yield from write_to_stream(input, payload=0b001)
     yield from write_to_stream(input, payload=0b010)
     yield from write_to_stream(input, payload=0b100)
     yield from write_to_stream(input, payload=0b011)
     yield from write_to_stream(input, payload=0b110)
     yield from write_to_stream(input, payload=0b111)
     yield from write_to_stream(input, payload=0b000)
示例#6
0
 def write_process():
     testdata = [[x * y for x in range(width)] for y in range(height)]
     yield from write_frame_to_stream(input, testdata, pause=True)
     yield from write_frame_to_stream(input, testdata, pause=True)
     yield from write_frame_to_stream(input, testdata, pause=True)
     yield Passive()
     while True:
         yield from write_to_stream(input,
                                    line_last=0,
                                    frame_last=0,
                                    payload=0)
示例#7
0
def answer_read_burst(axi: AxiEndpoint, memory: Dict[int, int], timeout=100):
    addr, burst_len, burst_type, beat_size_bytes = yield from read_from_stream(
        axi.read_address,
        ("payload", "burst_len", "burst_type", "beat_size_bytes"), timeout)
    assert 2**beat_size_bytes == axi.data_bytes
    assert burst_type == AxiBurstType.INCR.value
    print("read", addr, burst_len)

    for i in range(burst_len + 1):
        yield from write_to_stream(axi.read_data,
                                   payload=memory[addr + (i * axi.data_bytes)],
                                   resp=AxiResponse.OKAY,
                                   last=(i == burst_len),
                                   timeout=timeout)
示例#8
0
def answer_write_burst(axi: AxiEndpoint, timeout=100):
    memory = {}
    addr, burst_len, burst_type, beat_size_bytes = yield from read_from_stream(
        axi.write_address,
        ("payload", "burst_len", "burst_type", "beat_size_bytes"), timeout)
    assert 2**beat_size_bytes == axi.data_bytes
    assert burst_type == AxiBurstType.INCR.value
    accepted = 0
    for i in range(burst_len + 1):
        value, last, byte_strobe = yield from read_from_stream(
            axi.write_data, ("payload", "last", "byte_strobe"), timeout)
        if i == burst_len:
            assert last
        else:
            pass
            assert not last
        if byte_strobe != 0:
            memory[addr + i * axi.data_bytes] = value
            accepted += 1
    write_to_stream(axi.write_response, resp=AxiResponse.OKAY)
    print("wrote", memory)

    return memory, accepted
示例#9
0
def write_frame_to_stream(stream, frame, timeout=100, pause=False):
    random = Random(0)
    for y, line in enumerate(frame):
        for x, px in enumerate(line):
            if (random.random() < 0.3) and pause:
                yield from do_nothing()
            yield from write_to_stream(
                stream,
                payload=int(px),
                timeout=timeout,
                line_last=(x == (len(line) - 1)),
                frame_last=(y == (len(frame) - 1)) & (x == (len(line) - 1)),
            )
        if (random.random() < 0.3) and pause:
            yield from do_nothing()
示例#10
0
 def write_address_process():
     for addr in read_sequence:
         yield from write_to_stream(address_stream, payload=addr)
示例#11
0
 def writer():
     yield from write_to_stream(input, payload=payload_a, last=1)
     yield from write_to_stream(input, payload=payload_b, last=0)
示例#12
0
 def writer():
     for v in input_data:
         yield from write_to_stream(input, payload=v)
示例#13
0
 def writer():
     for i in range(0, 100, 2):
         yield from write_to_stream(input, payload=(((i + 1) << 8) | i))
         if i % 7 == 0:
             yield from do_nothing()
示例#14
0
 def writer():
     yield from write_to_stream(input, payload=0b0_010_001)
     yield from write_to_stream(input, payload=0b10_011_10)
     yield from write_to_stream(input, payload=0b000_111_1)
示例#15
0
 def writer():
     yield Passive()
     random.seed(0)
     while True:
         yield from write_to_stream(input, payload=random.randrange(0, 2**12))
示例#16
0
 def write_process():
     for i in range(128):
         yield from write_to_stream(address_stream,
                                    payload=i,
                                    last=(i % 8) == 0)
     yield Passive()
示例#17
0
 def write_process():
     yield from write_frame_to_stream(input, image, pause=False)
     yield Passive()
     yield from write_frame_to_stream(input, image, pause=False)
     while True:
         yield from write_to_stream(input, line_last=0, frame_last=0, payload=0)
示例#18
0
 def writer():
     yield from write_to_stream(input, payload=0b00_10_00_01, last=1)
     yield from write_to_stream(input, payload=0b10_00_01_00, last=0)
示例#19
0
 def write_process():
     for i, c in enumerate(input_data):
         yield from write_to_stream(input,
                                    payload=ord(c),
                                    last=(i == len(input_data) - 1))