Skip to content

Commit 638bc46

Browse files
committed
make the I2C Controller VC performance configurable
1 parent d53da34 commit 638bc46

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

hdl/ip/vhd/i2c/common/i2c_common_pkg.vhd

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ package i2c_common_pkg is
1414
--
1515

1616
type mode_t is (
17+
SIMULATION, -- arbitrarily fast for simulation only
1718
STANDARD, -- up to 100 Kbps
1819
FAST, -- up to 400 Kbps
1920
FAST_PLUS -- up to 1 Mbps
@@ -60,6 +61,15 @@ package body i2c_common_pkg is
6061
variable r : settings_t;
6162
begin
6263
case mode is
64+
when SIMULATION =>
65+
r := (
66+
800,
67+
50, -- currently unused by our simulated controller
68+
200,
69+
200,
70+
200,
71+
50 -- currently unsed by our simulated controller
72+
);
6373
when STANDARD =>
6474
r := (
6575
10_000, -- 10^9 / 100_000Hz

hdl/ip/vhd/vunit_components/BUCK

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ vhdl_unit(
2929
vhdl_unit(
3030
name = "i2c_controller_vc",
3131
srcs = glob(["i2c_controller/*.vhd"]),
32+
deps = ["//hdl/ip/vhd/i2c/common:i2c_common_pkg"],
3233
visibility = ['PUBLIC'],
3334
)
3435

hdl/ip/vhd/vunit_components/i2c_controller/i2c_ctrlr_vc.vhd

+8-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ library vunit_lib;
2222
context vunit_lib.com_context;
2323
use vunit_lib.sync_pkg.all;
2424

25+
use work.i2c_common_pkg.all;
2526
use work.i2c_ctrl_vc_pkg.all;
2627

2728
entity i2c_controller_vc is
2829
generic (
29-
i2c_ctrl_vc : i2c_ctrl_vc_t
30+
i2c_ctrl_vc : i2c_ctrl_vc_t;
31+
mode : mode_t := SIMULATION
3032
);
3133
port (
3234
scl : inout std_logic := 'Z';
@@ -35,10 +37,11 @@ entity i2c_controller_vc is
3537
end entity;
3638

3739
architecture model of i2c_controller_vc is
38-
constant sclk_per : time := 800 ns;
39-
constant thd_sta : time := 200 ns;
40-
constant tsu_sto : time := 200 ns;
41-
constant tbuf : time := 200 ns;
40+
constant settings : settings_t := get_i2c_settings(mode);
41+
constant sclk_per : time := settings.fscl_period_ns * 1 ns;
42+
constant thd_sta : time := settings.sta_su_hd_ns * 1 ns;
43+
constant tsu_sto : time := settings.sto_su_ns * 1 ns;
44+
constant tbuf : time := settings.sto_sta_buf_ns * 1 ns;
4245
type state_t is (IDLE, START, STOP, IN_DATA, OUT_DATA, ACK, NACK, GET_ACK_OR_NACK);
4346
signal state : state_t := IDLE;
4447
type flags_t is record

0 commit comments

Comments
 (0)