Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify the VMStubMEMemoryCM and VMStubTEOuterMemoryCM in VMStubMemory class #350

Merged
merged 14 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions IntegrationTests/common/hdl/tf_mem_bin.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ process(clka)
alias vi_nent_idx : std_logic_vector(NUM_PHI_BITS+NUM_RZ_BITS-1 downto 0) is addra(ADDR_WIDTH + NUM_PHI_BITS + NUM_RZ_BITS - 1 downto ADDR_WIDTH);

--! Extract phi bin from bin address
alias phibits: std_logic_vector(NUM_PHI_BITS-1 downto 0) is vi_nent_idx(NUM_PHI_BITS + NUM_RZ_BITS - 1 downto NUM_RZ_BITS);
alias phibits: std_logic_vector(NUM_PHI_BITS-1 downto 0) is vi_nent_idx(NUM_PHI_BITS - 1 downto 0);

--! Extract rz bin from binaddress
alias rzbits: std_logic_vector(NUM_RZ_BITS-1 downto 0) is vi_nent_idx(NUM_RZ_BITS-1 downto 0); --rz position
alias rzbits: std_logic_vector(NUM_RZ_BITS-1 downto 0) is vi_nent_idx(NUM_PHI_BITS + NUM_RZ_BITS-1 downto NUM_PHI_BITS); --rz position

variable binaddr : unsigned(ADDR_WIDTH-1 downto 0) := (others => '0');
variable nentry : unsigned(ADDR_WIDTH-1 downto 0) := (others => '0');
Expand All @@ -244,13 +244,14 @@ begin
init := '0';
slv_clk_cnt := (others => '0');
slv_page_cnt := (0 => '1', others => '0');
--report "tf_mem_bin "&time'image(now)&" "&NAME&" setting nentry_mask_tmp to zero";
nentry_mask_tmp <= (others => '0'); -- Do we need this??? FIXME
--report "tf_mem_bin "&time'image(now)&" "&NAME&" sync_nent set";
end if;
if (init = '0' and to_integer(unsigned(slv_clk_cnt)) < MAX_ENTRIES-1) then -- ####### Counter nent
slv_clk_cnt := std_logic_vector(unsigned(slv_clk_cnt)+1);
elsif (to_integer(unsigned(slv_clk_cnt)) >= MAX_ENTRIES-1) then -- -1 not included
slv_clk_cnt := (others => '0');
nentry_mask_tmp <= (others => '0'); -- Why do we need this??? FIXME
nentry_mask_tmp <= (others => '0'); -- Do we need this??? FIXME
--report "tf_mem_bin "&time'image(now)&" "&NAME&" setting nentry_mask_tmp to zero";
if (to_integer(unsigned(slv_page_cnt)) < NUM_PAGES-1) then
slv_page_cnt := std_logic_vector(unsigned(slv_page_cnt)+1);
Expand All @@ -266,7 +267,7 @@ begin
-- Write data to all copies

--report "tf_mem_bin vi_nent_idx vi_nent_idx_new: " & to_bstring(vi_nent_idx) & " " & to_bstring(vi_nent_idx_new) & " " & to_bstring(rzbits) & " " & to_bstring(phibits);

binaddr := unsigned(nentry_tmp(to_integer(unsigned(vi_nent_idx))));
nentry := binaddr+1;

Expand All @@ -279,7 +280,7 @@ begin
nentry_mask_tmp(to_integer(unsigned(vi_nent_idx))) <= '1';

writeaddr := slv_page_cnt_save & vi_nent_idx & std_logic_vector(binaddr);
--report "tf_mem_bin addra: " & NAME & " " & to_bstring(std_logic_vector(addra));
--report "tf_mem_bin writeaddr data: " & NAME & " " & to_bstring(writeaddr) & " " & to_bstring(dina);
for icopy in 0 to NUM_COPY-1 loop
sa_RAM_data(icopy)(to_integer(unsigned(writeaddr))) <= dina;
end loop;
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/common/script/impl.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ reset_run impl_1

# Implementation
update_compile_order -fileset sources_1
launch_runs impl_1 -jobs 4
set ncpus [exec nproc]
launch_runs impl_1 -jobs $ncpus
wait_on_run impl_1

