CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
CMX_rate_counter_inhibit.vhd
Go to the documentation of this file.
1 ----------------------------------------------------------------------------------
10 ----------------------------------------------------------------------------------
11 library IEEE;
12 use IEEE.STD_LOGIC_1164.ALL;
13 
14 
15 library work;
16 use work.CMXpackage.all;
17 use work.CMX_VME_defs.all;
18 
19 
20 -- Uncomment the following library declaration if using
21 -- arithmetic functions with Signed or Unsigned values
22 use IEEE.NUMERIC_STD.ALL;
23 
24 -- Uncomment the following library declaration if instantiating
25 -- any Xilinx primitives in this code.
26 --library UNISIM;
27 --use UNISIM.VComponents.all;
28 
30  port (
31  counter_inhibit : out std_logic;
32  counter_reset : out std_logic;
33  buf_clk40 : in std_logic;
34  --VME control:
35  ncs : in std_logic;
36  rd_nwr : in std_logic;
37  ds : in std_logic;
38  addr_vme : in std_logic_vector (15 downto 0);
39  data_vme_in : in std_logic_vector (15 downto 0);
40  data_vme_out : out std_logic_vector (15 downto 0);
41  bus_drive : out std_logic
42  );
43 end CMX_rate_counter_inhibit;
44 
45 architecture Behavioral of CMX_rate_counter_inhibit is
46 
47  component vme_local_switch is
48  port (
49  data_vme_up : out std_logic_vector (15 downto 0);
50  data_vme_from_below : in arr_16;
51  bus_drive_up : out std_logic;
52  bus_drive_from_below : in std_logic_vector);
53  end component vme_local_switch;
54 
55  component vme_inreg_notri is
56  generic (
57  ia_vme : integer;
58  width : integer);
59  port (
60  clk : in std_logic;
61  ncs : in std_logic;
62  rd_nwr : in std_logic;
63  ds : in std_logic;
64  addr_vme : in std_logic_vector (15 downto 0);
65  data_vme_in : in std_logic_vector (15 downto 0);
66  data_vme_out : out std_logic_vector (15 downto 0);
67  bus_drive : out std_logic;
68  data_from_vme : out std_logic_vector (width-1 downto 0);
69  data_to_vme : in std_logic_vector (width-1 downto 0);
70  read_detect : out std_logic;
71  write_detect : out std_logic);
72  end component vme_inreg_notri;
73 
74  component vme_inreg_notri_async is
75  generic (
76  ia_vme : integer;
77  width : integer);
78  port (
79  ncs : in std_logic;
80  rd_nwr : in std_logic;
81  ds : in std_logic;
82  addr_vme : in std_logic_vector (15 downto 0);
83  data_vme_in : in std_logic_vector (15 downto 0);
84  data_vme_out : out std_logic_vector (15 downto 0);
85  bus_drive : out std_logic;
86  data_from_vme : out std_logic_vector (width-1 downto 0);
87  data_to_vme : in std_logic_vector (width-1 downto 0));
88  end component vme_inreg_notri_async;
89 
91  generic (
92  ia_vme : integer;
93  width : integer);
94  port (
95  ncs : in std_logic;
96  rd_nwr : in std_logic;
97  ds : in std_logic;
98  addr_vme : in std_logic_vector (15 downto 0);
99  data_vme : out std_logic_vector (15 downto 0);
100  bus_drive : out std_logic;
101  data_to_vme : in std_logic_vector (width-1 downto 0));
102  end component vme_outreg_notri_async;
103 
104 
105  signal data_from_vme_REG_RW_RATE_COUNTER_INHIBIT: std_logic_vector(15 downto 0);
106  signal data_to_vme_REG_RW_RATE_COUNTER_INHIBIT: std_logic_vector(15 downto 0);
108 
109  signal data_from_vme_REG_RW_RATE_COUNTER_RESET: std_logic_vector(15 downto 0);
110  signal data_to_vme_REG_RW_RATE_COUNTER_RESET: std_logic_vector(15 downto 0);
111 
112 
113  signal data_vme_out_local : arr_16(3 downto 0);
114  signal bus_drive_local : std_logic_vector(3 downto 0);
115 
116 
117  signal normalisation_counter : unsigned(32 downto 0);
118 
119  signal counter_inhibit_r_local : std_logic;
120  signal counter_reset_r_local : std_logic;
121  signal counter_inhibit_sig : std_logic;
122  signal counter_reset_sig : std_logic;
123 
124  signal all_one_thirtythree : std_logic_vector(32 downto 0);
125 
126 
127 begin
128 
129  all_one_thirtythree<=(others=>'1');
130 
131  vme_local_switch_inst: entity work.vme_local_switch
132  port map (
137 
138 
139  vme_inreg_notri_REG_RW_RATE_COUNTER_INHIBIT: entity work.vme_inreg_notri
140  generic map (
141  ia_vme => ADDR_REG_RW_RATE_COUNTER_INHIBIT ,
142  width => 16)
143  port map (
144  clk => buf_clk40 ,
145  ncs => ncs,
146  rd_nwr => rd_nwr,
147  ds => ds,
148  addr_vme => addr_vme,
151  bus_drive => bus_drive_local (0),
154  read_detect => open,
157 
158  vme_inreg_notri_async_REG_RW_RATE_COUNTER_RESET: entity work.vme_inreg_notri_async
159  generic map (
160  ia_vme => ADDR_REG_RW_RATE_COUNTER_RESET ,
161  width => 16)
162  port map (
163  ncs => ncs,
164  rd_nwr => rd_nwr,
165  ds => ds,
166  addr_vme => addr_vme,
169  bus_drive => bus_drive_local (1),
173 
174  vme_outreg_notri_async_REG_RO_RATE_NORMALISATION_COUNTER_0: entity work.vme_outreg_notri_async
175  generic map (
176  ia_vme => ADDR_REG_RO_RATE_NORMALISATION_COUNTER,
177  width => 16)
178  port map (
179  ncs => ncs,
180  rd_nwr => rd_nwr,
181  ds => ds,
182  addr_vme => addr_vme,
184  bus_drive => bus_drive_local (2),
185  data_to_vme => std_logic_vector(normalisation_counter(15 downto 0)));
186 
187 
188  vme_outreg_notri_async_REG_RO_RATE_NORMALISATION_COUNTER_1: entity work.vme_outreg_notri_async
189  generic map (
190  ia_vme => ADDR_REG_RO_RATE_NORMALISATION_COUNTER+2,
191  width => 16)
192  port map (
193  ncs => ncs,
194  rd_nwr => rd_nwr,
195  ds => ds,
196  addr_vme => addr_vme,
198  bus_drive => bus_drive_local (3),
199  data_to_vme => std_logic_vector(normalisation_counter(31 downto 16)));
200 
201 
202  process(buf_clk40)
203  begin
204  if rising_edge(buf_clk40) then
207  counter_inhibit_sig<='1';
208  else
209  counter_inhibit_sig<='0';
210  end if;
211  end if;
212 
213 
215  counter_reset_sig<='1';
216  else
217  counter_reset_sig<='0';
218  end if;
219 
220  end if;
221 
222  end process;
223 
224  process(buf_clk40)
225  begin
226  if rising_edge(buf_clk40) then
229  end if;
230  end process;
231 
234 
235  process(buf_clk40)
236  begin
237  if rising_edge(buf_clk40) then
238  if counter_reset_r_local='1' then
239  normalisation_counter<=to_unsigned(0,33);
240  else
241  if normalisation_counter(32)='1' then
243  else
244  if counter_inhibit_r_local /='1' then
246  else
248  end if;
249  end if;
250  end if;
251  end if;
252  end process;
253 
254 
255 
256 end Behavioral;
257 
out read_detectstd_logic
in addr_vmestd_logic_vector (15 downto 0)
out data_vmestd_logic_vector (15 downto 0)
std_logic_vector (32 downto 0) all_one_thirtythree
out data_vme_outstd_logic_vector (15 downto 0)
out data_from_vmestd_logic_vector (width - 1 downto 0)
in data_vme_from_belowarr_16
--! inputs from local registers and from
out data_from_vmestd_logic_vector (width - 1 downto 0)
in data_vme_instd_logic_vector (15 downto 0)
out write_detectstd_logic
std_logic_vector (3 downto 0) bus_drive_local
in data_to_vmestd_logic_vector (width - 1 downto 0)
std_logic_vector (15 downto 0) data_to_vme_REG_RW_RATE_COUNTER_RESET
out data_vme_upstd_logic_vector (15 downto 0)
--! connect this to
in addr_vmestd_logic_vector (15 downto 0)
in addr_vmestd_logic_vector (15 downto 0)
std_logic_vector (15 downto 0) data_from_vme_REG_RW_RATE_COUNTER_INHIBIT
out bus_drive_upstd_logic
or of all bus drive requests from below
in data_vme_instd_logic_vector (15 downto 0)
out data_vme_outstd_logic_vector (15 downto 0)
std_logic_vector (15 downto 0) data_from_vme_REG_RW_RATE_COUNTER_RESET
in addr_vmestd_logic_vector (15 downto 0)
in data_to_vmestd_logic_vector (width - 1 downto 0)
std_logic_vector (15 downto 0) data_to_vme_REG_RW_RATE_COUNTER_INHIBIT
out data_vme_outstd_logic_vector (15 downto 0)
out bus_drivestd_logic
test registers
in data_vme_instd_logic_vector (15 downto 0)
in data_to_vmestd_logic_vector (width - 1 downto 0)
in bus_drive_from_belowstd_logic_vector