From d8b1e0aa46ecd9a046b636726dbc8eff219aa0e5 Mon Sep 17 00:00:00 2001 From: Karol Gugala Date: Fri, 17 Jan 2025 14:39:51 +0100 Subject: [PATCH] IO: move tristate handling to top level --- src/i3c.f | 1 - src/i3c_wrapper.sv | 17 +++++++++--- src/phy/buf_od.sv | 19 -------------- src/phy/buf_pp.sv | 1 - src/phy/bufs.sv | 26 ++----------------- src/phy/i3c_io.sv | 15 ++--------- verification/cocotb/block/i3c_phy_io/Makefile | 1 - .../block/i3c_phy_io/i3c_phy_io_wrapper.sv | 10 ++++++- 8 files changed, 27 insertions(+), 63 deletions(-) delete mode 100644 src/phy/buf_od.sv diff --git a/src/i3c.f b/src/i3c.f index 8e23c061..17fe146d 100644 --- a/src/i3c.f +++ b/src/i3c.f @@ -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 diff --git a/src/i3c_wrapper.sv b/src/i3c_wrapper.sv index c8c30b04..08d5d9a9 100644 --- a/src/i3c_wrapper.sv +++ b/src/i3c_wrapper.sv @@ -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 diff --git a/src/phy/buf_od.sv b/src/phy/buf_od.sv deleted file mode 100644 index 64ed8e64..00000000 --- a/src/phy/buf_od.sv +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 - -`timescale 1ns / 1ps - -/* - Model of an Open-Drain Driver - - | drive_low | out | - | 0 | z | - | 1 | 0 | -*/ -module buf_od ( - input logic drive_low, - inout wire buf_od_o -); - - assign buf_od_o = drive_low ? 1'b0 : 1'bz; - -endmodule diff --git a/src/phy/buf_pp.sv b/src/phy/buf_pp.sv index ee3cec83..475f2c5a 100644 --- a/src/phy/buf_pp.sv +++ b/src/phy/buf_pp.sv @@ -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, diff --git a/src/phy/bufs.sv b/src/phy/bufs.sv index 21cc5cc0..0ee114e2 100644 --- a/src/phy/bufs.sv +++ b/src/phy/bufs.sv @@ -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 diff --git a/src/phy/i3c_io.sv b/src/phy/i3c_io.sv index 7dbe2235..7fec785a 100644 --- a/src/phy/i3c_io.sv +++ b/src/phy/i3c_io.sv @@ -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 ( @@ -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 @@ -32,15 +24,13 @@ 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 @@ -48,5 +38,4 @@ module i3c_io ( assign scl_o = scl_io; assign sda_o = sda_io; - endmodule diff --git a/verification/cocotb/block/i3c_phy_io/Makefile b/verification/cocotb/block/i3c_phy_io/Makefile index bd0e825d..1c108736 100644 --- a/verification/cocotb/block/i3c_phy_io/Makefile +++ b/verification/cocotb/block/i3c_phy_io/Makefile @@ -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 \ diff --git a/verification/cocotb/block/i3c_phy_io/i3c_phy_io_wrapper.sv b/verification/cocotb/block/i3c_phy_io/i3c_phy_io_wrapper.sv index 491f1321..0aa48426 100644 --- a/verification/cocotb/block/i3c_phy_io/i3c_phy_io_wrapper.sv +++ b/verification/cocotb/block/i3c_phy_io/i3c_phy_io_wrapper.sv @@ -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), @@ -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