CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
vme_inreg_rtl_notri.vhd
Go to the documentation of this file.
1 
5 
6 
7 
8 
9 LIBRARY ieee ;
10 USE ieee.std_logic_1164.all;
11 USE ieee.numeric_std.all;
12 
13 
14 
15 
16 use work.CMXpackage.all;
17 use work.CMX_VME_defs.all;
18 
19 entity vme_inreg_notri is
20  generic(
21  ia_vme : integer := 0;
22  width : integer := 16
23  );
24  port(
25  clk : in std_logic;
26 
27  ncs : in std_logic;
28  rd_nwr : in std_logic;
29  ds : in std_logic;
30 
31  addr_vme : in std_logic_vector (15 downto 0);
32  data_vme_in : in std_logic_vector (15 downto 0);
33  data_vme_out : out std_logic_vector (15 downto 0);
34  bus_drive : out std_logic;
35 
36  data_from_vme : out std_logic_vector (width-1 downto 0);
37  data_to_vme :in std_logic_vector (width-1 downto 0);
38 
39  read_detect : out std_logic;
40  write_detect : out std_logic
41  );
42 
43 -- Declarations
44 
45 end vme_inreg_notri ;
46 --------------------------------------------------------------------------------
47 ARCHITECTURE rtl OF vme_inreg_notri IS
48 --------------------------------------------------------------------------------
49 -- VME register, all bits are inputs to board (q).
50 -- Variable width q, max 16.
51 --
52 
53  signal ren: std_logic; -- vme read enable
54  signal ren_r,ren_rr,ren_rrr,ren_rrrr,ren_rrrrr,ren_rrrrrr: std_logic; --above
55  --registered to
56  --sys clk
57 
58 
59  signal wen: std_logic; -- vme write enable
60  signal wen_r,wen_rr,wen_rrr,wen_rrrr,wen_rrrrr,wen_rrrrrr: std_logic; --above
61  --registered to
62  --sys clk
63 
64 
65  signal ds_r,ds_rr,ds_rrr,ds_rrrr,ds_rrrrr,ds_rrrrrr,ds_rrrrrrr,ds_rrrrrrrr : std_logic; -- previous
66  -- registered
67  -- value of strobe
68 
69  signal data_vme_r,data_vme_rr,data_vme_rrr,data_vme_rrrr: std_logic_vector(15 downto 0); -- registered value of data, it
70  -- doesn't have to be held after
71  -- ds
72 
73 
74  signal read_detect_sig, write_detect_sig : std_logic; --signals that pulse
75  --high on read or
76  --write op, forwarded
77  --to output
78 
79  signal read_detect_delay_line : std_logic_vector(VME_read_det_delay-1 downto 0);
80 
81  --component chipscope_icon_c1
82  -- port (
83  -- CONTROL0 : inout std_logic_vector(35 downto 0));
84  --end component;
85  --
86  --component chipscope_ila_inside_inreg
87  -- port (
88  -- CONTROL : inout std_logic_vector(35 downto 0);
89  -- CLK : in std_logic;
90  -- DATA : in std_logic_vector(39 downto 0);
91  -- TRIG0 : in std_logic_vector(3 downto 0));
92  --end component;
93  --
94  --signal CONTROL : std_logic_vector(35 downto 0);
95  --signal DATA_chipscope : std_logic_vector(39 downto 0);
96  --signal TRIG0_chipscope : std_logic_vector(3 downto 0);
97 
98 --------------------------------------------------------------------------------
99 BEGIN
100 
101 
102  ren <= vme_ren (ia_vme, addr_vme, ncs, rd_nwr);
103  wen <= vme_wen (ia_vme, addr_vme, ncs, rd_nwr);
104 
105  data_vme_out(width-1 downto 0)<=data_to_vme when ren='1' else (others=>'0');
106  gz: if width<16 generate
107  data_vme_out(15 downto width)<=(others=>'0');
108  end generate gz;
109  bus_drive<=ren;
110 
111 
112 
113  -- detect a read enable stable and ds edge after and generate a pulse on read_detect signal
114  -- detect a write enable stable and ds edge and generate a pulse on
115  -- write_detect and update output (data_from_vme)
116  -- signal and update the output
118  begin -- process read_detect_proc
119  if rising_edge(clk) then -- rising clock edge
120 
121  --detect rising edge, make sure signals are stable
122  if wen_rrrrrr='1' and wen_rrrrr='1' and wen_rrrr='1' and wen_rrr='1' and wen_rr='1' and wen_r='1'
123  and ds_rrrrrrrr='0' and ds_rrrrrrr='0' and ds_rrrrrr='0' and ds_rrrrr='1' and ds_rrrr='1' and ds_rrr='1' then
124  write_detect_sig <= '1';
125  data_from_vme(width-1 downto 0) <= data_vme_rrrr(width-1 downto 0);
126  else
127  write_detect_sig <= '0';
128  end if;
129 
130  --there is also a strobe after the read
131  if ren_rrrrrr='1' and ren_rrrrr='1' and ren_rrrr='1' and ren_rrr='1' and ren_rr='1' and ren_r='1'
132  and ds_rrrrrrrr='0' and ds_rrrrrrr='0' and ds_rrrrrr='0' and ds_rrrrr='1' and ds_rrrr='1' and ds_rrr='1' then
133  read_detect_sig <= '1';
134  else
135  read_detect_sig <= '0';
136  end if;
137 
138  --buffer the ren in a shift register
139 
142  ren_rrrr<=ren_rrr;
143  ren_rrr<=ren_rr;
144  ren_rr<=ren_r;
145  ren_r<=ren;
146 
147  --buffer the wen and ds in shift register
150  wen_rrrr<=wen_rrr;
151  wen_rrr<=wen_rr;
152  wen_rr<=wen_r;
153  wen_r<=wen;
154 
158  ds_rrrrr<=ds_rrrr;
159  ds_rrrr<=ds_rrr;
160  ds_rrr<=ds_rr;
161  ds_rr<=ds_r;
162  ds_r<=ds;
163 
168 
169  end if;
170  end process read_write_detect_proc;
171 
173  gen_read_detect_delay: for i_del in 1 to VME_read_det_delay-1 generate
174  process(clk)
175  begin
176  if rising_edge(clk) then
178  end if;
179  end process;
180  end generate gen_read_detect_delay;
181 
182  read_detect<=read_detect_delay_line(VME_read_det_delay-1);
184 
185 
186  --chipscope_icon_c1_inst: chipscope_icon_c1
187  -- port map (
188  -- CONTROL0 => CONTROL);
189  --
190  --chipscope_ila_inside_inreg_inst: chipscope_ila_inside_inreg
191  -- port map (
192  -- CONTROL => CONTROL,
193  -- CLK => clk,
194  -- DATA => DATA_chipscope,
195  -- TRIG0 => TRIG0_chipscope);
196  --
197  --
198  --TRIG0_chipscope(0)<=ds;
199  --TRIG0_chipscope(1)<=rd_nwr;
200  --TRIG0_chipscope(2)<=ren;
201  --TRIG0_chipscope(3)<=wen;
202  --
203  --
204  --DATA_chipscope(0)<=ds;
205  --DATA_chipscope(1)<=rd_nwr;
206  --DATA_chipscope(2)<=ren;
207  --DATA_chipscope(3)<=wen;
208  --DATA_chipscope(4)<=read_detect_sig;
209  --DATA_chipscope(5)<=write_detect_sig;
210  --DATA_chipscope(6) <=ds_r;
211  --DATA_chipscope(7) <=ds_rr;
212  --DATA_chipscope(8) <=ds_rrr;
213  --DATA_chipscope(9) <=ds_rrrr;
214  --DATA_chipscope(10)<=ds_rrrrr;
215  --DATA_chipscope(11)<=ds_rrrrrr;
216  --DATA_chipscope(12)<=ren_r;
217  --DATA_chipscope(13)<=ren_rr;
218  --DATA_chipscope(14)<=ren_rrr;
219  --DATA_chipscope(15)<=ren_rrrr;
220  --DATA_chipscope(16)<=ren_rrrrr;
221  --DATA_chipscope(17)<=ren_rrrrrr;
222  --DATA_chipscope(18)<=wen_r;
223  --DATA_chipscope(19)<=wen_rr;
224  --DATA_chipscope(20)<=wen_rrr;
225  --DATA_chipscope(21)<=wen_rrrr;
226  --DATA_chipscope(22)<=wen_rrrrr;
227  --DATA_chipscope(23)<=wen_rrrrrr;
228  --DATA_chipscope(39 downto 24)<=addr_vme;
229  --
230 --
231 -- vme_w_proc: process (iq, wen, ds)
232 -- -- write access
233 -- begin
234 -- if(ds'event and ds = '1') then
235 -- if (wen = '1') then
236 -- iq <= data_vme(width-1 downto 0);
237 -- end if;
238 -- end if;
239 -- end process;
240 
241 
242 
243 END rtl;
244 
245 
246 
out read_detectstd_logic
std_logic_vector (15 downto 0) data_vme_rrrr
out data_vme_outstd_logic_vector (15 downto 0)
out data_from_vmestd_logic_vector (width - 1 downto 0)
out write_detectstd_logic
std_logic_vector (15 downto 0) data_vme_rrr
_library_ ieeeieee
std_logic_vector (VME_read_det_delay - 1 downto 0) read_detect_delay_line
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_vme_r
out bus_drivestd_logic
test registers
in data_vme_instd_logic_vector (15 downto 0)
std_logic_vector (15 downto 0) data_vme_rr