Skip to content

Commit

Permalink
[kmac] Change fifo_empty interrupt type to status
Browse files Browse the repository at this point in the history
This resolves #21049.

Signed-off-by: Pirmin Vogel <[email protected]>
  • Loading branch information
vogelpi committed Feb 26, 2024
1 parent c31cc32 commit 6645b60
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 33 deletions.
8 changes: 7 additions & 1 deletion hw/ip/kmac/data/kmac.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@
desc: "KMAC/SHA3 absorbing has been completed"
}
{ name: "fifo_empty"
desc: "Message FIFO empty condition"
type: "status"
desc: '''
The message FIFO is empty.
This interrupt is not raised or de-asserts if any of the following conditions are met:
1) The KMAC block is exercised by a hardware application interface.
2) The KMAC block is completely idle, e.g., after finishing an operation.
'''
}
{ name: "kmac_err"
desc: "KMAC/SHA3 error occurred. ERR_CODE register shows the details"
Expand Down
10 changes: 5 additions & 5 deletions hw/ip/kmac/doc/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Referring to the [Comportable guideline for peripheral device functionality](htt

## Interrupts

| Interrupt Name | Type | Description |
|:-----------------|:-------|:--------------------------------------------------------------|
| kmac_done | Event | KMAC/SHA3 absorbing has been completed |
| fifo_empty | Event | Message FIFO empty condition |
| kmac_err | Event | KMAC/SHA3 error occurred. ERR_CODE register shows the details |
| Interrupt Name | Type | Description |
|:-----------------|:-------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| kmac_done | Event | KMAC/SHA3 absorbing has been completed |
| fifo_empty | Status | The message FIFO is empty. This interrupt is not raised or de-asserts if any of the following conditions are met: 1) The KMAC block is exercised by a hardware application interface. 2) The KMAC block is completely idle, e.g., after finishing an operation. |
| kmac_err | Event | KMAC/SHA3 error occurred. ERR_CODE register shows the details |

## Security Alerts

Expand Down
26 changes: 19 additions & 7 deletions hw/ip/kmac/doc/registers.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,27 @@ Interrupt State Register
### Fields

```wavejson
{"reg": [{"name": "kmac_done", "bits": 1, "attr": ["rw1c"], "rotate": -90}, {"name": "fifo_empty", "bits": 1, "attr": ["rw1c"], "rotate": -90}, {"name": "kmac_err", "bits": 1, "attr": ["rw1c"], "rotate": -90}, {"bits": 29}], "config": {"lanes": 1, "fontsize": 10, "vspace": 120}}
{"reg": [{"name": "kmac_done", "bits": 1, "attr": ["rw1c"], "rotate": -90}, {"name": "fifo_empty", "bits": 1, "attr": ["ro"], "rotate": -90}, {"name": "kmac_err", "bits": 1, "attr": ["rw1c"], "rotate": -90}, {"bits": 29}], "config": {"lanes": 1, "fontsize": 10, "vspace": 120}}
```

| Bits | Type | Reset | Name | Description |
|:------:|:------:|:-------:|:-----------|:--------------------------------------------------------------|
| 31:3 | | | | Reserved |
| 2 | rw1c | 0x0 | kmac_err | KMAC/SHA3 error occurred. ERR_CODE register shows the details |
| 1 | rw1c | 0x0 | fifo_empty | Message FIFO empty condition |
| 0 | rw1c | 0x0 | kmac_done | KMAC/SHA3 absorbing has been completed |
| Bits | Type | Reset | Name |
|:------:|:------:|:-------:|:--------------------------------------|
| 31:3 | | | Reserved |
| 2 | rw1c | 0x0 | [kmac_err](#intr_state--kmac_err) |
| 1 | ro | 0x0 | [fifo_empty](#intr_state--fifo_empty) |
| 0 | rw1c | 0x0 | [kmac_done](#intr_state--kmac_done) |

### INTR_STATE . kmac_err
KMAC/SHA3 error occurred. ERR_CODE register shows the details

### INTR_STATE . fifo_empty
The message FIFO is empty.
This interrupt is not raised or de-asserts if any of the following conditions are met:
1) The KMAC block is exercised by a hardware application interface.
2) The KMAC block is completely idle, e.g., after finishing an operation.

### INTR_STATE . kmac_done
KMAC/SHA3 absorbing has been completed

## INTR_ENABLE
Interrupt Enable Register
Expand Down
1 change: 0 additions & 1 deletion hw/ip/kmac/dv/env/kmac_scoreboard.sv
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,6 @@ class kmac_scoreboard extends cip_base_scoreboard #(
if (data_phase_write) begin
// clear internal state on a write
if (item.a_data[KmacDone]) intr_kmac_done = 0;
if (item.a_data[KmacFifoEmpty]) intr_fifo_empty = 0;
if (item.a_data[KmacErr]) intr_kmac_err = 0;
end else if (data_phase_read) begin
// ICEBOX: check below
Expand Down
25 changes: 14 additions & 11 deletions hw/ip/kmac/rtl/kmac.sv
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,6 @@ module kmac
// Interrupt //
///////////////

logic event_msgfifo_empty, msgfifo_empty_q;

// Hash process absorbed interrupt
// Convert mubi4_t to logic to generate interrupts
assign event_absorbed = prim_mubi_pkg::mubi4_test_true_strict(app_absorbed);
Expand All @@ -605,17 +603,22 @@ module kmac
$rose(prim_mubi_pkg::mubi4_test_true_strict(sha3_absorbed)) |=>
prim_mubi_pkg::mubi4_test_false_strict(sha3_absorbed))

