Exemplo n.º 1
0
def get_dev():
    dev = tb.get_dev()
    d = {}
    execfile("../terminals.py", d)
    
    di=d["di"]
    t = di["UART"].clone()
    t.addr = di["UART"].addr + 2
    t.name = "UART2"
    di.add_child(t)
    t = di["UART_CTRL"].clone()
    t.addr = di["UART_CTRL"].addr + 2
    t.name = "UART_CTRL2"
    di.add_child(t)
    
    dev.set_di(di)
    
    return dev
Exemplo n.º 2
0
import VUART_tb as tb
import logging, numpy
logging.basicConfig(level=logging.DEBUG)

if 1:
    tb.init("sim.vcd")
else:
    tb.init()

dev = tb.get_dev()
d = {}
execfile("../terminals.py", d)
dev.set_di(d["di"])

dev.set("UART_CTRL", "clk_div", 16) # speed up clock

def check():
    a = (numpy.random.rand(16) * 255).astype(numpy.uint16)
    dev.write("UART", 0, a)
    b = numpy.zeros_like(a)
    dev.read("UART", 0, b)
    return (b==a).all()

def checkN(N):
    for i in range(N):
        if check():
            passing += 1
        else:
            failing += 1

dev.set("UART", 0, 0x01)