diff --git a/dtc-fe/firmware/hdl/L1DataDecoder_PS10G.vhd b/dtc-fe/firmware/hdl/L1DataDecoder_PS10G.vhd index 7bed20d9a25a5059a761c9cc8dccfed2e0a4c61a..b4fb27e685081467ccf9a14057f67ce20d7f27c2 100644 --- a/dtc-fe/firmware/hdl/L1DataDecoder_PS10G.vhd +++ b/dtc-fe/firmware/hdl/L1DataDecoder_PS10G.vhd @@ -137,62 +137,58 @@ begin -- nPclusters defines length of payload Pixels' data length npclusters := header(cL1NPcluster_low + cL1NPcluster_width - 1 downto cL1NPcluster_low); - -- nSclusters defines length of payload strips' data length - nSclusters := header(cL1NScluster_low + cL1NScluster_width-1 downto cL1NScluster_low); - - --debug - snSclusters <= nSclusters; - snPclusters <= nPclusters; - sl1a <= l1a; - sstatus <= status; - - -- store the header to the data FIFO, and set word count to 1 - data_fifo <= l1a & status & nSclusters & nPclusters; - data_fifo_wr <= '1'; - word_count := to_unsigned(1, cL1CtrlFifoWidth); - - bit_counter <= cL1DataFifoWidth - 2; - payload_word(1 downto 0) <= data_in; - payload_sclust_cntr <= to_integer(unsigned(nSclusters)) * cL1SClusterWidth; - payload_pclust_cntr <= to_integer(unsigned(nPclusters)) * cL1PClusterWidth; - payload_sum <= payload_sclust_cntr + payload_pclust_cntr; - payload_counter <= payload_sum - 2; - --payload_counter <= to_integer(unsigned(nSclusters))*cL1SClusterWidth + to_integer(unsigned(nPclusters))*cL1PClusterWidth - 2; - - - else --header counter = -1 (the two new bits and the header(0) bit belong to payload word) - - decoder <= payload_capture; - - status := header(cL1StatusLow(selectIndexFromModuleType(module_type, bandwidth))+1 + cL1StatusWidth-1 downto cL1StatusLow(selectIndexFromModuleType(module_type, bandwidth))+1); - l1a := header(cL1IdLow(selectIndexFromModuleType(module_type, bandwidth))+1 + cL1IdWidth-1 downto cL1IdLow(selectIndexFromModuleType(module_type, bandwidth))+1); + -- nSclusters defines length of payload strips' data length + nsclusters := header(cL1NScluster_low + cL1NScluster_width - 1 downto cL1NScluster_low); + + -- debug + snsclusters <= nsclusters; + snpclusters <= npclusters; + sl1a <= l1a; + sstatus <= status; + + -- store the header to the data FIFO, and set word count to 1 + data_fifo <= l1a & status & nsclusters & npclusters; + data_fifo_wr <= '1'; + word_count := to_unsigned(1, cL1CtrlFifoWidth); + + bit_counter <= cL1DataFifoWidth - 2; + payload_word(1 downto 0) <= data_in; + payload_sclust_cntr <= to_integer(unsigned(nsclusters)) * cL1SClusterWidth; + payload_pclust_cntr <= to_integer(unsigned(npclusters)) * cL1PClusterWidth; + payload_sum <= payload_sclust_cntr + payload_pclust_cntr; + payload_counter <= payload_sum - 2; + -- payload_counter <= to_integer(unsigned(nSclusters))*cL1SClusterWidth + to_integer(unsigned(nPclusters))*cL1PClusterWidth - 2; + else -- header counter = -1 (the two new bits and the header(0) bit belong to payload word) + decoder <= payload_capture; + + status := header(cL1StatusLow(selectIndexFromModuleType(module_type, bandwidth)) + 1 + cL1StatusWidth - 1 downto cL1StatusLow(selectIndexFromModuleType(module_type, bandwidth)) + 1); + l1a := header(cL1IdLow(selectIndexFromModuleType(module_type, bandwidth)) + 1 + cL1IdWidth - 1 downto cL1IdLow(selectIndexFromModuleType(module_type, bandwidth)) + 1); -- nPclusters defines length of payload Pixels' data length npclusters := header(cL1NPcluster_low + 1 + cL1NPcluster_width - 1 downto cL1NPcluster_low + 1); - -- nSclusters defines length of payload strips' data length - nSclusters := header(cL1NScluster_low+1 + cL1NScluster_width-1 downto cL1NScluster_low+1); - - --debug - snSclusters <= nSclusters; - snPclusters <= nPclusters; - sl1a <= l1a; - sstatus <= status; - - -- store the header to the data FIFO, and set word count to 1 - data_fifo <= l1a & status & nSclusters & nPclusters; - data_fifo_wr <= '1'; - word_count := to_unsigned(1, cL1CtrlFifoWidth); - - bit_counter <= cL1DataFifoWidth - 3; - payload_word(2 downto 0) <= header(0) & data_in; - payload_sclust_cntr <= to_integer(unsigned(nSclusters)) * cL1SClusterWidth; - payload_pclust_cntr <= to_integer(unsigned(nPclusters)) * cL1PClusterWidth; - payload_sum <= payload_sclust_cntr + payload_pclust_cntr; - payload_counter <= payload_sum - 3; - --payload_counter <= to_integer(unsigned(nSclusters))*cL1SClusterWidth + to_integer(unsigned(nPclusters))*cL1PClusterWidth - 3; - - end if; + -- nSclusters defines length of payload strips' data length + nsclusters := header(cL1NScluster_low + 1 + cL1NScluster_width - 1 downto cL1NScluster_low + 1); + + -- debug + snsclusters <= nsclusters; + snpclusters <= npclusters; + sl1a <= l1a; + sstatus <= status; + + -- store the header to the data FIFO, and set word count to 1 + data_fifo <= l1a & status & nsclusters & npclusters; + data_fifo_wr <= '1'; + word_count := to_unsigned(1, cL1CtrlFifoWidth); + + bit_counter <= cL1DataFifoWidth - 3; + payload_word(2 downto 0) <= header(0) & data_in; + payload_sclust_cntr <= to_integer(unsigned(nsclusters)) * cL1SClusterWidth; + payload_pclust_cntr <= to_integer(unsigned(npclusters)) * cL1PClusterWidth; + payload_sum <= payload_sclust_cntr + payload_pclust_cntr; + payload_counter <= payload_sum - 3; + -- payload_counter <= to_integer(unsigned(nSclusters))*cL1SClusterWidth + to_integer(unsigned(nPclusters))*cL1PClusterWidth - 3; + end if; -- pack the payload into words until the predetermined packet length ends when payload_capture => diff --git a/dtc-fe/firmware/hdl/lpgbt-framer/emp_rx_user_data_framer.vhd b/dtc-fe/firmware/hdl/lpgbt-framer/emp_rx_user_data_framer.vhd index 5aa6c6eb88ca6662838287c27f43a967402248cd..ae84c97aeef4593bde8091d08543c29569476ef9 100644 --- a/dtc-fe/firmware/hdl/lpgbt-framer/emp_rx_user_data_framer.vhd +++ b/dtc-fe/firmware/hdl/lpgbt-framer/emp_rx_user_data_framer.vhd @@ -76,9 +76,12 @@ architecture interface of emp_rx_user_data_framer is end loop; return bandwidth; - end selectDataRateFromChannel; - function decrementIndex(index : in integer) return integer is + end function selectDataRateFromChannel; + + function decrementIndex ( + index : in integer + ) return integer is begin if (index = 0) then @@ -189,13 +192,16 @@ begin data_s.data(32 * i + 31) <= '1'; for j in 0 to cModuleELinks - 1 loop - data_s.data(32*i + cModuleELinks - 1 - j) <= stub_links(i)(j)(time_index); + + data_s.data(32 * i + cModuleELinks - 1 - j) <= stub_links(i)(j)(time_index); + end loop; for j in 0 to cModuleL1ELinks - 1 loop --- Stream L1A link --- - data_s.data(32*i + cModuleELinks + cModuleL1ELinks - 1 - j) <= l1a_data(i)(j)(time_index); + data_s.data(32 * i + cModuleELinks + cModuleL1ELinks - 1 - j) <= l1a_data(i)(j)(time_index); + end loop; end loop;