mirror of
https://github.com/saymrwulf/pqc-accelerate.git
synced 2026-05-14 20:48:07 +00:00
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
#include "test_case.h"
|
|
|
|
int main() {
|
|
// Top-level AXI4-Stream ports for the DUT
|
|
hls::stream<coeff_axis_big_t> in_data;
|
|
hls::stream<coeff_axis_t> out_data;
|
|
coeff_axis_big_t local_stream1;
|
|
coeff_axis_t local_stream2;
|
|
coeff_t actual_outputs[Nt];
|
|
int i;
|
|
|
|
// Write input stimuli into input AXI4-Stream
|
|
for (i = 0; i < Nt; i++) {
|
|
coeff_t val1 = input1_vals[i];
|
|
double_coeff_t val2 = (double_coeff_t) input2_vals[i] << 24;
|
|
// Pack two 24-bit values into one 48-bit word (stored in ap_axiu<48>)
|
|
local_stream1.data = (ap_uint<48>) ((ap_uint<48>) val1 | (ap_uint<48>) val2);
|
|
local_stream1.keep = -1;
|
|
local_stream1.strb = -1;
|
|
local_stream1.last = (i == Nt - 1) ? 1 : 0;
|
|
in_data.write(local_stream1);
|
|
}
|
|
|
|
// Call DUT
|
|
poly_mult(in_data, out_data);
|
|
|
|
// Read results from output AXI4-Stream
|
|
for (i = 0; i < Nt; i++) {
|
|
local_stream2 = out_data.read();
|
|
actual_outputs[i] = (coeff_t) local_stream2.data;
|
|
// (Optionally check local_stream2.last here)
|
|
}
|
|
|
|
// Compare against golden output
|
|
int ret_val = 0;
|
|
for (i = 0; i < Nt; i++) {
|
|
if (output_vals[i] != actual_outputs[i]) {
|
|
ret_val++;
|
|
std::cout << "Mismatch at index " << i
|
|
<< ": expected " << output_vals[i]
|
|
<< ", got " << actual_outputs[i] << std::endl;
|
|
break;
|
|
}
|
|
}
|
|
return ret_val;
|
|
}
|