diff --git a/dtc-fe/firmware/hdl/HeaderFingerprintChecker_PS10G.vhd b/dtc-fe/firmware/hdl/HeaderFingerprintChecker_PS10G.vhd index 9369bed94be8e1aa05c296db71cda74927b25e29..bf6df510329a7db8f2f5bcd01a1fe172ae75a6d8 100644 --- a/dtc-fe/firmware/hdl/HeaderFingerprintChecker_PS10G.vhd +++ b/dtc-fe/firmware/hdl/HeaderFingerprintChecker_PS10G.vhd @@ -45,7 +45,7 @@ begin -- Conditions for header fingerprint_match := rolling_window(cBoxCarFrames + cPaddingTapPoint)(4 downto 0) = b"00000" and rolling_window(cPaddingTapPoint)(4 downto 0) = b"00000"; - conf_match := rolling_window(cBoxCarFrames + cConfTapPoint)(5) = '1' and rolling_window(cConfTapPoint)(5) = '1'; + conf_match := rolling_window(cBoxCarFrames + cConfTapPoint)(11) = '1' and rolling_window(cConfTapPoint)(11) = '1'; if unsigned(bcid) > 7 then bcid_match := unsigned(bcid) - unsigned(previous_bcid) = 8; 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 3513d28102867d66d827ea3796e360788da5411e..377e70d66d7f63310db6d836bce3c048aa00f64e 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 @@ -63,6 +63,7 @@ architecture interface of emp_rx_user_data_framer is constant module_type : string := selectModuleTypeFromChannel(INDEX*4 + CHANNEL_INDEX); constant bandwidth : integer := selectDataRateFromChannel(INDEX*4 + CHANNEL_INDEX); constant cModuleELinks : integer := cNumberOfELinks(selectIndexFromModuleType(module_type, bandwidth)); + constant cModuleL1ELinks : integer := cNumberOfL1ELinks(selectIndexFromModuleType(module_type, bandwidth)); type tUnboundedLinkArray is array(integer range <>) of std_logic_vector(7 downto 0); subtype tLinkArray is tUnboundedLinkArray(cModuleELinks - 1 downto 0); @@ -74,8 +75,12 @@ architecture interface of emp_rx_user_data_framer is signal data_s : lword := LWORD_NULL; - type tL1AData is array(0 to 1) of std_logic_vector(7 downto 0); - signal l1a_data : tL1AData := (others => (others => '0')); + type tUnboundedL1ALinkArray is array(integer range <>) of std_logic_vector(7 downto 0); + subtype tL1ALinkArray is tUnboundedL1ALinkArray(cModuleL1ELinks - 1 downto 0); + type tUnboundedMultiCICL1ALinkArray is array(integer range <>) of tL1ALinkArray; + subtype tMultiCICL1ALinkArray is tUnboundedMultiCICL1ALinkArray(0 to cNumberOfCICs - 1); + + signal l1a_data : tMultiCICL1ALinkArray := (others => (others => (others => '0'))); signal stub_links : tMultiCICLinkArray := NullMultiCICLinkArray; @@ -96,10 +101,29 @@ begin if (time_index = 0) then for i in 0 to cNumberOfCICs - 1 loop - for j in 0 to cModuleELinks - 1 loop - stub_links(i)(j)(7 downto 0) <= user_data_i(link_indices(selectIndexFromModuleType(module_type, bandwidth))(i)(j) + 7 downto link_indices(selectIndexFromModuleType(module_type, bandwidth))(i)(j)); + for j in 0 to cModuleELinks - 1 loop + for k in 7 downto 0 loop + if cWordWidth(selectIndexFromModuleType(module_type, bandwidth)) = 8 then + stub_links(i)(j)(k) <= user_data_i(link_indices(selectIndexFromModuleType(module_type, bandwidth))(i)(j) + k); + else + if j < 6 then + stub_links(i)(j)(k) <= user_data_i(link_indices(selectIndexFromModuleType(module_type, bandwidth))(i)(j) + 2*k + 1); + else + stub_links(i)(j)(k) <= user_data_i(link_indices(selectIndexFromModuleType(module_type, bandwidth))(i)(j) + 2*k); + end if; + end if; end loop; - l1a_data(i) <= user_data_i(l1a_indices(selectIndexFromModuleType(module_type, bandwidth))(i) + 7 downto l1a_indices(selectIndexFromModuleType(module_type, bandwidth))(i)); + end loop; + for j in 0 to cModuleL1ELinks - 1 loop + --l1a_data(i)(j)(7 downto 0) <= user_data_i(l1a_indices(selectIndexFromModuleType(module_type, bandwidth))(i)(j) + 7 downto l1a_indices(selectIndexFromModuleType(module_type, bandwidth))(i)(j)); + for k in 7 downto 0 loop + if cWordWidth(selectIndexFromModuleType(module_type, bandwidth)) = 8 then + l1a_data(i)(j)(k) <= user_data_i(l1a_indices(selectIndexFromModuleType(module_type, bandwidth))(i)(j) + k); + else + l1a_data(i)(j)(k) <= user_data_i(l1a_indices(selectIndexFromModuleType(module_type, bandwidth))(i)(j) + 2*k + 1 - j); + end if; + end loop; + end loop; end loop; end if; @@ -116,8 +140,10 @@ 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)(to_integer(time_index)); + end loop; + for j in 0 to cModuleL1ELinks - 1 loop --- Stream L1A link --- - data_s.data(32*i + cModuleELinks) <= l1a_data(i)(to_integer(time_index)); + data_s.data(32*i + cModuleELinks + cModuleL1ELinks - 1 - j) <= l1a_data(i)(j)(to_integer(time_index)); end loop; end loop; end if; diff --git a/dtc-fe/firmware/hdl/module_constants.vhd b/dtc-fe/firmware/hdl/module_constants.vhd index b5419ca4ad5af5d26a7012d970300297048d06fc..55d76c17acc9a96e4fc7d27246c8cecd0a222523 100644 --- a/dtc-fe/firmware/hdl/module_constants.vhd +++ b/dtc-fe/firmware/hdl/module_constants.vhd @@ -14,18 +14,21 @@ package module_constants is type tUnbounded2DIntegerArray is array(integer range <>) of tLinkIndicesArray; subtype tMultiCICLinkIndicesArray is tUnbounded2DIntegerArray(0 to 2 - 1); type tModuleConstantLinkIndicesArray is array (0 to 2) of tMultiCICLinkIndicesArray; - type tModuleConstantL1AIndicesArray is array (0 to 2) of tL1AIndicesArray; + type tUnboundedL1A2DIntegerArray is array(integer range <>) of tL1AIndicesArray; + subtype tMultiCICL1AIndicesArray is tUnboundedL1A2DIntegerArray(0 to 2 - 1); + type tModuleConstantL1AIndicesArray is array (0 to 2) of tMultiCICL1AIndicesArray; constant cGBTFrameWidth : integer := 112; constant cNumberOfELinks : tModuleConstantIntegerArray := (5, 6, 12); constant cNumberOfL1ELinks : tModuleConstantIntegerArray := (1, 1, 2); + constant cWordWidth : tModuleConstantIntegerArray := (8, 8, 16); constant cStubWidth : tModuleConstantIntegerArray := (18, 21, 21); constant cHeaderWidth : integer := 28; constant cMaxStubs : tModuleConstantIntegerArray := (16, 16, 35); constant cBoxCarFrames : integer := 64; - constant cHeaderFrames : tModuleConstantIntegerArray := (6, 5, 5); + constant cHeaderFrames : tModuleConstantIntegerArray := (6, 5, 3); constant cFirstStubOffset : tModuleConstantIntegerArray := (3, 4, 4); constant cDataPeriod : tModuleConstantIntegerArray := (8, 8, 8); @@ -60,17 +63,17 @@ package module_constants is constant cL1UnsparsifiedLength : integer := 2200; constant cHeaderSRDelay : tModuleConstantVectorArray := ("1000000", "0100000", "0001000"); -- CHECK THIS - constant cHeaderSignalDelay : tModuleConstantIntegerArray := (55, 56, 56); -- CHECK THIS + constant cHeaderSignalDelay : tModuleConstantIntegerArray := (55, 56, 58); -- CHECK THIS constant link_indices : tModuleConstantLinkIndicesArray := ( (( 64, 72, 80, 88, 96, -1, -1, -1, -1, -1, -1, -1), ( 8, 16, 24, 32, 40, -1, -1, -1, -1, -1, -1, -1)), (( 0, 104, 96, 88, 80, 64, -1, -1, -1, -1, -1, -1), (56, 48, 40, 32, 24, 8, -1, -1, -1, -1, -1, -1)), - ((104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192), ( 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96)) + (( 0, 208, 192, 176, 160, 128, 0, 208, 192, 176, 160, 128), (112, 96, 80, 64, 48, 16, 112, 96, 80, 64, 48, 16)) ); constant l1a_indices : tModuleConstantL1AIndicesArray := ( - ( 0, 56), - (72, 16), - ( 0, 56) + ((0, -1), (56, -1)), + ((72, -1), (16, -1)), + ((144, 144),(32, 32)) ); function selectIndexFromModuleType(module_type : in string; bandwidth : in integer) return integer;