2from esi.types
import FunctionPort
6from typing
import List, cast
10acc = acc_conn.build_accelerator()
12print(
"***** Testing add function")
14add = cast(FunctionPort, acc.ports[
esi.AppID(
"add")])
19 return (a + b + sum(arr)) % 2**8
23 a = random.randint(0, 2**8 - 1)
24 b = random.randint(0, 2**8 - 1)
25 arr = [random.randint(0, 2**8 - 1)
for _
in range(16)]
28 print(f
"call(a={a}, b={b}, arr={arr})")
30 resp =
add(a=a, b=b, arr=arr).result()
32 print(f
" = {resp} (expected {expected})")
34 print(f
" = {resp} (matches Python result)")
37input(
"Press Enter to continue...")
40print(
"***** Testing compute_crc function")
42compute_crc = cast(FunctionPort, acc.ports[
esi.AppID(
"crc")])
45data = [random.randint(0, 2**8 - 1)
for _
in range(64)]
46crc =
compute_crc(identifier=0, input=data, input_bytes=64, reset=1).result()
50new_data = [random.randint(0, 2**8 - 1)
for _
in range(64)]
51crc =
compute_crc(identifier=0, input=new_data, input_bytes=64,
53print(f
"crc({new_data})")
static void print(TypedAttr val, llvm::raw_ostream &os)
Abstract class representing a connection to an accelerator.
int add_golden(int a, int b, List[int] arr)