CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
BUF_2X24_AT_80_TO_1X96_AT_40.vhd
Go to the documentation of this file.
1 ----------------------------------------------------------------------------------
8 ----------------------------------------------------------------------------------
9 library IEEE;
10 use IEEE.STD_LOGIC_1164.ALL;
11 
12 library work;
13 use work.CMXpackage.all;
14 
15 
16 -- Uncomment the following library declaration if using
17 -- arithmetic functions with Signed or Unsigned values
18 use IEEE.NUMERIC_STD.ALL;
19 
20 -- Uncomment the following library declaration if instantiating
21 -- any Xilinx primitives in this code.
22 --library UNISIM;
23 --use UNISIM.VComponents.all;
24 
26  port (
27  PDATA, NDATA : in std_logic_vector(numbitsinchan - 1 downto 0);
28  ODATA : out std_logic_vector((numbitsinchan*4)-1 downto 0);
29  ODATA_first_half : out std_logic_vector((numbitsinchan*2)-1 downto 0);
30  clk80 : in std_logic;
31  cyclecounter : in unsigned(0 downto 0);
32  counter_enable : in std_logic;
33  PAR_ERROR : out std_logic);
34 end BUF_2X24_AT_80_TO_1X96_AT_40;
35 
36 architecture Behavioral of BUF_2X24_AT_80_TO_1X96_AT_40 is
37 
38  attribute keep : string;
39 
40  signal PDATA_24, NDATA_24: std_logic_vector(23 downto 0);
41 
42 
43 
44  signal P_temp_reg : std_logic_vector(numbitsinchan -1 downto 0); -- holds
45  -- first
46  -- part of
47  -- PDATA
48  -- for
49  -- half
50  -- cycle
51  -- of
52  -- 40MHz
53  -- Clock
54 
55  signal N_temp_reg : std_logic_vector(numbitsinchan -1 downto 0); --same for
56  --NDATA
57 
58  --signal P_temp_reg1,N_temp_reg1 : std_logic_vector(numbitsinchan -1 downto 0);
59 
60  signal parP, parN : std_logic; -- holds the parity for
61  -- the P and N line
62 
63  signal parP_odd_err, parN_odd_err : std_logic; --'1' if we did not get odd
64  --parity data
65 
66  signal parP_odd_err_reg, parN_odd_err_reg : std_logic; --hold parity error for the first
67  --1 set of 24 bits (rising 40MHz
68  --clock edge)
69 
70  -- -- signal PDATA_msb0, NDATA_msb0 : std_logic_vector(numbitsinchan-1 downto 0);
71  -- -- --PDATA_reg_msb0, NDATA_reg_msb0 : std_logic_vector(numbitsinchan-1 downto 0);
72  -- -- -- corresponding signals
73  -- -- -- with the msb set to 0
74  -- -- -- for parity calculation
75 
76  --attribute keep of P_temp_reg1, N_temp_reg1,
77  attribute keep of parP_odd_err, parN_odd_err, parP_odd_err_reg, parN_odd_err_reg : signal is "TRUE";
78 
79  component PARITY_CALC
80  port (
81  DATA : in std_logic_vector(numbitsinchan - 1 downto 0);
82  PARITY : out std_logic);
83  end component;
84 
85 begin
86 
87  --PDATA_24(23 downto (23-(numbitsinchan-1))) <= PDATA;
88  --NDATA_24(23 downto (23-(numbitsinchan-1))) <= NDATA;
89  --genZEROS: if numbitsinchan<24 generate
90  -- PDATA_24(23-(numbitsinchan-1)-1 downto 0) <= (others=>'0');
91  -- NDATA_24(23-(numbitsinchan-1)-1 downto 0) <= (others=>'0');
92  --end generate genZEROS;
93 
94  --- ---PDATA_msb0(numbitsinchan-2 downto 0)<=PDATA(numbitsinchan-2 downto 0);
95  --- ---PDATA_msb0(numbitsinchan-1)<='0';
96  --- ---NDATA_msb0(numbitsinchan-2 downto 0)<=NDATA(numbitsinchan-2 downto 0);
97  --- ---NDATA_msb0(numbitsinchan-1)<='0';
98 
99  --PDATA_reg_msb0(numbitsinchan-2 downto 0)<=PDATA_reg(numbitsinchan-2 downto 0);
100  --PDATA_reg_msb0(numbitsinchan-1)<='0';
101  --NDATA_reg_msb0(numbitsinchan-2 downto 0)<=NDATA_reg(numbitsinchan-2 downto 0);
102  --NDATA_reg_msb0(numbitsinchan-1)<='0';
103 
104 
105 
106 
107 
108  pcalcP: PARITY_CALC port map (PDATA, parP);
109  pcalcN: PARITY_CALC port map (NDATA, parN);
110 
111  parP_odd_err<=parP xor '1'; --these will be '1' if the parity result is '0'
112  parN_odd_err<=parN xor '1'; --i.e. the received data had even parity (we
113  --expect odd)
114 
115  process(clk80)
116  begin
117  if rising_edge(clk80) then
118  if counter_enable='0' then
119  ODATA<=(others=>'0');
120  ODATA_first_half<=(others=>'0');
121  P_temp_reg<=(others=>'0');
122  N_temp_reg<=(others=>'0');
123  parP_odd_err_reg<='0';
124  parN_odd_err_reg<='0';
125  PAR_ERROR<='0';
126  else
127 
128  if cyclecounter=to_unsigned(0,1) then
129  P_temp_reg <= PDATA;
130  N_temp_reg <= NDATA;
133  ODATA_first_half(numbitsinchan-1 downto 0)<=PDATA;
134  ODATA_first_half(2*numbitsinchan-1 downto numbitsinchan)<=NDATA;
135  else
136  --P_temp_reg1<=PDATA;
137  --N_temp_reg1<=NDATA;
138 
139  -- reversed order --ODATA( (4*numbitsinchan-1) downto (3*numbitsinchan)) <= P_temp_reg;
140  -- reversed order --ODATA( (3*numbitsinchan)-1 downto (2*numbitsinchan)) <= N_temp_reg;
141  -- reversed order --ODATA( (2*numbitsinchan)-1 downto (1*numbitsinchan)) <=PDATA;
142  -- reversed order --ODATA( (1*numbitsinchan)-1 downto (0*numbitsinchan)) <=NDATA;
143 
144  ODATA( (4*numbitsinchan-1) downto (3*numbitsinchan)) <= NDATA;
145  ODATA( (3*numbitsinchan)-1 downto (2*numbitsinchan)) <= PDATA;
146  ODATA( (2*numbitsinchan)-1 downto (1*numbitsinchan)) <=N_temp_reg;
147  ODATA( (1*numbitsinchan)-1 downto (0*numbitsinchan)) <=P_temp_reg;
148 
150  end if;
151 
152  end if;
153  end if;
154  end process;
155 
156 
157 
158 end Behavioral;
159 
out PARITYstd_logic
Definition: PARITY_CALC.vhd:31
out ODATA_first_halfstd_logic_vector ((numbitsinchan * 2) - 1 downto 0)
PARITY_CALC pcalcnpcalcn
std_logic_vector (numbitsinchan - 1 downto 0) N_temp_reg
std_logic_vector (numbitsinchan - 1 downto 0) P_temp_reg
in DATAstd_logic_vector (numbitsinchan - 1 downto 0)
Definition: PARITY_CALC.vhd:30
in PDATAstd_logic_vector (numbitsinchan - 1 downto 0)
out ODATAstd_logic_vector ((numbitsinchan * 4) - 1 downto 0)
_library_ IEEEIEEE
_library_ workwork
in NDATAstd_logic_vector (numbitsinchan - 1 downto 0)
PARITY_CALC pcalcppcalcp