HLS: Changes to allow cosimulation with Vitis HLS
This commit is contained in:
@@ -26,7 +26,7 @@ ADD_LIBRARY( HLSSimulation STATIC
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES(HLSSimulation PUBLIC ../include)
|
||||
TARGET_LINK_LIBRARIES(HLSSimulation CommonFunctions)
|
||||
TARGET_COMPILE_DEFINITIONS(HLSSimulation PRIVATE -DNO_SYNTH)
|
||||
TARGET_COMPILE_DEFINITIONS(HLSSimulation PUBLIC -DJFJOCH_HLS_NOSYNTH)
|
||||
|
||||
IF(VIVADO_HLS)
|
||||
|
||||
|
||||
@@ -322,7 +322,7 @@ void bitshuffle(STREAM_512 &data_in, STREAM_512 &data_out) {
|
||||
BSHUF_STREAM fifo_4_3;
|
||||
#pragma HLS STREAM variable=fifo_4_3 depth=32
|
||||
|
||||
#ifdef __SYNTHESIS__
|
||||
#ifndef JFJOCH_HLS_NOSYNTH
|
||||
bshuf256(data_in, fifo_0);
|
||||
bshuf1k_axis_split(fifo_0, fifo_1_0, fifo_1_1, fifo_1_2, fifo_1_3);
|
||||
bshuf1k_axis_combine(fifo_1_0, fifo_1_1, fifo_1_2, fifo_1_3, fifo_2);
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
|
||||
|
||||
#ifndef JUNGFRAUJOCH_HLS_JFJOCH_H
|
||||
#define JUNGFRAUJOCH_HLS_JFJOCH_H
|
||||
|
||||
#include <ap_int.h>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <hls_burst_maxi.h>
|
||||
|
||||
#ifdef __SYNTHESIS__
|
||||
#ifndef JFJOCH_HLS_NOSYNTH
|
||||
#include <ap_axi_sdata.h>
|
||||
#include <hls_stream.h>
|
||||
#include <hls_burst_maxi.h>
|
||||
#else
|
||||
#include "../include/hls_burst_maxi.h"
|
||||
#include "parallel_stream.h"
|
||||
#endif
|
||||
|
||||
@@ -31,7 +29,7 @@ typedef ap_ufixed<16,12, AP_RND_CONV> strong_pixel_threshold_t;
|
||||
|
||||
typedef ap_uint<256> hbm256_t;
|
||||
|
||||
#ifndef __SYNTHESIS__
|
||||
#ifdef JFJOCH_HLS_NOSYNTH
|
||||
template<int D,int U,int TI,int TD>
|
||||
struct ap_axiu{
|
||||
ap_uint<D> data;
|
||||
|
||||
+10
-18
@@ -361,6 +361,7 @@ void spot_finder(STREAM_512 &data_in,
|
||||
hls::stream<ap_axiu<32,1,1,1>> &strong_pixel_out,
|
||||
volatile ap_int<16> &in_photon_count_threshold,
|
||||
volatile ap_uint<16> &in_strong_pixel_threshold) {
|
||||
// Comment line below for Vitis HLS Cosimulation
|
||||
#pragma HLS INTERFACE ap_ctrl_none port=return
|
||||
#pragma HLS DATAFLOW
|
||||
|
||||
@@ -370,37 +371,28 @@ void spot_finder(STREAM_512 &data_in,
|
||||
#pragma HLS INTERFACE ap_none register port=in_photon_count_threshold
|
||||
#pragma HLS INTERFACE ap_none register port=in_strong_pixel_threshold
|
||||
|
||||
hls::stream<spot_finder_packet> data_stream_0, data_stream_1, data_stream_2;
|
||||
hls::stream<ap_uint<SUM_BITWIDTH*32>> sum_stream_0, sum_stream_1, sum_stream_2;
|
||||
hls::stream<ap_uint<SUM2_BITWIDTH*32>> sum2_stream_0, sum2_stream_1, sum2_stream_2;
|
||||
hls::stream<ap_uint<MASK_SUM_BITWIDTH*32>> valid_stream_0, valid_stream_1, valid_stream_2;
|
||||
#pragma HLS STREAM variable=data_stream_0 depth=512 type=fifo
|
||||
hls::stream<spot_finder_packet, 256> data_stream_0;
|
||||
hls::stream<spot_finder_packet, 8> data_stream_1, data_stream_2;
|
||||
hls::stream<ap_uint<SUM_BITWIDTH*32>, 16> sum_stream_0;
|
||||
hls::stream<ap_uint<SUM_BITWIDTH*32>, 8> sum_stream_1, sum_stream_2;
|
||||
hls::stream<ap_uint<SUM2_BITWIDTH*32>, 16> sum2_stream_0;
|
||||
hls::stream<ap_uint<SUM2_BITWIDTH*32>, 8> sum2_stream_1, sum2_stream_2;
|
||||
hls::stream<ap_uint<MASK_SUM_BITWIDTH*32>, 16> valid_stream_0;
|
||||
hls::stream<ap_uint<MASK_SUM_BITWIDTH*32>, 8> valid_stream_1, valid_stream_2;
|
||||
#pragma HLS bind_storage variable=data_stream_0 type=fifo impl=bram
|
||||
#pragma HLS STREAM variable=data_stream_1 depth=64 type=fifo
|
||||
#pragma HLS bind_storage variable=data_stream_1 type=fifo impl=bram
|
||||
#pragma HLS STREAM variable=data_stream_2 depth=64 type=fifo
|
||||
#pragma HLS bind_storage variable=data_stream_2 type=fifo impl=bram
|
||||
|
||||
#pragma HLS STREAM variable=sum_stream_0 depth=512 type=fifo
|
||||
#pragma HLS bind_storage variable=sum_stream_0 type=fifo impl=bram
|
||||
#pragma HLS STREAM variable=sum_stream_1 depth=64 type=fifo
|
||||
#pragma HLS bind_storage variable=sum_stream_1 type=fifo impl=bram
|
||||
#pragma HLS STREAM variable=sum_stream_2 depth=64 type=fifo
|
||||
#pragma HLS bind_storage variable=sum_stream_2 type=fifo impl=bram
|
||||
#pragma HLS STREAM variable=sum2_stream_0 depth=512 type=fifo
|
||||
#pragma HLS bind_storage variable=sum2_stream_0 type=fifo impl=bram
|
||||
#pragma HLS STREAM variable=sum2_stream_1 depth=64 type=fifo
|
||||
#pragma HLS bind_storage variable=sum2_stream_1 type=fifo impl=bram
|
||||
#pragma HLS STREAM variable=sum2_stream_2 depth=64 type=fifo
|
||||
#pragma HLS bind_storage variable=sum2_stream_2 type=fifo impl=bram
|
||||
#pragma HLS STREAM variable=valid_stream_0 depth=512 type=fifo
|
||||
#pragma HLS bind_storage variable=valid_stream_0 type=fifo impl=bram
|
||||
#pragma HLS STREAM variable=valid_stream_1 depth=64 type=fifo
|
||||
#pragma HLS bind_storage variable=valid_stream_1 type=fifo impl=bram
|
||||
#pragma HLS STREAM variable=valid_stream_2 depth=64 type=fifo
|
||||
#pragma HLS bind_storage variable=valid_stream_2 type=fifo impl=bram
|
||||
|
||||
#ifdef __SYNTHESIS__
|
||||
#ifndef JFJOCH_HLS_NOSYNTH
|
||||
spot_finder_col_sum(data_in, data_stream_0, sum_stream_0, sum2_stream_0, valid_stream_0);
|
||||
spot_finder_line_sum(data_stream_0, data_stream_1,
|
||||
sum_stream_0, sum2_stream_0, valid_stream_0,
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "hls_jfjoch.h"
|
||||
#include <thread>
|
||||
|
||||
int main() {
|
||||
|
||||
int ret = 0;
|
||||
|
||||
STREAM_512 input;
|
||||
STREAM_512 output;
|
||||
hls::stream<ap_axiu<32, 1, 1, 1>> strong_pixel;
|
||||
|
||||
ap_int<16> in_photon_count_threshold = 8;
|
||||
ap_uint<16> in_strong_pixel_threshold = 16;
|
||||
|
||||
std::vector<int16_t> input_frame(4 * RAW_MODULE_SIZE), output_frame(
|
||||
RAW_MODULE_SIZE);
|
||||
for (int i = 0; i < 4 * RAW_MODULE_SIZE; i++) {
|
||||
if (i % RAW_MODULE_COLS == 1023)
|
||||
input_frame[i] = INT16_MIN;
|
||||
else
|
||||
input_frame[i] = i % RAW_MODULE_COLS;
|
||||
}
|
||||
auto input_frame_512 = (ap_uint<512>*) input_frame.data();
|
||||
auto output_frame_512 = (ap_uint<512>*) output_frame.data();
|
||||
|
||||
input << packet_512_t { .user = 0 };
|
||||
for (int i = 0; i < 4 * RAW_MODULE_SIZE * sizeof(uint16_t) / 64; i++)
|
||||
input << packet_512_t { .data = input_frame_512[i], .user = 0 };
|
||||
|
||||
input << packet_512_t { .user = 1 };
|
||||
|
||||
spot_finder(input, output, strong_pixel, in_photon_count_threshold,
|
||||
in_strong_pixel_threshold);
|
||||
|
||||
if (input.size() != 0)
|
||||
ret = 1;
|
||||
if (output.size() != 4 * RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 2)
|
||||
ret = 1;
|
||||
for (int i = 0; i < 4 * RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 2; i++)
|
||||
output.read();
|
||||
|
||||
if (strong_pixel.size() != 4 * RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 1)
|
||||
ret = 1;
|
||||
for (int i = 0; i < 4 * RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 1; i++)
|
||||
strong_pixel.read();
|
||||
|
||||
|
||||
if (ret != 0) {
|
||||
printf("Test failed !!!\n");
|
||||
ret = 1;
|
||||
} else {
|
||||
printf("Test passed !\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user