cms-L1TK / project_generation_scripts

Python scripts to generate the wiring map of the tracklet pattern recognition & the top-level HDL that calls the HLS modules in the Hybrid Chain.
1 stars 2 forks source link

Functions for getting a string version of the enums #26

Closed meisonlikesicecream closed 3 years ago

meisonlikesicecream commented 3 years ago

Making the script write functions in memUtil_pkg.vhd that converts the memory enums to strings. These functions are needed as the current PRMEMC VHDL testbench assumes that all file names for each memory type are of the same length, which is not generally true for other chains. We avoid that issue with these functions (converting the enums directly isn't case sensitive, so that didn't work), and it also makes the VHDL testbenches shorter as one doesn't have to specify every single filename by hand.

Example of the PRMEMC memUtil_pkg.vhd: https://github.com/meisonlikesicecream/firmware-hls/blob/update_VHDL_tb/IntegrationTests/PRMEMC/hdl/memUtil_pkg.vhd

Example of what the PRMEMC testbench could look like: https://github.com/meisonlikesicecream/firmware-hls/blob/update_VHDL_tb/IntegrationTests/PRMEMC/tb/tb_tf_top.vhd

I'll make a PR with the above examples to the firmware repo as well if this PR gets approved.

tomalin commented 3 years ago

Check if you can achieve the enum to string conversion more compactly by using a VHDL "attribute". See http://computer-programming-forum.com/42-vhdl/ec98ccdceac6fa62.htm . I can't recall if the syntax is "string x := enum_TPROJ_60'image(L1L2G_L3PHIC) or simply := L1L2G_L3PHIC'image. Or is this the solution that failed because it isn't "case sensitive"?

meisonlikesicecream commented 3 years ago

Check if you can achieve the enum to string conversion more compactly by using a VHDL "attribute". See http://computer-programming-forum.com/42-vhdl/ec98ccdceac6fa62.htm . I can't recall if the syntax is "string x := enum_TPROJ_60'image(L1L2G_L3PHIC) or simply := L1L2G_L3PHIC'image.

It's string x := enum_TPROJ_60'image(L1L2G_L3PHIC). And no, this didn't work because it doesn't preserve the upper case letters. It just converted every letter to lower case, which doesn't work if we want to use the strings for finding the file names. (I also tried creating a function that converted lower case letters to upper case, but then I realised that some enums are a mix of both...)

tomalin commented 3 years ago

At https://github.com/meisonlikesicecream/firmware-hls/blob/update_VHDL_tb/IntegrationTests/PRMEMC/tb/tb_tf_top.vhd#L83 , why do all file names end in "_04.dat"? What does "04" mean?

meisonlikesicecream commented 3 years ago

At https://github.com/meisonlikesicecream/firmware-hls/blob/update_VHDL_tb/IntegrationTests/PRMEMC/tb/tb_tf_top.vhd#L83 , why do all file names end in "_04.dat"? What does "04" mean?

it's the sector/nonant number that was chosen in the emulation for the testvectors: https://github.com/cms-L1TK/cmssw/blob/L1TK-dev-11_3_0_pre3/L1Trigger/TrackFindingTracklet/interface/Settings.h#L810. Why nonant number 4 was chosen you have to ask someone else...

tomalin commented 3 years ago

At https://github.com/meisonlikesicecream/firmware-hls/blob/update_VHDL_tb/IntegrationTests/PRMEMC/tb/tb_tf_top.vhd#L83 , why do all file names end in "_04.dat"? What does "04" mean?

it's the sector/nonant number that was chosen in the emulation for the testvectors: https://github.com/cms-L1TK/cmssw/blob/L1TK-dev-11_3_0_pre3/L1Trigger/TrackFindingTracklet/interface/Settings.h#L810. Why nonant number 4 was chosen you have to ask someone else...

OK. I suggest when you commit your VHDL TB, to add a comment to that line explaining that.