pub struct SboxPair { /* private fields */ }Expand description
Two registered S-box lookups per cycle from one dual-port memory.
§Why pairs
A block RAM tile (BRAM18) and an UltraRAM each have two ports, but RHDL’s
SyncBRAM uses only one. Built from SyncBRAMs, every S-box placed in
RAM cost a whole BRAM18 or URAM, so four slices could not afford to move
their leftover S-boxes (rounds 0–2 and 9 of a T-table lane) out of LUTs:
build v5 still spent 17,040 LUT-RAM per slice on them. A pair serves two
S-boxes of the same round from one memory, halving the RAM per box, the
same step DualTableRom took for T-tables.
┌──────── one memory (style: LUT, block or ultra) ────────┐
a ──────▶ │ port A: o_a <= S[a] (UltraRAM: or write the loader's │ ──▶ o.a
│ entry while loading) │
b ──────▶ │ port B: o_b <= S[b] │ ──▶ o.b
└──────────────────────────────────────────────────────────┘§Timing
Addresses in cycle t give their bytes in cycle t + 1 on both ports,
like a SyncBRAM ROM. Reset is ignored: ownership lives in the lane’s
valid bits, and an UltraRAM pair’s lane reports “not ready” until its
loader has written all 256 entries. While loading, port A does the write
(its read output is meaningless then), so the memory never needs more
than the two ports UltraRAM has.
Like DualTableRom this is a hand-specified RHDL primitive: a Rust
simulation model plus the Verilog printed by SboxPair::hdl, checked
against each other in Icarus by the tests below.
Implementations§
Trait Implementations§
Source§impl Synchronous for SboxPair
Behaviour (simulation) and structure (Verilog) of the pair.
impl Synchronous for SboxPair
Behaviour (simulation) and structure (Verilog) of the pair.
Source§fn init(&self) -> Self::S
fn init(&self) -> Self::S
A ROM starts holding the S-box; an UltraRAM starts empty (zeros here, unknown on the chip). Outputs start as “don’t care”.
Source§fn sim(
&self,
clock_reset: ClockReset,
input: Self::I,
state: &mut Self::S,
) -> Self::O
fn sim( &self, clock_reset: ClockReset, input: Self::I, state: &mut Self::S, ) -> Self::O
One half-clock step: read both addresses while the clock is low, capture (and, for UltraRAM, write) on the rising edge.
Source§fn descriptor(
&self,
scoped_name: ScopedName,
) -> Result<Descriptor<SyncKind>, RHDLError>
fn descriptor( &self, scoped_name: ScopedName, ) -> Result<Descriptor<SyncKind>, RHDLError>
Register the Verilog below with RHDL as a primitive.
Auto Trait Implementations§
impl Freeze for SboxPair
impl RefUnwindSafe for SboxPair
impl Send for SboxPair
impl Sync for SboxPair
impl Unpin for SboxPair
impl UnsafeUnpin for SboxPair
impl UnwindSafe for SboxPair
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more