Skip to main content

u280_shell_rhdl/
reader.rs

1//! One-outstanding-transaction HBM0 reader state and validation helpers.
2
3use rhdl::prelude::*;
4
5use crate::axi::AXI_RESP_OKAY;
6
7/// HBM0 reader state.
8#[derive(Clone, Copy, Debug, Default, Digital, Eq, PartialEq)]
9pub enum ReaderState {
10    /// No request is owned.
11    #[default]
12    Idle,
13    /// `ARVALID` is asserted and cannot be cancelled.
14    Address,
15    /// The single expected response is being drained.
16    Response,
17    /// A checked line is retained until signer admission.
18    Hold,
19}
20
21/// Resetless line payload retained behind a resettable valid bit.
22#[derive(Clone, Copy, Debug, Digital, Eq, PartialEq)]
23pub struct InputJob {
24    /// Private seed in lanes 0 through 31 and message digest in lanes 32 through 63.
25    pub data: [b8; 64],
26    /// Implicit sequential job identity.
27    pub job_id: b32,
28}
29
30impl Default for InputJob {
31    fn default() -> Self {
32        Self {
33            data: [b8(0); 64],
34            job_id: b32(0),
35        }
36    }
37}
38
39/// Derive the fixed one-line input address without a multiplier.
40#[kernel]
41pub fn input_job_address_kernel(base: b64, job_id: b32) -> b64 {
42    let wide_job: b64 = job_id.resize();
43    base + (wide_job << 6)
44}
45
46/// Accept only the exact one-line, ID-zero, nonexclusive response contract.
47#[kernel]
48pub fn input_response_is_canonical_kernel(rid: b1, rresp: b2, rlast: bool) -> bool {
49    rid == b1(0) && rresp == AXI_RESP_OKAY && rlast
50}