# Make reports
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/common/script/synth.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ set_property -name {STEPS.SYNTH_DESIGN.ARGS.MORE OPTIONS} -value {-mode out_of_c

# Synthesis
update_compile_order -fileset sources_1
launch_runs synth_1 -jobs 4
set ncpus [exec nproc]
launch_runs synth_1 -jobs $ncpus
wait_on_run synth_1

# Make reports
Expand Down
20 changes: 10 additions & 10 deletions TestBenches/MatchProcessor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace std;
int main()
{
// Define memory patterns
const string trackletProjectionPattern = "TrackletProjections*";
const string trackletProjectionPattern = "TrackletProjections_MPROJ*";
const string allStubPatternarray = "AllStub*";
const string vmStubPatternarray = "VMStubs_VMSME*";
const string fullMatchPattern = "FullMatches*";
Expand All @@ -48,7 +48,7 @@ int main()
const auto nAllStub = tb.nFiles(allStubPatternarray);
vector<AllStubMemory<stubMemType>> allstub(nAllStub);
const auto nVMStubs = tb.nFiles(vmStubPatternarray);
VMStubMEMemoryCM<vmStubMemType, vmStubMemRZ, kNbitsphibin, kNMatchEngines> vmstub; // barrel
VMStubMemory<vmStubMemType, vmStubMemRZ, kNbitsphibin, kNMatchEngines> vmstub; // barrel

// output memories
const auto nFullMatches = tb.nFiles(fullMatchPattern);
Expand All @@ -71,6 +71,11 @@ int main()
for (unsigned int ievt = 0; ievt < nevents; ++ievt) {
cout << "Event: " << dec << ievt << endl;

// bx
BXType bx = ievt;
BXType bx_out;


// read event and write to memories
auto &fin_TrackletProjections = tb.files(trackletProjectionPattern);
for (unsigned int i = 0; i < nTrackletProjections; i++)
Expand All @@ -79,16 +84,12 @@ int main()
for (unsigned int i = 0; i < nAllStub; i++)
writeMemFromFile<AllStubMemory<stubMemType>>(allstub[i], fin_AllStub.at(i), ievt);
auto &fin_VMStubs = tb.files(vmStubPatternarray);
writeMemFromFile<VMStubMEMemoryCM<vmStubMemType, vmStubMemRZ, kNbitsphibin, kNMatchEngines>>(vmstub, fin_VMStubs.at(0), ievt); // barrel
writeMemFromFile<VMStubMemory<vmStubMemType, vmStubMemRZ, kNbitsphibin, kNMatchEngines>>(vmstub, fin_VMStubs.at(0), ievt); // barrel

// clear allarray, output memories before starting
for (unsigned int i = 0; i < nFullMatches; i++)
fullmatcharray[i].clear();

// bx
BXType bx = ievt;
BXType bx_out;

// Unit Under Test
TOP_FUNC_(bx, tprojarray.data(), vmstub, allstub.data(), bx_out, fullmatcharray.data());

Expand All @@ -106,10 +107,9 @@ int main()

} // end of event loop

// This is necessary because HLS seems to only return an 8-bit error count, so if err%256==0, the test bench can falsely pass
// This is necessary because HLS seems to only return an 8-bit error count,
// so if err%256==0, the test bench can falsely pass
if (err > 255) err = 255;
// cout << "Module actually has " << err << " errors." << endl;
// return 0;
return err;

}
144 changes: 2 additions & 142 deletions TestBenches/TrackletProcessor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ std::cout<<module_name[MODULE_];
const auto nOuterStubMems = tb.nFiles(outerStubPattern);
vector<AllStubInnerMemory<InnerStubType> > innerStubs(nInnerStubMems);
vector<AllStubMemory<OuterStubType> > outerStubs(nOuterStubMems);
vector<VMStubTEOuterMemoryCM<OuterStubType, kNbitsrzbin, kNbitsphibin, NCOPY> > outervmStubs(nOuterVMStubMems);
vector<VMStubMemory<OuterStubType, kNbitsrzbin, kNbitsphibin, NCOPY, true> > outervmStubs(nOuterVMStubMems);

// output memories
TrackletParameterMemory tpar;
Expand All @@ -122,8 +122,6 @@ std::cout<<module_name[MODULE_];
auto &fin_outerStubs = tb.files(outerStubPattern);
auto &fin_outervmStubs = tb.files("VMStubs*");
auto &fout_tpar = tb.files("TrackletParameters*");
auto &fout_tproj = tb.files("TrackletProjections*");
const auto &tproj_names = tb.fileNames("TrackletProjections*");
// print the input files loaded
std::cout << "Loaded the input files:\n";
for (unsigned i = 0; i < nInnerStubMems; i++)
Expand All @@ -145,7 +143,7 @@ std::cout<<module_name[MODULE_];
for (unsigned i = 0; i < nOuterStubMems; i++)
writeMemFromFile<AllStubMemory<OuterStubType> >(outerStubs[i], fin_outerStubs.at(i), ievt);
for (unsigned i = 0; i < nOuterVMStubMems; i++)
writeMemFromFile<VMStubTEOuterMemoryCM<OuterStubType, kNbitsrzbin, kNbitsphibin, NCOPY>>(outervmStubs[i], fin_outervmStubs.at(i), ievt);
writeMemFromFile<VMStubMemory<OuterStubType, kNbitsrzbin, kNbitsphibin, NCOPY, true>>(outervmStubs[i], fin_outervmStubs.at(i), ievt);

// clear all output memories before starting
tpar.clear();
Expand All @@ -168,144 +166,6 @@ std::cout<<module_name[MODULE_];
// compare the computed outputs with the expected ones
err += compareMemWithFile<TrackletParameterMemory>(tpar, fout_tpar.at(0), ievt,
"\nTrackletParameter", truncation);
for (unsigned i = 0; i < tproj_names.size(); i++) {
const auto &tproj_name = tproj_names.at(i);
auto &fout = fout_tproj.at(i);
if (tproj_name.find("_D1PHIA") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D1PHIA], fout, ievt,
"\nTrackletProjection (D1PHIA)", truncation);
else if (tproj_name.find("_D1PHIB") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D1PHIB], fout, ievt,
"\nTrackletProjection (D1PHIB)", truncation);
else if (tproj_name.find("_D1PHIC") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D1PHIC], fout, ievt,
"\nTrackletProjection (D1PHIC)", truncation);
else if (tproj_name.find("_D1PHID") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D1PHID], fout, ievt,
"\nTrackletProjection (D1PHID)", truncation);
else if (tproj_name.find("_D2PHIA") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D2PHIA], fout, ievt,
"\nTrackletProjection (D2PHIA)", truncation);
else if (tproj_name.find("_D2PHIB") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D2PHIB], fout, ievt,
"\nTrackletProjection (D2PHIB)", truncation);
else if (tproj_name.find("_D2PHIC") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D2PHIC], fout, ievt,
"\nTrackletProjection (D2PHIC)", truncation);
else if (tproj_name.find("_D2PHID") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D2PHID], fout, ievt,
"\nTrackletProjection (D2PHID)", truncation);
else if (tproj_name.find("_D3PHIA") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D3PHIA], fout, ievt,
"\nTrackletProjection (D3PHIA)", truncation);
else if (tproj_name.find("_D3PHIB") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D3PHIB], fout, ievt,
"\nTrackletProjection (D3PHIB)", truncation);
else if (tproj_name.find("_D3PHIC") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D3PHIC], fout, ievt,
"\nTrackletProjection (D3PHIC)", truncation);
else if (tproj_name.find("_D3PHID") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D3PHID], fout, ievt,
"\nTrackletProjection (D3PHID)", truncation);
else if (tproj_name.find("_D4PHIA") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D4PHIA], fout, ievt,
"\nTrackletProjection (D4PHIA)", truncation);
else if (tproj_name.find("_D4PHIB") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D4PHIB], fout, ievt,
"\nTrackletProjection (D4PHIB)", truncation);
else if (tproj_name.find("_D4PHIC") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D4PHIC], fout, ievt,
"\nTrackletProjection (D4PHIC)", truncation);
else if (tproj_name.find("_D4PHID") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D4PHID], fout, ievt,
"\nTrackletProjection (D4PHID)", truncation);
else if (tproj_name.find("_L1PHIA") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIA], fout, ievt,
"\nTrackletProjection (L1PHIA)", truncation);
else if (tproj_name.find("_L1PHIB") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIB], fout, ievt,
"\nTrackletProjection (L1PHIB)", truncation);
else if (tproj_name.find("_L1PHIC") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIC], fout, ievt,
"\nTrackletProjection (L1PHIC)", truncation);
else if (tproj_name.find("_L1PHID") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHID], fout, ievt,
"\nTrackletProjection (L1PHID)", truncation);
else if (tproj_name.find("_L1PHIE") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIE], fout, ievt,
"\nTrackletProjection (L1PHIE)", truncation);
else if (tproj_name.find("_L1PHIF") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIF], fout, ievt,
"\nTrackletProjection (L1PHIF)", truncation);
else if (tproj_name.find("_L1PHIG") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIG], fout, ievt,
"\nTrackletProjection (L1PHIG)", truncation);
else if (tproj_name.find("_L1PHIH") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIH], fout, ievt,
"\nTrackletProjection (L1PHIH)", truncation);
else if (tproj_name.find("_L2PHIA") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L2PHIA], fout, ievt,
"\nTrackletProjection (L2PHIA)", truncation);
else if (tproj_name.find("_L2PHIB") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L2PHIB], fout, ievt,
"\nTrackletProjection (L2PHIB)", truncation);
else if (tproj_name.find("_L2PHIC") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L2PHIC], fout, ievt,
"\nTrackletProjection (L2PHIC)", truncation);
else if (tproj_name.find("_L2PHID") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L2PHID], fout, ievt,
"\nTrackletProjection (L2PHID)", truncation);
else if (tproj_name.find("_L3PHIA") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L3PHIA], fout, ievt,
"\nTrackletProjection (L3PHIA)", truncation);
else if (tproj_name.find("_L3PHIB") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L3PHIB], fout, ievt,
"\nTrackletProjection (L3PHIB)", truncation);
else if (tproj_name.find("_L3PHIC") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L3PHIC], fout, ievt,
"\nTrackletProjection (L3PHIC)", truncation);
else if (tproj_name.find("_L3PHID") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L3PHID], fout, ievt,
"\nTrackletProjection (L3PHID)", truncation);

