3.6.6.2 General Porting

Vitis HLS / Vivado HLSSmartHLS
set_top <FUNC> (in synthesis Tcl file)On the first line of <FUNC>, add #pragma HLS function top
#include <ap_int.h>

#include <hls/ap_int.hpp>

Depending on the type(s) used, add using hls::ap_uint;, and/or using hls::ap_int;

#include <ap_fixed.h>

#include <hls/ap_fixpt.hpp>

Depending on the type(s) used, add using hls::ap_fixpt; #define ap_fixed ap_fixpt , and/or using hls::ap_ufixpt; #define ap_ufixed ap_ufixpt

#include <hls_stream.h>

#include <hls/streaming.hpp>

#define stream FIFO

hls::stream constructor

Vitis/Vivado HLS’s stream constructor optionally takes a string name as argument, while SmartHLS’s FIFO constructor optionally takes depth and type.VHLS’s stream assumes infinite size in C simulation, so set equivalent SmartHLS FIFOs’ depths very deep for C simulation.Example of mapping an external FIFO:

VHLS: hls::stream<int> data;

SmartHLS: hls::stream<int> data(1e4);

Example of mapping an internal FIFO:

VHLS:

hls::stream<int> data;
#pragma HLS stream variable = data depth = 2
SmartHLS:
#ifndef __SYNTHESIS__
#define INTERNAL_STREAM_DEPTH  1e4
#else
#define INTERNAL_STREAM_DEPTH  2
#endif
hls::stream<int> data(INTERNAL_STREAM_DEPTH);
VHLS’s stream constructor may take FIFO name as argument, which should be removed.
<AP_INT_VAR>.to_int()

<AP_INT_VAR>.to_uint64(), or <AP_INT_VAR>.to_int64()

VHLS’s ap_int has a list of C-type conversion functions (e.g. to_short(), to_int(), to_long()), while SmartHLS only has to_uint64()/to_int64() and expects users to add explicit casting to the return value.

<AP_INT_VAR>.range(7,0).to_int()

(ap_uint<...><AP_INT_VAR>.range(7,0)).to_int64()

In SmartHLS, the return value of <AP_INT_VAR>.range() cannot be used to directly invoke to_int64()/to_uint64().

stringstream >> ap_fixpt<W, IW, Q_M, O_M>
std::stringstream istr(line)
ap_fixpt<W, IW, Q_M, O_M> = args;
double args_temp;
istr >> args_temp;
args = args_temp;
#include <assert.h>
#ifdef __SYNTHESIS__
#define NDEBUG
#endif
#include <assert.h>