AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
stretcher.vhd
1 -- stretcher
2 --
3 -- Stretches a single clock pulse so it's visible on an LED
4 --
5 -- Dave Newbold, January 2013
6 --
7 -- $Id$
8 
9 library ieee;
10 use ieee.std_logic_1164.all;
11 
12 entity stretcher is
13  port(
14  clk: in std_logic; -- Assumed to be 125MHz ipbus clock
15  d: in std_logic; -- Input (edge detected)
16  q: out std_logic -- LED output, ~0.25s pulse
17  );
18 
19 end stretcher;
20 
21 architecture rtl of stretcher is
22 
23  signal d_sync, d_sync_d, d_edge, d25, d25_d, q_i: std_logic;
24 
25 begin
26 
27  clkdiv: entity work.clock_div
28  port map(
29  clk => clk,
30  d25 => d25,
31  d28 => open
32  );
33 
34  process(clk)
35  begin
36  if rising_edge(clk) then
37  d_sync <= d; -- Possible clock domain crossing from slower clock (sync not important)
38  d_sync_d <= d_sync;
39  d_edge <= (d_sync and not d_sync_d) or (d_edge and not q_i);
40  d25_d <= d25;
41  if d25='1' and d25_d='0' then
42  q_i <= d_edge;
43  end if;
44  end if;
45  end process;
46 
47  q <= q_i;
48 
49 end rtl;