else if (tproj_name.find("_L4PHIA") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L4PHIA], fout, ievt,
"\nTrackletProjection (L4PHIA)", truncation);
else if (tproj_name.find("_L4PHIB") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L4PHIB], fout, ievt,
"\nTrackletProjection (L4PHIB)", truncation);
else if (tproj_name.find("_L4PHIC") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L4PHIC], fout, ievt,
"\nTrackletProjection (L4PHIC)", truncation);
else if (tproj_name.find("_L4PHID") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L4PHID], fout, ievt,
"\nTrackletProjection (L4PHID)", truncation);
else if (tproj_name.find("_L5PHIA") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L5PHIA], fout, ievt,
"\nTrackletProjection (L5PHIA)", truncation);
else if (tproj_name.find("_L5PHIB") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L5PHIB], fout, ievt,
"\nTrackletProjection (L5PHIB)", truncation);
else if (tproj_name.find("_L5PHIC") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L5PHIC], fout, ievt,
"\nTrackletProjection (L5PHIC)", truncation);
else if (tproj_name.find("_L5PHID") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L5PHID], fout, ievt,
"\nTrackletProjection (L5PHID)", truncation);
else if (tproj_name.find("_L6PHIA") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L6PHIA], fout, ievt,
"\nTrackletProjection (L6PHIA)", truncation);
else if (tproj_name.find("_L6PHIB") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L6PHIB], fout, ievt,
"\nTrackletProjection (L6PHIB)", truncation);
else if (tproj_name.find("_L6PHIC") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L6PHIC], fout, ievt,
"\nTrackletProjection (L6PHIC)", truncation);
else if (tproj_name.find("_L6PHID") != string::npos)
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L6PHID], fout, ievt,
"\nTrackletProjection (L6PHID)", truncation);

}
aryd marked this conversation as resolved.
Show resolved Hide resolved
cout << endl;

} // end of event loop
Expand Down
Loading
Loading