Commit 7a0c85e 1 parent f87b7d2 commit 7a0c85e Copy full SHA for 7a0c85e
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 @@ -68,6 +68,8 @@ architecture rtl of i2c_ctrl_link_layer is
68
68
constant SDA_TRANSITION_TICKS : positive :=
69
69
to_integer (calc_ns(300 , CLK_PER_NS, 5 ));
70
70
71
+ constant TSP_TICKS : positive := to_integer (calc_ns(SETTINGS.tsp_ns, CLK_PER_NS, 8 ));
72
+
71
73
type state_t is (
72
74
IDLE,
73
75
WAIT_TBUF,
@@ -187,15 +189,22 @@ begin
187
189
-- SDA Control
188
190
--
189
191
190
- -- TODO: this should be a glitch filter that means `tsp` per the spec
191
- sda_in_sync : entity work .meta_sync
192
- generic map (
193
- STAGES => 2
192
+ -- Right now the controller doesn't need much of what this block offers aside from SDA filtering
193
+ i2c_glitch_filter_inst : entity work .i2c_glitch_filter
194
+ generic map (
195
+ filter_cycles => TSP_TICKS
194
196
)
195
197
port map (
196
- async_input => sda_if.i,
197
- clk => clk,
198
- sycnd_output => sda_in_syncd
198
+ clk => clk,
199
+ reset => reset,
200
+ raw_scl => '1' ,
201
+ raw_sda => sda_if.i,
202
+ filtered_scl => open ,
203
+ scl_fedge => open ,
204
+ scl_redge => open ,
205
+ filtered_sda => sda_in_syncd,
206
+ sda_fedge => open ,
207
+ sda_redge => open
199
208
);
200
209
201
210
-- 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