示例#1
0
import numpy as np
import dsim

a = np.array([0, 1, 2, 3, 4])
b = np.array([0, 1, 2, 3, 4])
c = np.array([0, 0, 0, 0, 0])

a_s = dsim.DArray(a)
b_s = dsim.DArray(b)
c_s = dsim.DArray(c)

hw_lib_path = "./hardware/chisel/build/libhw.so"

cycle = dsim.sim(ptrs=[a_s, b_s, c_s], vars=[5, 5], hwlib=hw_lib_path)

print("Cycle: " + str(cycle))
print(a_s.getData())
print(b_s.getData())
print(c_s.getData())
示例#2
0
import numpy as np
import platform
import dsim

def test05(a):
    a_len = 10
    for i in range(0, a_len):
        a[i] = 2 * a[i]
    return a



if platform.system() == 'Linux':
    hw_lib_path = "./hardware/chisel/build/libhw.so"
elif platform.system() == 'Darwin':
    hw_lib_path = "./hardware/chisel/build/libhw.dylib"

val_a = list(range(1, 11))
print(val_a)
a_s = dsim.DArray(val_a, dsim.DArray.DType.DWord)

events = dsim.sim(ptrs = [a_s], vars= [], numRets=1, numEvents=1, hwlib = hw_lib_path)

print("Cycle: " + str(events[0]))
print("Output array:\n\t")
print(a_s.getData())
print(test05(val_a))
示例#3
0
        if a > b:
            a -= b
        else:
            b -= a
        i += 1

    return a * b


if platform.system() == 'Linux':
    hw_lib_path = "./hardware/chisel/build/libhw.so"
elif platform.system() == 'Darwin':
    hw_lib_path = "./hardware/chisel/build/libhw.dylib"

val_a = 50
val_b = 5

events = dsim.sim(ptrs=[],
                  vars=[val_a, val_b],
                  numRets=1,
                  numEvents=1,
                  hwlib=hw_lib_path)

print("Cycle: " + str(events[0]))

if events[1] == test06(val_a, val_b):
    print("Success!\nRet: " + str(events[1]))
else:
    print("Failed!\nExpected {0}, but Returned: {1}".format(
        str(test06(val_a, val_b)), str(events[1])))