always_ff @(posedge clk_i or negedge rst_ni) begin
if (!rst_ni) msgfifo_empty_q <= 1'b1;
else msgfifo_empty_q <= msgfifo_empty;
end

assign event_msgfifo_empty = ~msgfifo_empty_q & msgfifo_empty;

prim_intr_hw #(.Width(1)) intr_fifo_empty (
// Message FIFO empty interrupt
// The message FIFO empty interrupt is not useful for software if:
// - One of the hardware application interfaces is actively using the KMAC block. In this case
// the message FIFO including the empty condition is managed entirely by the application
// interface.
// - The KMAC block is completely idle. The FIFO should anyway be empty in that case.
logic status_msgfifo_empty;
assign status_msgfifo_empty = msgfifo_empty & ~app_active & (sha3_fsm != sha3_pkg::StIdle);

prim_intr_hw #(
.Width(1),
.IntrT("Status")
) intr_fifo_empty (
.clk_i,
.rst_ni,
.event_intr_i (event_msgfifo_empty),
.event_intr_i (status_msgfifo_empty),
.reg2hw_intr_enable_q_i (reg2hw.intr_enable.fifo_empty.q),
.reg2hw_intr_test_q_i (reg2hw.intr_test.fifo_empty.q),
.reg2hw_intr_test_qe_i (reg2hw.intr_test.fifo_empty.qe),
Expand Down
9 changes: 3 additions & 6 deletions hw/ip/kmac/rtl/kmac_reg_top.sv
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ module kmac_reg_top (
logic intr_state_kmac_done_qs;
logic intr_state_kmac_done_wd;
logic intr_state_fifo_empty_qs;
logic intr_state_fifo_empty_wd;
logic intr_state_kmac_err_qs;
logic intr_state_kmac_err_wd;
logic intr_enable_we;
Expand Down Expand Up @@ -418,16 +417,16 @@ module kmac_reg_top (
// F[fifo_empty]: 1:1
prim_subreg #(
.DW (1),
.SwAccess(prim_subreg_pkg::SwAccessW1C),
.SwAccess(prim_subreg_pkg::SwAccessRO),
.RESVAL (1'h0),
.Mubi (1'b0)
) u_intr_state_fifo_empty (
.clk_i (clk_i),
.rst_ni (rst_ni),

// from register interface
.we (intr_state_we),
.wd (intr_state_fifo_empty_wd),
.we (1'b0),
.wd ('0),

// from internal hardware
.de (hw2reg.intr_state.fifo_empty.de),
Expand Down Expand Up @@ -2846,8 +2845,6 @@ module kmac_reg_top (

assign intr_state_kmac_done_wd = reg_wdata[0];

assign intr_state_fifo_empty_wd = reg_wdata[1];

assign intr_state_kmac_err_wd = reg_wdata[2];
assign intr_enable_we = addr_hit[1] & reg_we & !reg_error;

Expand Down
2 changes: 1 addition & 1 deletion sw/device/lib/dif/autogen/dif_kmac_autogen.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static bool kmac_get_irq_bit_index(dif_kmac_irq_t irq,

static dif_irq_type_t irq_types[] = {
kDifIrqTypeEvent,
kDifIrqTypeEvent,
kDifIrqTypeStatus,
kDifIrqTypeEvent,
};

Expand Down
5 changes: 4 additions & 1 deletion sw/device/lib/dif/autogen/dif_kmac_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ typedef enum dif_kmac_irq {
*/
kDifKmacIrqKmacDone = 0,
/**
* Message FIFO empty condition
* The message FIFO has run empty. This interrupt is not raised or de-asserts
* if any of the following conditions are met: 1) The KMAC block is exercised
* by a hardware application interface. 2) The KMAC block is completely idle,
* e.g., after finishing an operation.
*/
kDifKmacIrqFifoEmpty = 1,
/**
Expand Down

0 comments on commit 6645b60

Please sign in to comment.