Skip to content

Commit d5d04ae

Browse files
committed
wip
1 parent cf60864 commit d5d04ae

11 files changed

+132
-1049
lines changed

hdl/ip/vhd/i2c/BUCK

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
load("//tools:hdl.bzl", "vhdl_unit", "vunit_sim")
2+
load("//tools:rdl.bzl", "rdl_file")
3+
4+
rdl_file(
5+
name = "i2c_core_regs_pkg",
6+
src = "i2c_core_regs.rdl",
7+
outputs = ["i2c_core_regs_pkg.vhd", "i2c_core_regs.html"],
8+
visibility = ['PUBLIC']
9+
)
210

311
vhdl_unit(
412
name = "i2c_txn_layer",

hdl/ip/vhd/i2c/i2c_core_regs.rdl

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2024 Oxide Computer Company
2+
// This is a SystemRDL description of the SW-accessible registers for the I2C core.
3+
4+
addrmap i2c_core_regs {
5+
name = "I2C core registers";
6+
desc = "Registers accessible on the AXI bus for interacting with the I2C core.";
7+
8+
default regwidth = 32;
9+
default sw = rw;
10+
default hw = r;
11+
12+
reg {
13+
name = "Receive data";
14+
default sw = r;
15+
default hw = rw;
16+
17+
field {
18+
desc = "Last 4 bytes recieved";
19+
} DATA[31:0] = 0;
20+
} RXD;
21+
22+
reg {
23+
name = "Transmit data";
24+
default sw = r;
25+
default hw = rw;
26+
27+
field {
28+
desc = "Next 4 bytes to send";
29+
} DATA[31:0] = 0;
30+
} TXD;
31+
32+
reg {
33+
name = "Control bits for I2C communication.";
34+
35+
field {
36+
desc = "Number of bytes to read/write in the I2C transaction. up to 128 bytes.";
37+
} COUNT[22:16] = 1;
38+
39+
field {
40+
desc = "I2C Address of target";
41+
} ADDR[14:8] = 0;
42+
43+
field {
44+
desc = "2'b00 to read, 2'b01 to write, 2'b10 to random-read.";
45+
} OP[2:1] = 0;
46+
47+
field {
48+
desc = "'1' to start next transaction.";
49+
} START[0:0] = 0;
50+
} CONTROL;
51+
};

hdl/ip/vhd/i2c/i2c_core_regs.vhd

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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;

hdl/ip/vhd/i2c/i2c_core.vhd hdl/ip/vhd/i2c/i2c_core_top.vhd

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use work.tristate_if_pkg;
1111

1212
use work.i2c_common_pkg;
1313

14-
entity i2c_core is
14+
entity i2c_core_top is
1515
generic (
1616
CLK_PER_NS : positive;
1717
MODE : mode_t;
@@ -28,7 +28,7 @@ entity i2c_core is
2828
);
2929
end entity;
3030

31-
architecture rtl of i2c_core is
31+
architecture rtl of i2c_core_top is
3232

3333
begin
3434

hdl/ip/vhd/i2c/sims/i2c_cmd_vc.vhd

-67
This file was deleted.

hdl/ip/vhd/i2c/sims/i2c_cmd_vc_pkg.vhd

-82
This file was deleted.

0 commit comments

Comments
 (0)