Skip to content

Commit

Permalink
also use new LUT reader for trackletcalculator LUTs
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonfan393 committed Nov 22, 2023
1 parent a0a83ab commit 462e9f1
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 4 deletions.
10 changes: 6 additions & 4 deletions TrackletAlgorithm/SWLUTReader.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#include <fstream>
#include <string>
// 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<class lutType, int lutsize> void readSWLUT(lutType lut[lutsize], std::string lutpath){
template<class lutType, int lutsize> 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;
Expand Down
40 changes: 40 additions & 0 deletions TrackletAlgorithm/TrackletCalculator_calculate_DXDY.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ap_int<19>,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<ap_int<19>,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<ap_int<19>,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<ap_int<19>,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];
}
}
Expand Down Expand Up @@ -946,37 +966,57 @@ ap_int<18> invt;

if (Seed == TF::D1D2){
if (negDisk){
#ifndef __SYNTHESIS__
static ap_int<18> LUT_invt[2048];
readSWLUT<ap_int<18>,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<ap_int<18>,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<ap_int<18>,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<ap_int<18>,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];
}
}
Expand Down
40 changes: 40 additions & 0 deletions TrackletAlgorithm/TrackletCalculator_calculate_LXD1.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ap_int<19>,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<ap_int<19>,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<ap_int<19>,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<ap_int<19>,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];
}
}
Expand Down Expand Up @@ -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<ap_int<18>,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<ap_int<18>,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<ap_int<18>,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<ap_int<18>,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];
}
}
Expand Down
40 changes: 40 additions & 0 deletions TrackletAlgorithm/TrackletCalculator_calculate_LXLY.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,42 +85,62 @@ ap_int<18> drinv;
switch (Seed) {
case TF::L1L2:
{
#if __SYNTHESIS__
static ap_int<18> LUT_drinv[512];
readSWLUT<ap_int<18>,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<ap_int<18>,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<ap_int<18>,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<ap_int<18>,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;
}
Expand Down Expand Up @@ -1122,42 +1142,62 @@ ap_int<18> invt;
switch (Seed) {
case TF::L1L2:
{
#if __SYNTHESIS__
static ap_int<18> LUT_invt[4096];
readSWLUT<ap_int<18>,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<ap_int<18>,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<ap_int<18>,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<ap_int<18>,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;
}
Expand Down

0 comments on commit 462e9f1

Please sign in to comment.