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