diff --git a/TrackletAlgorithm/SWLUTReader.h b/TrackletAlgorithm/SWLUTReader.h index 96d920b2530..d3ff4d421dd 100644 --- a/TrackletAlgorithm/SWLUTReader.h +++ b/TrackletAlgorithm/SWLUTReader.h @@ -1,15 +1,17 @@ #include #include // The following function provides a more compiler efficient method for reading look up table arrays (currently used in TP), this is only used in C simulations and not synthesis -template void readSWLUT(lutType lut[lutsize], std::string lutpath){ +template void readSWLUT(lutType lut[lutsize], std::string lutpath, bool skipfirst = true, bool hex = false){ std::ifstream LUTif(lutpath); + if (hex) { + LUTif >> std::hex; + } lutType lutval; - bool first = true; unsigned int lutIndex=0; while (LUTif >> lutval){ - if (first && lutval == 0){ - first = false; + if (skipfirst && lutval == 0){ + skipfirst = false; continue; } lut[lutIndex]=lutval; diff --git a/TrackletAlgorithm/TrackletCalculator_calculate_DXDY.h b/TrackletAlgorithm/TrackletCalculator_calculate_DXDY.h index 0d153870870..e291c79826a 100644 --- a/TrackletAlgorithm/TrackletCalculator_calculate_DXDY.h +++ b/TrackletAlgorithm/TrackletCalculator_calculate_DXDY.h @@ -77,37 +77,57 @@ ap_int<19> drinv; const ap_uint<10> addr_drinv = dr & 1023; // address for the LUT if (Seed == TF::D1D2){ if (negDisk){ +#ifndef __SYNTHESIS__ + static ap_int<19> LUT_drinv[1024]; + readSWLUT,1024>(LUT_drinv,"../../../../../emData/LUTs/TC_B1B2_drinv.tab",false,true); +#else static const ap_int<19> LUT_drinv[1024] = { #if __has_include("../emData/LUTs/TC_B1B2_drinv.tab") # include "../emData/LUTs/TC_B1B2_drinv.tab" #endif }; +#endif drinv = LUT_drinv[addr_drinv]; } else{ +#ifndef __SYNTHESIS__ + static ap_int<19> LUT_drinv[1024]; + readSWLUT,1024>(LUT_drinv,"../../../../../emData/LUTs/TC_F1F2_drinv.tab",false,true); +#else static const ap_int<19> LUT_drinv[1024] = { #if __has_include("../emData/LUTs/TC_F1F2_drinv.tab") # include "../emData/LUTs/TC_F1F2_drinv.tab" #endif }; +#endif drinv = LUT_drinv[addr_drinv]; } } else{ if (negDisk){ +#ifndef __SYNTHESIS__ + static ap_int<19> LUT_drinv[1024]; + readSWLUT,1024>(LUT_drinv,"../../../../../emData/LUTs/TC_B3B4_drinv.tab",false,true); +#else static const ap_int<19> LUT_drinv[1024] = { #if __has_include("../emData/LUTs/TC_B3B4_drinv.tab") # include "../emData/LUTs/TC_B3B4_drinv.tab" #endif }; +#endif drinv = LUT_drinv[addr_drinv]; } else{ +#ifndef __SYNTHESIS__ + static ap_int<19> LUT_drinv[1024]; + readSWLUT,1024>(LUT_drinv,"../../../../../emData/LUTs/TC_F3F4_drinv.tab",false,true); +#else static const ap_int<19> LUT_drinv[1024] = { #if __has_include("../emData/LUTs/TC_F3F4_drinv.tab") # include "../emData/LUTs/TC_F3F4_drinv.tab" #endif }; +#endif drinv = LUT_drinv[addr_drinv]; } } @@ -946,37 +966,57 @@ ap_int<18> invt; if (Seed == TF::D1D2){ if (negDisk){ +#ifndef __SYNTHESIS__ + static ap_int<18> LUT_invt[2048]; + readSWLUT,2048>(LUT_invt,"../../../../../emData/LUTs/TC_B1B2_invt.tab",false,true); +#else static const ap_int<18> LUT_invt[2048] = { #if __has_include("../emData/LUTs/TC_B1B2_invt.tab") # include "../emData/LUTs/TC_B1B2_invt.tab" #endif }; +#endif invt = LUT_invt[addr_invt]; } else{ +#ifndef __SYNTHESIS__ + static ap_int<18> LUT_invt[2048]; + readSWLUT,2048>(LUT_invt,"../../../../../emData/LUTs/TC_F1F2_invt.tab",false,true); +#else static const ap_int<18> LUT_invt[2048] = { #if __has_include("../emData/LUTs/TC_F1F2_invt.tab") # include "../emData/LUTs/TC_F1F2_invt.tab" #endif }; +#endif invt = LUT_invt[addr_invt]; } } else{ if (negDisk){ +#ifndef __SYNTHESIS__ + static ap_int<18> LUT_invt[2048]; + readSWLUT,2048>(LUT_invt,"../../../../../emData/LUTs/TC_B3B4_invt.tab",false,true); +#else static const ap_int<18> LUT_invt[2048] = { #if __has_include("../emData/LUTs/TC_B3B4_invt.tab") # include "../emData/LUTs/TC_B3B4_invt.tab" #endif }; +#endif invt = LUT_invt[addr_invt]; } else{ +#ifndef __SYNTHESIS__ + static ap_int<18> LUT_invt[2048]; + readSWLUT,2048>(LUT_invt,"../../../../../emData/LUTs/TC_F3F4_invt.tab",false,true); +#else static const ap_int<18> LUT_invt[2048] = { #if __has_include("../emData/LUTs/TC_F3F4_invt.tab") # include "../emData/LUTs/TC_F3F4_invt.tab" #endif }; +#endif invt = LUT_invt[addr_invt]; } } diff --git a/TrackletAlgorithm/TrackletCalculator_calculate_LXD1.h b/TrackletAlgorithm/TrackletCalculator_calculate_LXD1.h index 3897140abd4..e4ce0abddab 100644 --- a/TrackletAlgorithm/TrackletCalculator_calculate_LXD1.h +++ b/TrackletAlgorithm/TrackletCalculator_calculate_LXD1.h @@ -89,37 +89,57 @@ const ap_uint<11> addr_drinv = dr & 2047; // address for the LUT if (Seed == TF::L1D1){ if (negDisk){ +#if __SYNTHESIS__ + static ap_int<19> LUT_drinv[2048]; + readSWLUT,2048>(LUT_drinv, "../../../../../emData/LUTs/TC_L1B1_drinv.tab",false,true); +#else static const ap_int<19> LUT_drinv[2048] = { #if __has_include("../emData/LUTs/TC_L1B1_drinv.tab") # include "../emData/LUTs/TC_L1B1_drinv.tab" #endif }; +#endif drinv = LUT_drinv[addr_drinv]; } else{ +#if __SYNTHESIS__ + static ap_int<19> LUT_drinv[2048]; + readSWLUT,2048>(LUT_drinv, "../../../../../emData/LUTs/TC_L1F1_drinv.tab",false,true); +#else static const ap_int<19> LUT_drinv[2048] = { #if __has_include("../emData/LUTs/TC_L1F1_drinv.tab") # include "../emData/LUTs/TC_L1F1_drinv.tab" #endif }; +#endif drinv = LUT_drinv[addr_drinv]; } } else{ if (negDisk){ +#if __SYNTHESIS__ + static ap_int<19> LUT_drinv[2048]; + readSWLUT,2048>(LUT_drinv, "../../../../../emData/LUTs/TC_L2B1_drinv.tab",false,true); +#else static const ap_int<19> LUT_drinv[2048] = { #if __has_include("../emData/LUTs/TC_L2B1_drinv.tab") # include "../emData/LUTs/TC_L2B1_drinv.tab" #endif }; +#endif drinv = LUT_drinv[addr_drinv]; } else{ +#if __SYNTHESIS__ + static ap_int<19> LUT_drinv[2048]; + readSWLUT,2048>(LUT_drinv, "../../../../../emData/LUTs/TC_L2F1_drinv.tab",false,true); +#else static const ap_int<19> LUT_drinv[2048] = { #if __has_include("../emData/LUTs/TC_L2F1_drinv.tab") # include "../emData/LUTs/TC_L2F1_drinv.tab" #endif }; +#endif drinv = LUT_drinv[addr_drinv]; } } @@ -982,37 +1002,57 @@ const ap_uint<11> addr_invt = (t_final>>1) & 2047; // address for the LUT ap_int<18> invt; if (Seed==TF::L1D1){ if (negDisk){ +#if __SYNTHESIS__ + static ap_int<18> LUT_invt[2048]; + readSWLUT,2048>(LUT_invt, "../../../../../emData/LUTs/TC_L1B1_invt.tab",false,true); +#else static const ap_int<18> LUT_invt[2048] = { #if __has_include("../emData/LUTs/TC_L1B1_invt.tab") # include "../emData/LUTs/TC_L1B1_invt.tab" #endif }; +#endif invt = LUT_invt[addr_invt]; } else{ +#if __SYNTHESIS__ + static ap_int<18> LUT_invt[2048]; + readSWLUT,2048>(LUT_invt, "../../../../../emData/LUTs/TC_L1F1_invt.tab",false,true); +#else static const ap_int<18> LUT_invt[2048] = { #if __has_include("../emData/LUTs/TC_L1F1_invt.tab") # include "../emData/LUTs/TC_L1F1_invt.tab" #endif }; +#endif invt = LUT_invt[addr_invt]; } } else{ if (negDisk){ +#if __SYNTHESIS__ + static ap_int<18> LUT_invt[2048]; + readSWLUT,2048>(LUT_invt, "../../../../../emData/LUTs/TC_L2B1_invt.tab",false,true); +#else static const ap_int<18> LUT_invt[2048] = { #if __has_include("../emData/LUTs/TC_L2B1_invt.tab") # include "../emData/LUTs/TC_L2B1_invt.tab" #endif }; +#endif invt = LUT_invt[addr_invt]; } else{ +#if __SYNTHESIS__ + static ap_int<18> LUT_invt[2048]; + readSWLUT,2048>(LUT_invt, "../../../../../emData/LUTs/TC_L2F1_invt.tab",false,true); +#else static const ap_int<18> LUT_invt[2048] = { #if __has_include("../emData/LUTs/TC_L2F1_invt.tab") # include "../emData/LUTs/TC_L2F1_invt.tab" #endif }; +#endif invt = LUT_invt[addr_invt]; } } diff --git a/TrackletAlgorithm/TrackletCalculator_calculate_LXLY.h b/TrackletAlgorithm/TrackletCalculator_calculate_LXLY.h index 716996a1f85..87c9c1bbef9 100644 --- a/TrackletAlgorithm/TrackletCalculator_calculate_LXLY.h +++ b/TrackletAlgorithm/TrackletCalculator_calculate_LXLY.h @@ -85,42 +85,62 @@ ap_int<18> drinv; switch (Seed) { case TF::L1L2: { +#if __SYNTHESIS__ + static ap_int<18> LUT_drinv[512]; + readSWLUT,512>(LUT_drinv, "../../../../../emData/LUTs/TC_L1L2_drinv.tab",false,true); +#else static const ap_int<18> LUT_drinv[512] = { #if __has_include("../emData/LUTs/TC_L1L2_drinv.tab") # include "../emData/LUTs/TC_L1L2_drinv.tab" #endif }; +#endif drinv = LUT_drinv[addr_drinv]; break; } case TF::L2L3: { +#if __SYNTHESIS__ + static ap_int<18> LUT_drinv[512]; + readSWLUT,512>(LUT_drinv, "../../../../../emData/LUTs/TC_L2L3_drinv.tab",false,true); +#else static const ap_int<18> LUT_drinv[512] = { #if __has_include("../emData/LUTs/TC_L2L3_drinv.tab") # include "../emData/LUTs/TC_L2L3_drinv.tab" #endif }; +#endif drinv = LUT_drinv[addr_drinv]; break; } case TF::L3L4: { +#if __SYNTHESIS__ + static ap_int<18> LUT_drinv[512]; + readSWLUT,512>(LUT_drinv, "../../../../../emData/LUTs/TC_L3L4_drinv.tab",false,true); +#else static const ap_int<18> LUT_drinv[512] = { #if __has_include("../emData/LUTs/TC_L3L4_drinv.tab") # include "../emData/LUTs/TC_L3L4_drinv.tab" #endif }; +#endif drinv = LUT_drinv[addr_drinv]; break; } case TF::L5L6: { +#if __SYNTHESIS__ + static ap_int<18> LUT_drinv[512]; + readSWLUT,512>(LUT_drinv, "../../../../../emData/LUTs/TC_L5L6_drinv.tab",false,true); +#else static const ap_int<18> LUT_drinv[512] = { #if __has_include("../emData/LUTs/TC_L5L6_drinv.tab") # include "../emData/LUTs/TC_L5L6_drinv.tab" #endif }; +#endif drinv = LUT_drinv[addr_drinv]; break; } @@ -1122,42 +1142,62 @@ ap_int<18> invt; switch (Seed) { case TF::L1L2: { +#if __SYNTHESIS__ + static ap_int<18> LUT_invt[4096]; + readSWLUT,4096>(LUT_invt, "../../../../../emData/LUTs/TC_L1L2_invt.tab",false,true); +#else static const ap_int<18> LUT_invt[4096] = { #if __has_include("../emData/LUTs/TC_L1L2_invt.tab") # include "../emData/LUTs/TC_L1L2_invt.tab" #endif }; +#endif invt = LUT_invt[addr_invt]; break; } case TF::L2L3: { +#if __SYNTHESIS__ + static ap_int<18> LUT_invt[4096]; + readSWLUT,4096>(LUT_invt, "../../../../../emData/LUTs/TC_L2L3_invt.tab",false,true); +#else static const ap_int<18> LUT_invt[4096] = { #if __has_include("../emData/LUTs/TC_L2L3_invt.tab") # include "../emData/LUTs/TC_L2L3_invt.tab" #endif }; +#endif invt = LUT_invt[addr_invt]; break; } case TF::L3L4: { +#if __SYNTHESIS__ + static ap_int<18> LUT_invt[4096]; + readSWLUT,4096>(LUT_invt, "../../../../../emData/LUTs/TC_L3L4_invt.tab",false,true); +#else static const ap_int<18> LUT_invt[4096] = { #if __has_include("../emData/LUTs/TC_L3L4_invt.tab") # include "../emData/LUTs/TC_L3L4_invt.tab" #endif }; +#endif invt = LUT_invt[addr_invt]; break; } case TF::L5L6: { +#if __SYNTHESIS__ + static ap_int<18> LUT_invt[4096]; + readSWLUT,4096>(LUT_invt, "../../../../../emData/LUTs/TC_L5L6_invt.tab",false,true); +#else static const ap_int<18> LUT_invt[4096] = { #if __has_include("../emData/LUTs/TC_L5L6_invt.tab") # include "../emData/LUTs/TC_L5L6_invt.tab" #endif }; +#endif invt = LUT_invt[addr_invt]; break; }