1
+ -- This Source Code Form is subject to the terms of the Mozilla Public
2
+ -- License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ -- file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ --
5
+ -- Copyright 2024 Oxide Computer Company
6
+
7
+ -- AXI-accessible registers for the I2C block
8
+
9
+ library ieee;
10
+ use ieee.std_logic_1164.all ;
11
+ use ieee.numeric_std.all ;
12
+ use ieee.numeric_std_unsigned.all ;
13
+
14
+ use work.axil8x32_pkg.all ;
15
+
16
+ use work.i2c_core_regs_pkg.all ;
17
+
18
+ entity i2c_core_regs is
19
+ port (
20
+ clk : in std_logic ;
21
+ reset : in std_logic ;
22
+ axi_if : view axil_target;
23
+ ) ;
24
+ end entity ;
25
+
26
+ architecture rtl of i2c_core_regs is
27
+ constant AXI_OKAY : std_logic_vector (1 downto 0 ) := "00" ;
28
+ signal axi_read_ready_int : std_logic ;
29
+ signal axi_awready : std_logic ;
30
+ signal axi_wready : std_logic ;
31
+ signal axi_bvalid : std_logic ;
32
+ signal axi_bready : std_logic ;
33
+ signal axi_arready : std_logic ;
34
+ signal axi_rvalid : std_logic ;
35
+ signal axi_rdata : std_logic_vector (31 downto 0 );
36
+ begin
37
+
38
+ -- AXI wiring
39
+ axi_if.write_response.resp <= AXI_OKAY;
40
+ axi_if.write_response.valid <= axi_bvalid;
41
+ axi_if.read_data.resp <= AXI_OKAY;
42
+ axi_if.write_data.ready <= axi_wready;
43
+ axi_if.write_address.ready <= axi_awready;
44
+ axi_if.read_address.ready <= axi_arready;
45
+ axi_if.read_data.data <= axi_rdata;
46
+ axi_if.read_data.valid <= axi_rvalid;
47
+
48
+ axi_bready <= axi_if.write_response.ready;
49
+ axi_wready <= awready;
50
+ axi_arready <= not rvalid;
51
+ axi_read_ready_int <= axi_if.read_address.valid and axi_arready;
52
+
53
+ axi : process (clk, reset)
54
+ begin
55
+ if reset then
56
+ axi_awready <= '0' ;
57
+ axi_bvalid <= '0' ;
58
+ axi_rvalid <= '0' ;
59
+ elsif rising_edge (clk) then
60
+
61
+ -- bvalid is set on every write and then cleared after bv
62
+ if axi_awready then
63
+ axi_bvalid <= '1' ;
64
+ elsif axi_bready then
65
+ axi_bvalid <= '0' ;
66
+ end if ;
67
+
68
+ end if ;
69
+ end process ;
70
+
71
+ end architecture ;
0 commit comments