Commit e317723 1 parent 46e66c7 commit e317723 Copy full SHA for e317723
File tree 5 files changed +30
-15
lines changed
5 files changed +30
-15
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ vhdl_unit(
16
16
name = "i2c_glitch_filter" ,
17
17
srcs = ["i2c_glitch_filter.vhd" ],
18
18
deps = [
19
- "//hdl/ip/vhd/synchronizers:meta_sync" ,
19
+ "//hdl/ip/vhd/common:transforms_pkg" ,
20
+ "//hdl/ip/vhd/synchronizers:meta_sync" ,
20
21
],
21
22
visibility = ['PUBLIC' ]
22
23
)
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ package i2c_common_pkg is
27
27
sta_su_hd_ns : positive ; -- START set-up/hold time
28
28
sto_su_ns : positive ; -- STOP set-up time
29
29
sto_sta_buf_ns : positive ; -- bus free time between STOP and START
30
+ tsp_ns : positive ; -- pulse width of spikes to be suppressed by the input filter
30
31
end record ;
31
32
32
33
function get_i2c_settings (constant mode : mode_t) return settings_t;
@@ -65,23 +66,26 @@ package body i2c_common_pkg is
65
66
250 ,
66
67
4700 ,
67
68
4000 ,
68
- 4700
69
+ 4700 ,
70
+ 50 -- this is technically undefined in the spec
69
71
);
70
72
when FAST =>
71
73
r := (
72
74
2500 , -- 10^9 / 400_000Hz
73
75
100 ,
74
76
600 ,
75
77
600 ,
76
- 1300
78
+ 1300 ,
79
+ 50
77
80
);
78
81
when FAST_PLUS =>
79
82
r := (
80
83
1000 , -- 10^9 / 1_000_000Hz
81
84
50 ,
82
85
260 ,
83
86
260 ,
84
- 500
87
+ 500 ,
88
+ 50
85
89
);
86
90
end case ;
87
91
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ use ieee.std_logic_1164.all;
18
18
use ieee.numeric_std.all ;
19
19
use ieee.numeric_std_unsigned.all ;
20
20
21
+ use work.transforms_pkg.shift_in_at_0;
22
+
21
23
entity i2c_glitch_filter is
22
24
generic (
23
25
-- number of register stages the n filter pipeline
86
88
last_sda <= filtered_sda;
87
89
-- Using variables here to make the filtered outputs
88
90
-- simultaneous more easily
89
- nxt_scl_pipe := shift_left (scl_pipe, 1 );
90
- nxt_scl_pipe(0 ) := scl_syncd;
91
+ nxt_scl_pipe := shift_in_at_0(scl_pipe, scl_syncd);
91
92
scl_pipe <= nxt_scl_pipe; -- do the register assignment
92
- nxt_sda_pipe := shift_left (sda_pipe, 1 );
93
- nxt_sda_pipe(0 ) := sda_syncd;
93
+ nxt_sda_pipe := shift_in_at_0(sda_pipe, sda_syncd);
94
94
sda_pipe <= nxt_sda_pipe; -- do the register assignment
95
95
96
96
-- we use the variables set above here to make the filtered outputs
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ vhdl_unit(
15
15
"txn_layer/*.vhd" ,]),
16
16
deps = [
17
17
"//hdl/ip/vhd/i2c/common:i2c_common_pkg" ,
18
+ "//hdl/ip/vhd/i2c/common:i2c_glitch_filter" ,
18
19
"//hdl/ip/vhd/common:countdown" ,
19
20
"//hdl/ip/vhd/common:strobe" ,
20
21
"//hdl/ip/vhd/common:streaming_if_pkg" ,
Original file line number Diff line number Diff line change @@ -77,6 +77,8 @@ architecture rtl of i2c_ctrl_link_layer is
77
77
constant SDA_TRANSITION_TICKS : positive :=
78
78
to_integer (calc_ns(300 , CLK_PER_NS, 5 ));
79
79
80
+ constant TSP_TICKS : positive := to_integer (calc_ns(SETTINGS.tsp_ns, CLK_PER_NS, 8 ));
81
+
80
82
type state_t is (
81
83
IDLE,
82
84
WAIT_TBUF,
@@ -198,15 +200,22 @@ begin
198
200
-- SDA Control
199
201
--
200
202
201
- -- TODO: this should be a glitch filter that means `tsp` per the spec
202
- sda_in_sync : entity work .meta_sync
203
- generic map (
204
- STAGES => 2
203
+ -- Right now the controller doesn't need much of what this block offers aside from SDA filtering
204
+ i2c_glitch_filter_inst : entity work .i2c_glitch_filter
205
+ generic map (
206
+ filter_cycles => TSP_TICKS
205
207
)
206
208
port map (
207
- async_input => sda_if.i,
208
- clk => clk,
209
- sycnd_output => sda_in_syncd
209
+ clk => clk,
210
+ reset => reset,
211
+ raw_scl => '1' ,
212
+ raw_sda => sda_if.i,
213
+ filtered_scl => open ,
214
+ scl_fedge => open ,
215
+ scl_redge => open ,
216
+ filtered_sda => sda_in_syncd,
217
+ sda_fedge => open ,
218
+ sda_redge => open
210
219
);
211
220
212
221
-- This counter enforces `tvd` per the spec, ensuring we transition SDA only after an
You can’t perform that action at this time.
0 commit comments