ROD firmware  1.0.5
ATLAS l1-calo - ROD_eFEX and ROD_jFEX firmware for the L1Calo ROD board

Back to ROD documentation
pulse_stretch.vhd
1 ----------------------------------------------------------------------------------
2 -- Company:
3 -- Engineer:
4 --
5 -- Create Date: 09.05.2019 13:13:43
6 -- Design Name:
7 -- Module Name: pulse_stretch - RTL
8 -- Project Name:
9 -- Target Devices:
10 -- Tool Versions:
11 -- Description:
12 --
13 -- Dependencies:
14 --
15 -- Revision:
16 -- Revision 0.01 - File Created
17 -- Additional Comments:
18 --
19 ----------------------------------------------------------------------------------
20 
21 
22 library IEEE;
23 use IEEE.STD_LOGIC_1164.ALL;
24 use IEEE.STD_LOGIC_UNSIGNED.ALL;
25 
26 -- Uncomment the following library declaration if using
27 -- arithmetic functions with Signed or Unsigned values
28 --use IEEE.NUMERIC_STD.ALL;
29 
30 -- Uncomment the following library declaration if instantiating
31 -- any Xilinx leaf cells in this code.
32 --library UNISIM;
33 --use UNISIM.VComponents.all;
34 
35 entity pulse_stretch is
36  generic (
37  COUNTER_WIDTH : integer := 5
38  );
39  Port (
40  clock : in STD_LOGIC;
41  reset : in STD_LOGIC;
42  pulse_in : in STD_LOGIC;
43  pulse_out : out STD_LOGIC
44 
45  );
46 end pulse_stretch;
47 
48 
49 architecture RTL of pulse_stretch is
50 
51 signal counter : std_logic_vector(counter_width-1 downto 0) := (others => '1');
52 signal count_max : STD_LOGIC_VECTOR (counter_width-1 downto 0); --:= (others => '1');
53 signal pulse_out_i : std_logic := '0';
54 
55 
56 begin
57 
58 count_max <= (others => '1');
59 
60 process (clock) begin
61  if rising_edge (clock) then
62  if reset = '1' then
63  counter <= (others=> '1');
64  pulse_out_i <= '0';
65  elsif pulse_in = '1' then
66  counter <= (others=> '0');
67  pulse_out_i <= '1';
68  elsif counter = count_max then
69  pulse_out_i <= '0';
70  counter <= counter;
71  else
72  counter <= counter + 1;
73  end if;
74  end if;
75 end process;
76 
77 pulse_out <= pulse_out_i or pulse_in;
78 
79 
80 end RTL;