Skip to content

Commit

Permalink
Updates to muxes to support multiple instances sharing i2c bus.
Browse files Browse the repository at this point in the history
Add input signal so that we can ignore requests to enable multiple
mux channels concurrently, even across virtual pca9545s, and 
test cases to check this stuff.
adds the phy consolidator and test
  • Loading branch information
nathanaelhuffman committed Jan 29, 2025
1 parent 5c5a3a8 commit 8fdfa33
Show file tree
Hide file tree
Showing 13 changed files with 421 additions and 158 deletions.
1 change: 1 addition & 0 deletions hdl/ip/vhd/i2c/io_expanders/PCA9506ish/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ vunit_sim(
deps = [
":pca9506_top",
"//hdl/ip/vhd/vunit_components:i2c_controller_vc",
"//hdl/ip/vhd/i2c/target:i2c_phy_consolidator",
],
visibility = ['PUBLIC'],
)
2 changes: 2 additions & 0 deletions hdl/ip/vhd/i2c/io_expanders/PCA9506ish/pca9506_function.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ begin
case r.state is
when IDLE =>
v.increment := '0';
v.data_valid := '0';
v.post_ack_state := IDLE;
if txn_header.valid = '1' and txn_header.tgt_addr = i2c_addr then
v.state := ACK;
if txn_header.read_write_n = '0' then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,36 @@ use work.i2c_ctrl_vc_pkg.all;

package i2c_pca9506ish_sim_pkg is

constant i2c_tgt_addr: std_logic_vector(6 downto 0) := 7x"20";

constant i2c_ctrl_vc : i2c_ctrl_vc_t := new_i2c_ctrl_vc("i2c_ctrl_vc");

-- Some helper functions for writing test benches.
-- want to be able to read/write arbitrary registers
-- want to be able to read/write categories of registers (wrapping)
procedure single_write_pca9506_reg(
signal net : inout network_t;
constant i2c_addr : in std_logic_vector(6 downto 0);
constant register_addr : in integer range 0 to 16#27#;
constant write_data: in std_logic_vector(7 downto 0);
variable did_ack: inout boolean;
constant auto_inc: in boolean := true;
constant i2c_addr : in std_logic_vector(6 downto 0) := i2c_tgt_addr
constant auto_inc: in boolean := true
);
procedure write_pca9506_reg(
signal net : inout network_t;
constant i2c_addr : in std_logic_vector(6 downto 0);
constant starting_reg : in integer range 0 to 16#27#;
constant byte_queue: in queue_t;
constant ack_queue: in queue_t;
constant auto_inc: in boolean := true;
constant i2c_addr : in std_logic_vector(6 downto 0) := i2c_tgt_addr
constant auto_inc: in boolean := true
);

procedure read_pca9506_reg(
signal net : inout network_t;
constant i2c_addr : in std_logic_vector(6 downto 0);
constant starting_reg : in integer range 0 to 16#27#;
constant num_regs_to_read : in integer;
constant response_queue: in queue_t;
constant ack_queue: in queue_t;
constant auto_inc: in boolean := true;
constant i2c_addr : in std_logic_vector(6 downto 0) := i2c_tgt_addr
constant auto_inc: in boolean := true
);

end package;
Expand All @@ -57,17 +55,17 @@ package body i2c_pca9506ish_sim_pkg is

procedure single_write_pca9506_reg(
signal net : inout network_t;
constant i2c_addr : in std_logic_vector(6 downto 0);
constant register_addr : in integer range 0 to 16#27#;
constant write_data: in std_logic_vector(7 downto 0);
variable did_ack: inout boolean;
constant auto_inc: in boolean := true;
constant i2c_addr : in std_logic_vector(6 downto 0) := i2c_tgt_addr
constant auto_inc: in boolean := true
) is
constant tx_queue : queue_t := new_queue;
constant ack_queue: queue_t := new_queue;
begin
push_byte(tx_queue, to_integer(write_data));
write_pca9506_reg(net, register_addr, tx_queue, tx_queue, auto_inc, i2c_addr);
write_pca9506_reg(net, i2c_addr, register_addr, tx_queue, tx_queue, auto_inc);
did_ack := true;
while not is_empty(ack_queue) loop
if pop_byte(ack_queue) = 0 then
Expand All @@ -79,11 +77,11 @@ package body i2c_pca9506ish_sim_pkg is

procedure write_pca9506_reg(
signal net : inout network_t;
constant i2c_addr : in std_logic_vector(6 downto 0);
constant starting_reg : in integer range 0 to 16#27#;
constant byte_queue: in queue_t;
constant ack_queue: in queue_t;
constant auto_inc: in boolean := true;
constant i2c_addr : in std_logic_vector(6 downto 0) := i2c_tgt_addr
constant auto_inc: in boolean := true
) is
variable cmd_reg : std_logic_vector(7 downto 0);
constant tx_queue : queue_t := new_queue;
Expand All @@ -102,12 +100,12 @@ package body i2c_pca9506ish_sim_pkg is

procedure read_pca9506_reg(
signal net : inout network_t;
constant i2c_addr : in std_logic_vector(6 downto 0);
constant starting_reg : in integer range 0 to 16#27#;
constant num_regs_to_read : in integer;
constant response_queue: in queue_t;
constant ack_queue: in queue_t;
constant auto_inc: in boolean := true;
constant i2c_addr : in std_logic_vector(6 downto 0) := i2c_tgt_addr
constant auto_inc: in boolean := true
) is
variable cmd_reg : std_logic_vector(7 downto 0);
constant tx_queue : queue_t := new_queue;
Expand Down
Loading

0 comments on commit 8fdfa33

Please sign in to comment.