Skip to content

Commit 817d3e5

Browse files
Updates to muxes to support multiple instances sharing i2c bus.
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
1 parent 9ecd722 commit 817d3e5

File tree

13 files changed

+421
-158
lines changed

13 files changed

+421
-158
lines changed

hdl/ip/vhd/i2c/io_expanders/PCA9506ish/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ vunit_sim(
2424
deps = [
2525
":pca9506_top",
2626
"//hdl/ip/vhd/vunit_components:i2c_controller_vc",
27+
"//hdl/ip/vhd/i2c/target:i2c_phy_consolidator",
2728
],
2829
visibility = ['PUBLIC'],
2930
)

hdl/ip/vhd/i2c/io_expanders/PCA9506ish/pca9506_function.vhd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ begin
9191
case r.state is
9292
when IDLE =>
9393
v.increment := '0';
94+
v.data_valid := '0';
95+
v.post_ack_state := IDLE;
9496
if txn_header.valid = '1' and txn_header.tgt_addr = i2c_addr then
9597
v.state := ACK;
9698
if txn_header.read_write_n = '0' then

hdl/ip/vhd/i2c/io_expanders/PCA9506ish/sims/i2c_pca9506ish_sim_pkg.vhd

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,36 @@ use work.i2c_ctrl_vc_pkg.all;
1717

1818
package i2c_pca9506ish_sim_pkg is
1919

20-
constant i2c_tgt_addr: std_logic_vector(6 downto 0) := 7x"20";
21-
2220
constant i2c_ctrl_vc : i2c_ctrl_vc_t := new_i2c_ctrl_vc("i2c_ctrl_vc");
2321

2422
-- Some helper functions for writing test benches.
2523
-- want to be able to read/write arbitrary registers
2624
-- want to be able to read/write categories of registers (wrapping)
2725
procedure single_write_pca9506_reg(
2826
signal net : inout network_t;
27+
constant i2c_addr : in std_logic_vector(6 downto 0);
2928
constant register_addr : in integer range 0 to 16#27#;
3029
constant write_data: in std_logic_vector(7 downto 0);
3130
variable did_ack: inout boolean;
32-
constant auto_inc: in boolean := true;
33-
constant i2c_addr : in std_logic_vector(6 downto 0) := i2c_tgt_addr
31+
constant auto_inc: in boolean := true
3432
);
3533
procedure write_pca9506_reg(
3634
signal net : inout network_t;
35+
constant i2c_addr : in std_logic_vector(6 downto 0);
3736
constant starting_reg : in integer range 0 to 16#27#;
3837
constant byte_queue: in queue_t;
3938
constant ack_queue: in queue_t;
40-
constant auto_inc: in boolean := true;
41-
constant i2c_addr : in std_logic_vector(6 downto 0) := i2c_tgt_addr
39+
constant auto_inc: in boolean := true
4240
);
4341

4442
procedure read_pca9506_reg(
4543
signal net : inout network_t;
44+
constant i2c_addr : in std_logic_vector(6 downto 0);
4645
constant starting_reg : in integer range 0 to 16#27#;
4746
constant num_regs_to_read : in integer;
4847
constant response_queue: in queue_t;
4948
constant ack_queue: in queue_t;
50-
constant auto_inc: in boolean := true;
51-
constant i2c_addr : in std_logic_vector(6 downto 0) := i2c_tgt_addr
49+
constant auto_inc: in boolean := true
5250
);
5351

5452
end package;
@@ -57,17 +55,17 @@ package body i2c_pca9506ish_sim_pkg is
5755

5856
procedure single_write_pca9506_reg(
5957
signal net : inout network_t;
58+
constant i2c_addr : in std_logic_vector(6 downto 0);
6059
constant register_addr : in integer range 0 to 16#27#;
6160
constant write_data: in std_logic_vector(7 downto 0);
6261
variable did_ack: inout boolean;
63-
constant auto_inc: in boolean := true;
64-
constant i2c_addr : in std_logic_vector(6 downto 0) := i2c_tgt_addr
62+
constant auto_inc: in boolean := true
6563
) is
6664
constant tx_queue : queue_t := new_queue;
6765
constant ack_queue: queue_t := new_queue;
6866
begin
6967
push_byte(tx_queue, to_integer(write_data));
70-
write_pca9506_reg(net, register_addr, tx_queue, tx_queue, auto_inc, i2c_addr);
68+
write_pca9506_reg(net, i2c_addr, register_addr, tx_queue, tx_queue, auto_inc);
7169
did_ack := true;
7270
while not is_empty(ack_queue) loop
7371
if pop_byte(ack_queue) = 0 then
@@ -79,11 +77,11 @@ package body i2c_pca9506ish_sim_pkg is
7977

8078
procedure write_pca9506_reg(
8179
signal net : inout network_t;
80+
constant i2c_addr : in std_logic_vector(6 downto 0);
8281
constant starting_reg : in integer range 0 to 16#27#;
8382
constant byte_queue: in queue_t;
8483
constant ack_queue: in queue_t;
85-
constant auto_inc: in boolean := true;
86-
constant i2c_addr : in std_logic_vector(6 downto 0) := i2c_tgt_addr
84+
constant auto_inc: in boolean := true
8785
) is
8886
variable cmd_reg : std_logic_vector(7 downto 0);
8987
constant tx_queue : queue_t := new_queue;
@@ -102,12 +100,12 @@ package body i2c_pca9506ish_sim_pkg is
102100

103101
procedure read_pca9506_reg(
104102
signal net : inout network_t;
103+
constant i2c_addr : in std_logic_vector(6 downto 0);
105104
constant starting_reg : in integer range 0 to 16#27#;
106105
constant num_regs_to_read : in integer;
107106
constant response_queue: in queue_t;
108107
constant ack_queue: in queue_t;
109-
constant auto_inc: in boolean := true;
110-
constant i2c_addr : in std_logic_vector(6 downto 0) := i2c_tgt_addr
108+
constant auto_inc: in boolean := true
111109
) is
112110
variable cmd_reg : std_logic_vector(7 downto 0);
113111
constant tx_queue : queue_t := new_queue;

0 commit comments

Comments
 (0)