~ruther/vhdl-i2c

ref: 2dd83c491968d96294e91abf854adad299b4850a vhdl-i2c/src/utils/open_drain_buffer.vhd -rw-r--r-- 750 bytes
2dd83c49 — Rutherther docs: styling 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
library ieee;
use ieee.std_logic_1164.all;

entity open_drain_buffer is

  port (
    pad_io   : inout std_logic;         -- The pad itself, will be set to 'Z'
                                        -- when enable_i = '0'
    enable_i : in    std_logic;         -- Whether to enable output, ie. set
                                        -- pad to '0' for enable_i = '1'
    state_o  : out   std_logic);        -- The state of the pad, relevant if
                                        -- enable_i = '0'

end entity open_drain_buffer;

architecture a1 of open_drain_buffer is

begin  -- architecture a1

  pad_io <= '0' when enable_i = '1' else
            'Z';

  state_o <= '1' when pad_io = 'H' else
             pad_io;

end architecture a1;
Do not follow this link