~ruther/vhdl-i2c

ref: 987035cd215d71ee109cae9038fe55d6cf83ea76 vhdl-i2c/src/utils/delay.vhd -rw-r--r-- 1.1 KiB
987035cd — Rutherther fix: full_on skips indices 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
library ieee;
use ieee.std_logic_1164.all;

entity delay is
  generic (
    DELAY : integer range 0 to 31);

  port (
    clk_i   : in std_logic;
    rst_in  : in std_logic;
    signal_i : in std_logic;
    signal_o : out std_logic);

end entity delay;

architecture a1 of delay is
  constant DELAYED_PULSE_POS : natural := DELAY - 1;
  signal curr_pulses : std_logic_vector(DELAYED_PULSE_POS downto 0);
  signal next_pulses : std_logic_vector(DELAYED_PULSE_POS downto 0);
begin  -- architecture a1

  zero_delay: if DELAY = 0 generate
    signal_o <= signal_i;
  else generate
    signal_o <= curr_pulses(DELAYED_PULSE_POS);
  end generate zero_delay;

  next_pulses <= curr_pulses(DELAYED_PULSE_POS - 1 downto 0) & signal_i;

  set_regs: process (clk_i) is
  begin  -- process set_regs
    if rising_edge(clk_i) then          -- rising clock edge
      if rst_in = '0' then              -- synchronous reset (active low)
        curr_pulses <= (others => '0');
      else
        curr_pulses <= next_pulses;
      end if;
    end if;
  end process set_regs;

end architecture a1;
Do not follow this link