Skip to content

Commit

Permalink
IO: move tristate handling to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
kgugala committed Jan 17, 2025
1 parent f35c8c5 commit d8b1e0a
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 63 deletions.
1 change: 0 additions & 1 deletion src/i3c.f
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
${I3C_ROOT_DIR}/src/csr/I3CCSR_pkg.sv
${I3C_ROOT_DIR}/src/ctrl/controller_pkg.sv
${I3C_ROOT_DIR}/src/i3c_pkg.sv
${I3C_ROOT_DIR}/src/phy/buf_od.sv
${I3C_ROOT_DIR}/src/phy/buf_pp.sv
${I3C_ROOT_DIR}/src/phy/bufs.sv
${I3C_ROOT_DIR}/src/phy/i3c_phy.sv
Expand Down
17 changes: 14 additions & 3 deletions src/i3c_wrapper.sv
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,27 @@ module i3c_wrapper #(
assign sda_o = sda_phy2io;
assign sel_od_pp_o = sel_od_pp;
`else
logic scl_drive_low, sda_drive_low;
logic sda_od, scl_od;
wire i3c_scl_pp_io, i3c_scl_pp_io;
assign scl_drive_low = ~scl_phy2io;
assign sda_drive_low = ~sda_phy2io;

i3c_io xio (
.scl_i(scl_phy2io),
.sda_i(sda_phy2io),
.scl_o(scl_io2phy),
.sda_o(sda_io2phy),
.sel_od_pp_i(sel_od_pp),
.scl_io(i3c_scl_io),
.sda_io(i3c_sda_io)
.scl_io(i3c_scl_pp_io),
.sda_io(i3c_sda_pp_io)
);
`endif

assign sda_od = sda_drive_low ? 1'b0 : 1'bz;
assign scl_od = scl_drive_low ? 1'b0 : 1'bz;
assign i3c_sda_io = sel_od_pp ? i3c_sda_pp_io : sda_od;
assign i3c_scl_io = sel_od_pp ? i3c_scl_pp_io : scl_od;

`endif

endmodule
19 changes: 0 additions & 19 deletions src/phy/buf_od.sv

This file was deleted.

1 change: 0 additions & 1 deletion src/phy/buf_pp.sv
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
| 1 | 0| 1 |
| 1 | 1| x |
TODO: Add assertion for when pull_up_en and pull_down_en have the same state
*/
module buf_pp (
input logic pull_up_en,
Expand Down
26 changes: 2 additions & 24 deletions src/phy/bufs.sv
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,20 @@

`timescale 1ns / 1ps

/*
Combined model of the Open-Drain Driver and Push-Pull Driver for the I3C bus lines.
| sel_driver_i | phy_data_i | phy_data_io |
| 0 | 0 | z |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
*/
module bufs (
input logic phy_data_i,
input logic sel_od_pp_i,
inout wire phy_data_io
output wire phy_data_o
);

logic phy_data_i_z;

assign phy_data_i_z = ~phy_data_i;

logic buf_pp_o;
wire buf_od_o;

// Model of a Push-Pull driver
buf_pp xbuf_pp (
.pull_up_en(phy_data_i),
.pull_down_en(phy_data_i_z),
.buf_pp_o(buf_pp_o)
.buf_pp_o(phy_data_o)
);

// Model of an Open-Drain driver
buf_od xbuf_od (
.drive_low(~phy_data_i),
.buf_od_o (buf_od_o)
);

// Mux between OD and PP
assign phy_data_io = sel_od_pp_i ? buf_pp_o : buf_od_o;

endmodule
15 changes: 2 additions & 13 deletions src/phy/i3c_io.sv
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

/*
This module provides IO definition for the I3C Core.
The Core provides a few IO models, which can be used for different use cases:
- simulation
- FPGA emulation
- silicon synthesis
*/

module i3c_io (
Expand All @@ -21,9 +16,6 @@ module i3c_io (
output logic scl_o,
output logic sda_o,

// Open-Drain / Push-Pull control
input logic sel_od_pp_i,

// Bus {SCL, SDA}
inout wire scl_io,
inout wire sda_io
Expand All @@ -32,21 +24,18 @@ module i3c_io (
// SCL buffers
bufs xbufs_scl (
.phy_data_i (scl_i),
.sel_od_pp_i(sel_od_pp_i),
.phy_data_io(scl_io)
.phy_data_o(scl_io)
);

// SDA buffers
bufs xbufs_sda (
.phy_data_i (sda_i),
.sel_od_pp_i(sel_od_pp_i),
.phy_data_io(sda_io)
.phy_data_o(sda_io)
);

// Bus state is read to provide feedback to the controller
// Used to resolve bus arbitration and detect bus error conditions
assign scl_o = scl_io;
assign sda_o = sda_io;


endmodule
1 change: 0 additions & 1 deletion verification/cocotb/block/i3c_phy_io/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ TOPLEVEL = i3c_phy_io_wrapper
include $(TEST_DIR)/../../caliptra_common.mk

VERILOG_SOURCES += \
$(SRC_DIR)/phy/buf_od.sv \
$(SRC_DIR)/phy/buf_pp.sv \
$(SRC_DIR)/phy/bufs.sv \
$(SRC_DIR)/phy/i3c_io.sv \
Expand Down
10 changes: 9 additions & 1 deletion verification/cocotb/block/i3c_phy_io/i3c_phy_io_wrapper.sv
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ module i3c_phy_io_wrapper (
logic sda_io2phy;
logic sel_od_pp;

logic scl_drive_low, sda_drive_low;
logic sda_od, scl_od;
assign scl_drive_low = ~scl_phy2io;
assign sda_drive_low = ~sda_phy2io;

i3c_phy xphy(
.clk_i(clk_i),
.rst_ni(rst_ni),
Expand All @@ -50,11 +55,14 @@ module i3c_phy_io_wrapper (
.sda_i(sda_phy2io),
.scl_o(scl_io2phy),
.sda_o(sda_io2phy),
.sel_od_pp_i(sel_od_pp),
.scl_io(scl_io),
.sda_io(sda_io)
);

assign sda_od = sda_drive_low ? 1'b0 : 1'bz;
assign scl_od = sda_drive_low ? 1'b0 : 1'bz;
assign i3c_sda_io = sel_od_pp ? sda_io : sda_od;
assign i3c_scl_io = sel_od_pp ? scl_io : scl_od;

initial
begin
Expand Down

0 comments on commit d8b1e0a

Please sign in to comment.