Skip to content

Commit

Permalink
[i2c] Change existing interrupts to Status
Browse files Browse the repository at this point in the history
Modify existing FIFO Threshold interrupts to Status type.

Signed-off-by: Adrian Lees <[email protected]>
  • Loading branch information
alees24 authored and andreaskurth committed Feb 29, 2024
1 parent 2a0f24e commit 10fc8b8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
2 changes: 2 additions & 0 deletions hw/ip/i2c/data/i2c.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@
interrupt_list: [
{ name: "fmt_threshold"
desc: "host mode interrupt: raised when the FMT FIFO depth is less than the low threshold."
type: "status"
}
{ name: "rx_threshold"
desc: "host mode interrupt: raised if the RX FIFO is greater than the high threshold."
type: "status"
}
{ name: "fmt_overflow"
desc: "host mode interrupt: raised if the FMT FIFO has overflowed."
Expand Down
62 changes: 28 additions & 34 deletions hw/ip/i2c/rtl/i2c_core.sv
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ module i2c_core import i2c_pkg::*;
logic rx_fifo_rready;
logic [7:0] rx_fifo_rdata;

logic fmt_threshold_d;
logic fmt_threshold_q;
logic rx_threshold_d;
logic rx_threshold_q;
// FMT FIFO level at or below programmed threshold
logic fmt_le_threshold;
// Rx FIFO level at or above programmed threshold
logic rx_ge_threshold;

logic tx_fifo_wvalid;
logic tx_fifo_wready;
Expand Down Expand Up @@ -220,40 +220,28 @@ module i2c_core import i2c_pkg::*;
assign i2c_fifo_txrst = reg2hw.fifo_ctrl.txrst.q & reg2hw.fifo_ctrl.txrst.qe;
assign i2c_fifo_acqrst = reg2hw.fifo_ctrl.acqrst.q & reg2hw.fifo_ctrl.acqrst.qe;

always_ff @ (posedge clk_i or negedge rst_ni) begin : threshold_transition
if (!rst_ni) begin
fmt_threshold_q <= 1'b1; // true by default
rx_threshold_q <= 1'b0; // false by default
end else begin
fmt_threshold_q <= fmt_threshold_d;
rx_threshold_q <= rx_threshold_d;
end
end

// FMT FIFO level at or below programmed threshold
always_comb begin
unique case(i2c_fifo_fmtilvl)
2'h0: fmt_threshold_d = (fmt_fifo_depth <= 7'd1);
2'h1: fmt_threshold_d = (fmt_fifo_depth <= 7'd4);
2'h2: fmt_threshold_d = (fmt_fifo_depth <= 7'd8);
default: fmt_threshold_d = (fmt_fifo_depth <= 7'd16);
2'h0: fmt_le_threshold = (fmt_fifo_depth <= 7'd1);
2'h1: fmt_le_threshold = (fmt_fifo_depth <= 7'd4);
2'h2: fmt_le_threshold = (fmt_fifo_depth <= 7'd8);
default: fmt_le_threshold = (fmt_fifo_depth <= 7'd16);
endcase
end

assign event_fmt_threshold = fmt_threshold_d & ~fmt_threshold_q;

// Rx FIFO level at or above programmed threshold
always_comb begin
unique case(i2c_fifo_rxilvl)
3'h0: rx_threshold_d = (rx_fifo_depth >= 7'd1);
3'h1: rx_threshold_d = (rx_fifo_depth >= 7'd4);
3'h2: rx_threshold_d = (rx_fifo_depth >= 7'd8);
3'h3: rx_threshold_d = (rx_fifo_depth >= 7'd16);
3'h4: rx_threshold_d = (rx_fifo_depth >= 7'd30);
default: rx_threshold_d = 1'b0;
3'h0: rx_ge_threshold = (rx_fifo_depth >= 7'd1);
3'h1: rx_ge_threshold = (rx_fifo_depth >= 7'd4);
3'h2: rx_ge_threshold = (rx_fifo_depth >= 7'd8);
3'h3: rx_ge_threshold = (rx_fifo_depth >= 7'd16);
3'h4: rx_ge_threshold = (rx_fifo_depth >= 7'd30);
default: rx_ge_threshold = 1'b0;
endcase
end

assign event_rx_threshold = rx_threshold_d & ~rx_threshold_q;

assign event_fmt_overflow = fmt_fifo_wvalid & ~fmt_fifo_wready;
assign event_rx_overflow = rx_fifo_wvalid & ~rx_fifo_wready;

Expand Down Expand Up @@ -480,10 +468,13 @@ module i2c_core import i2c_pkg::*;
.event_host_timeout_o (event_host_timeout)
);

prim_intr_hw #(.Width(1)) intr_hw_fmt_threshold (
prim_intr_hw #(
.Width(1),
.IntrT("Status")
) intr_hw_fmt_threshold (
.clk_i,
.rst_ni,
.event_intr_i (event_fmt_threshold),
.event_intr_i (fmt_le_threshold),
.reg2hw_intr_enable_q_i (reg2hw.intr_enable.fmt_threshold.q),
.reg2hw_intr_test_q_i (reg2hw.intr_test.fmt_threshold.q),
.reg2hw_intr_test_qe_i (reg2hw.intr_test.fmt_threshold.qe),
Expand All @@ -493,10 +484,13 @@ module i2c_core import i2c_pkg::*;
.intr_o (intr_fmt_threshold_o)
);

prim_intr_hw #(.Width(1)) intr_hw_rx_threshold (
prim_intr_hw #(
.Width(1),
.IntrT("Status")
) intr_hw_rx_threshold (
.clk_i,
.rst_ni,
.event_intr_i (event_rx_threshold),
.event_intr_i (rx_ge_threshold),
.reg2hw_intr_enable_q_i (reg2hw.intr_enable.rx_threshold.q),
.reg2hw_intr_test_q_i (reg2hw.intr_test.rx_threshold.q),
.reg2hw_intr_test_qe_i (reg2hw.intr_test.rx_threshold.qe),
Expand Down Expand Up @@ -612,7 +606,7 @@ module i2c_core import i2c_pkg::*;

prim_intr_hw #(
.Width(1),
.IntrT ("Status")
.IntrT("Status")
) intr_hw_tx_stretch (
.clk_i,
.rst_ni,
Expand Down Expand Up @@ -641,7 +635,7 @@ module i2c_core import i2c_pkg::*;

prim_intr_hw #(
.Width(1),
.IntrT ("Status")
.IntrT("Status")
) intr_hw_acq_overflow (
.clk_i,
.rst_ni,
Expand Down

0 comments on commit 10fc8b8

Please sign in to comment.