-
Notifications
You must be signed in to change notification settings - Fork 21
/
client.cc
55 lines (36 loc) · 1.05 KB
/
client.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2024 Zero ASIC Corporation
// This code is licensed under Apache License 2.0 (see LICENSE for details)
#include "switchboard.hpp"
#define NBYTES 32
int main() {
SBTX tx;
SBRX rx;
// initialize connections
tx.init("to_rtl.q");
rx.init("from_rtl.q");
// form packet
sb_packet txp;
for (int i = 0; i < NBYTES; i++) {
txp.data[i] = i & 0xff;
}
txp.destination = 0xbeefcafe;
txp.last = true;
// send packet
tx.send_blocking(txp);
printf("TX packet: %s\n", sb_packet_to_str(txp, NBYTES).c_str());
// receive packet
sb_packet rxp;
rx.recv_blocking(rxp);
printf("RX packet: %s\n", sb_packet_to_str(rxp, NBYTES).c_str());
for (int i = 0; i < NBYTES; i++) {
assert(rxp.data[i] == (txp.data[i] + 1));
}
// send a packet that will end the test
for (int i = 0; i < NBYTES; i++) {
txp.data[i] = 0xff;
}
tx.send_blocking(txp);
// declare test as having passed for regression testing purposes
printf("PASS!\n");
return 0;
}