Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 240 additions & 0 deletions AGENTS.md

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ SLAC Ultimate RTL Framework

<!--- ########################################################################################### -->

# Repository Map

- [Agent guidance](AGENTS.md): project layout, coding conventions, and verification notes for contributors and coding agents.
- [AXI](axi/README.md): AXI-Lite, AXI4, AXI Stream, DMA, bridges, and simulation-link RTL.
- [Base](base/README.md): foundational packages, CDC, FIFO, RAM, reset, delay, CRC, and generic RTL helpers.
- [Devices](devices/README.md): vendor and component-specific RTL support.
- [DSP](dsp/README.md): generic and Xilinx-specific DSP support.
- [Ethernet](ethernet/README.md): MAC, raw Ethernet, IPv4, UDP, RoCEv2, and high-speed Ethernet cores.
- [Protocols](protocols/README.md): PGP, SSI, SRP, RSSI, CoaXPress, JESD204B, peripheral buses, and related protocol cores.
- [Xilinx](xilinx/README.md): Xilinx-family wrappers, primitive integrations, and XVC UDP support.
- [Python](python/README.md): PyRogue package layout under `python/surf`.
- [Tests](tests/README.md): cocotb regression layout, methodology, helpers, and simulator conventions.

<!--- ########################################################################################### -->

# Before you clone the GIT repository

Setup for large filesystems on github. `git-lfs` used for all binary files (example: .dcp)
Expand Down
14 changes: 14 additions & 0 deletions axi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# AXI

This tree contains reusable AXI-family RTL and wrappers. Top-level `axi/ruckus.tcl` loads the submodules used by SURF builds.

## Layout

- `axi-lite/`: AXI-Lite records, crossbars, endpoints, masters, slaves, monitors, and IP-integrator adapters.
- `axi-stream/`: AXI Stream records, FIFOs, muxes, monitors, protocol adapters, and stream wrappers.
- `axi4/`: full AXI4 support blocks and adapters.
- `bridge/`: bridges between AXI-family buses and SURF protocol records.
- `dma/`: DMA register, descriptor, FIFO, and stream integration cores.
- `simlink/`: simulator-link support and C/C++/VHDL pieces used by simulation flows.

Use existing package record types before adding flattened ports. Put durable adapter entities in `ip_integrator/` or `wrappers/`, and keep executable cocotb tests under `tests/axi/`.
2 changes: 1 addition & 1 deletion axi/axi-lite/rtl/AxiLitePkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ package AxiLitePkg is
connectivity => X"FFFF"));

-------------------------------------------------------------------------------------------------
-- Initilize masters with uppder address bits already set to configuration base address
-- Initialize masters with upper address bits already set to configuration base address
-------------------------------------------------------------------------------------------------
function axiWriteMasterInit (constant config : AxiLiteCrossbarMasterConfigArray) return AxiLiteWriteMasterArray;
function axiWriteMasterInit (constant config : AxiLiteCrossbarMasterConfigType) return AxiLiteWriteMasterType;
Expand Down
2 changes: 1 addition & 1 deletion axi/axi-lite/rtl/AxiLiteSequencerRam.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ begin
end if;
----------------------------------------------------------------------
when SEQ_DONE_S =>
-- Set all bits to 1 so SW knowns it done
-- Set all bits to 1 so SW knows it done
v.addr := (others => '0');
v.din := (others => '1');
v.wstrb := (others => '1');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ entity AxiStreamFifoV2IpIntegrator is

-- Internal FIFO width select, "WIDE", "NARROW" or "CUSTOM"
-- WIDE uses wider of slave / master. NARROW uses narrower.
-- CUSOTM uses passed FIFO_DATA_WIDTH_G
-- CUSTOM uses passed FIFO_DATA_WIDTH_G
INT_WIDTH_SELECT : string := "WIDE";
INT_DATA_WIDTH : natural range 1 to 16 := 16;

Expand Down
2 changes: 1 addition & 1 deletion axi/axi-stream/rtl/AxiStreamBatchingFifo.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ begin
------- END MAIN DATA FIFO -------
----------------------------------

-- These signals are not responsible for hanshakes and can
-- These signals are not responsible for handshakes and can
-- just be forwarded
combAxisMaster.tData <= axisMasterFifo.tData;
combAxisMaster.tStrb <= axisMasterFifo.tStrb;
Expand Down
2 changes: 1 addition & 1 deletion axi/axi-stream/rtl/AxiStreamCompact.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ begin -- architecture rtl
-- Reset full flags
v.fullBus := false;

-- get tKeet boundaries
-- get tKeep boundaries
tKeepMin := getTKeepMin(sAxisMaster.tKeep, SLAVE_AXI_CONFIG_G);
tKeepWidth := getTKeep(sAxisMaster.tKeep, SLAVE_AXI_CONFIG_G);
tDataWidth := to_integer(shift_left(to_unsigned(tKeepWidth, SLV_BYTES_C), 3));
Expand Down
2 changes: 1 addition & 1 deletion axi/axi-stream/rtl/AxiStreamConcat.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-- Description: Firmware module that AxiStreamConcat multiple AXI stream frames
-- together. It will ignore TKEEP and the format of the frame.
-------------------------------------------------------------------------------
-- Note: This module is similiar to "AxiStreamBatcher.vhd" but does NOT
-- Note: This module is similar to "AxiStreamBatcher.vhd" but does NOT
-- have the following features
-- 1) No super header
-- 2) No tail footer
Expand Down
6 changes: 3 additions & 3 deletions axi/axi-stream/rtl/AxiStreamFifoV2.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ entity AxiStreamFifoV2 is

-- Internal FIFO width select, "WIDE", "NARROW" or "CUSTOM"
-- WIDE uses wider of slave / master. NARROW uses narrower.
-- CUSOTM uses passed FIFO_DATA_WIDTH_G
-- CUSTOM uses passed FIFO_DATA_WIDTH_G
INT_WIDTH_SELECT_G : string := "WIDE";
INT_DATA_WIDTH_G : natural range 1 to AXI_STREAM_MAX_TKEEP_WIDTH_C := 16;

Expand Down Expand Up @@ -176,7 +176,7 @@ architecture rtl of AxiStreamFifoV2 is

begin

-- Cant use tkeep_fixed on master side when resizing or if not on slave side
-- Can't use tkeep_fixed on master side when resizing or if not on slave side
assert (not (MASTER_AXI_CONFIG_G.TKEEP_MODE_C = TKEEP_FIXED_C and
SLAVE_AXI_CONFIG_G.TKEEP_MODE_C /= TKEEP_FIXED_C))
report "AxiStreamFifoV2: Can't have TKEEP_MODE = TKEEP_FIXED on master side if not on slave side"
Expand Down Expand Up @@ -225,7 +225,7 @@ begin
-- Is ready enabled?
fifoReady <= (not fifoAFull) when SLAVE_READY_EN_G else '1';

-- Output a copy of FIFO WR count incase application needs more than one threshold
-- Output a copy of FIFO WR count in case application needs more than one threshold
fifoWrCnt <= fifoWrCount;

-- Map bits
Expand Down
2 changes: 1 addition & 1 deletion axi/axi-stream/rtl/AxiStreamFlush.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- Company : SLAC National Accelerator Laboratory
-------------------------------------------------------------------------------
-- Description:
-- Block to flush AXI Stream frames, being mindfull of frame boundaries.
-- Block to flush AXI Stream frames, being mindful of frame boundaries.
-- This module is designed to feed into an AxiStreamFifo using pause to determine
-- backpressure situations.
-------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion axi/axi-stream/rtl/AxiStreamGearbox.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ begin
assert (SLV_BYTES_C <= MST_BYTES_C or READY_EN_G = true)
report "READY_EN_G must be true if slave width is great than master" severity failure;

-- Cant use tkeep_fixed on master side when resizing or if not on slave side
-- Can't use tkeep_fixed on master side when resizing or if not on slave side
assert (not (MASTER_AXI_CONFIG_G.TKEEP_MODE_C = TKEEP_FIXED_C and
SLAVE_AXI_CONFIG_G.TKEEP_MODE_C /= TKEEP_FIXED_C))
report "AxiStreamGearbox: Can't have TKEEP_MODE = TKEEP_FIXED on master side if not on slave side"
Expand Down
4 changes: 2 additions & 2 deletions axi/axi-stream/rtl/AxiStreamMux.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ entity AxiStreamMux is
-- Assign a priority for each input stream index.
-- Higher priority streams will be selected over those with lower priority of both are active.
-- Format is (index => priority)
-- Leave unchanged for equal priority round-robbin
-- Leave unchanged for equal priority round-robin
PRIORITY_G : IntegerArray := (0 => 0);
-- In INDEXED mode, assign slave index to TDEST at this bit offset
TDEST_LOW_G : integer range 0 to 7 := 0;
Expand Down Expand Up @@ -179,7 +179,7 @@ begin
end process;

-- When in INDEXED priority mode, tvalid on a given slave side index disables selection
-- for all channels with higer index
-- for all channels with higher index
PRIORITY_CONTROL : process (disableSel, sAxisMasters) is
variable tmp : slv(NUM_SLAVES_G-1 downto 0);
begin
Expand Down
2 changes: 1 addition & 1 deletion axi/axi-stream/rtl/AxiStreamResize.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ begin
assert (SLV_BYTES_C <= MST_BYTES_C or READY_EN_G = true)
report "READY_EN_G must be true if slave width is great than master" severity failure;

-- Cant use tkeep_fixed on master side when resizing or if not on slave side
-- Can't use tkeep_fixed on master side when resizing or if not on slave side
assert (not (MASTER_AXI_CONFIG_G.TKEEP_MODE_C = TKEEP_FIXED_C and
SLAVE_AXI_CONFIG_G.TKEEP_MODE_C /= TKEEP_FIXED_C))
report "AxiStreamResize: Can't have TKEEP_MODE = TKEEP_FIXED on master side if not on slave side"
Expand Down
2 changes: 1 addition & 1 deletion axi/axi-stream/tb/AxiStreamBatchingFifoTb.vhd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-------------------------------------------------------------------------------
-- Company : SLAC National Accelerator Laboratory
-------------------------------------------------------------------------------
-- Description: Simulation Testbed for testing the AxiStreamBatchinFifo module
-- Description: Simulation Testbed for testing the AxiStreamBatchingFifo module
-------------------------------------------------------------------------------
-- This file is part of 'SLAC Firmware Standard Library'.
-- It is subject to the license terms in the LICENSE.txt file found in the
Expand Down
2 changes: 1 addition & 1 deletion axi/axi4/rtl/AxiReadEmulate.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ begin
----------------------------------------------------------------------
end case;

-- Combinatoral outputs before reset
-- Combinatorial outputs before reset
intReadSlave <= v.iSlave;

-- Reset
Expand Down
2 changes: 1 addition & 1 deletion axi/axi4/rtl/AxiReadPathMux.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ begin
v.master.arcache := selAddr.arcache;
v.addrState := S_LAST_C;

-- Laster transfer
-- Last transfer
when S_LAST_C =>
if mAxiReadSlave.arready = '1' then
v.master.arvalid := '0';
Expand Down
4 changes: 2 additions & 2 deletions axi/axi4/rtl/AxiWritePathMux.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ begin
v.master.awvalid := '0';
v.dataReq := '0';

-- Aribrate between requesters
-- Arbitrate between requesters
if r.addrValid = '0' then
arbitrate(addrRequests, r.addrAckNum, v.addrAckNum, v.addrValid, v.addrAcks);
end if;
Expand Down Expand Up @@ -216,7 +216,7 @@ begin
end if;
end if;

-- Laster transfer
-- Last transfer
when S_LAST_C =>
if mAxiWriteSlave.wready = '1' then
v.master.wvalid := '0';
Expand Down
2 changes: 1 addition & 1 deletion axi/axi4/tb/AxiRingBufferTb.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ begin
axisSlave => AXI_STREAM_SLAVE_FORCE_C);

--------------------------------------
-- Load waveofrm and check the Results
-- Load waveform and check the Results
--------------------------------------
comb : process (axisMaster, r, rst) is
variable v : RegType;
Expand Down
2 changes: 1 addition & 1 deletion axi/dma/rtl/v1/AxiStreamDmaWrite.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ begin
if (v.wMaster.awvalid = '0') then
-- Set the memory address
v.wMaster.awaddr(AXI_CONFIG_G.ADDR_WIDTH_C-1 downto 0) := r.dmaReq.address(AXI_CONFIG_G.ADDR_WIDTH_C-1 downto 0);
-- Bursts after the FIRST are garunteed to be aligned.
-- Bursts after the FIRST are guaranteed to be aligned.
v.wMaster.awlen := AWLEN_C;
if r.dmaReq.maxSize(31 downto ADDR_LSB_C) < v.wMaster.awlen then
v.wMaster.awlen := resize(r.dmaReq.maxSize(ADDR_LSB_C+AXI_CONFIG_G.LEN_BITS_C-1 downto ADDR_LSB_C)-1, 8);
Expand Down
2 changes: 1 addition & 1 deletion axi/dma/rtl/v2/AxiStreamDmaV2Desc.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ entity AxiStreamDmaV2Desc is
-- Choose between one-clock arbitration for return descriptors or count and check selection
DESC_ARB_G : boolean := true;

-- Choose between infeered or xpm generated descriptor FIFOs
-- Choose between inferred or xpm generated descriptor FIFOs
DESC_SYNTH_MODE_G : string := "inferred";

-- Choose the type of resources for the descriptor FIFOs when DESC_SYNTH_MODE_G="xpm"
Expand Down
14 changes: 14 additions & 0 deletions base/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Base

This tree contains the foundational RTL used by the rest of SURF. Top-level `base/ruckus.tcl` loads each base library area.

## Layout

- `general/`: common packages and generic utilities such as `StdRtlPkg`, arbiters, muxes, reset pipelines, gearboxes, counters, and watchdog/reset helpers.
- `sync/`: clock-domain crossing, synchronizers, reset synchronizers, trigger-rate, status, and frequency measurement helpers.
- `fifo/`: synchronous, asynchronous, muxing, cascade, FWFT, and output-pipeline FIFO blocks.
- `ram/`: inferred and Xilinx RAM implementations.
- `delay/`: fixed, RAM-backed, and FIFO-backed delay blocks.
- `crc/`: CRC packages and implementations.

Most modules use SURF package aliases such as `sl` and `slv`, `_G` generics, `_C` constants, and the local `RegType`/`REG_INIT_C` registered-process style. Reuse these base modules rather than duplicating CDC, FIFO, RAM, reset, or CRC logic in higher-level subsystems.
33 changes: 27 additions & 6 deletions base/delay/rtl/SlvDelayRam.vhd
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
-------------------------------------------------------------------------------
-- Company : SLAC National Accelerator Laboratory
-------------------------------------------------------------------------------
-- Description: Shift Register Delay module for std_logic_vector
-- Uses a counter and single port RAM (distributed, block, ultra)
-- Single port RAM setup in read first mode
-- Counter counts 0...maxCount
-- Optional data out register (DO_REG_G) on the RAM
-- Description: Runtime-configurable delay line for std_logic_vector data.
--
-- delay = maxCount + ite(DO_REG_G, 3, 2)
-- SlvDelayRam stores each accepted din sample in an inferred
-- single-port RAM and reads back the sample located at the
-- current circular address. The RAM is used in read-before-write
-- mode, so the visible output is the sample captured on an
-- earlier visit to the same address. The address counter wraps
-- when it reaches the registered maxCount value, which sets the
-- requested delay depth. The en input freezes the address
-- counter, maxCount register, RAM write, and output update.
--
-- DO_REG_G adds an output register after the RAM read data.
-- With the current implementation, the observable delay is:
--
-- delay = maxCount + ite(DO_REG_G, 3, 2)
--
-- maxCount is sampled while en is asserted and is intended to be
-- programmed during initialization or while the module is held in
-- reset. If maxCount is changed while traffic is flowing, the
-- circular address phase is not automatically realigned. The
-- transition samples are therefore undefined, and shrinking
-- maxCount below the current address can violate the internal
-- counter range in simulation. Software or firmware that changes
-- maxCount at runtime must assert rst afterward and should discard
-- any pre-reset output history before relying on dout again. In
-- practice, allow at least one newly configured delay interval
-- after reset release before treating dout as aligned to the new
-- maxCount setting.
-------------------------------------------------------------------------------
-- This file is part of 'SLAC Firmware Standard Library'.
-- It is subject to the license terms in the LICENSE.txt file found in the
Expand Down
2 changes: 1 addition & 1 deletion base/general/rtl/TextUtilPkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ package body TextUtilPkg is
-- converts an integer into a character
-- for 0 to 9 the obvious mapping is used, higher
-- values are mapped to the characters A-Z
-- (this is usefull for systems with base > 10)
-- (this is useful for systems with base > 10)
-- (adapted from Steve Vogwell's posting in comp.lang.vhdl)
function chr(intValue : integer) return character is
variable c : character;
Expand Down
2 changes: 1 addition & 1 deletion base/ram/xilinx/SinglePortRamPrimitive.vhd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-------------------------------------------------------------------------------
-- Company : SLAC National Accelerator Laboratory
-------------------------------------------------------------------------------
-- Description: Manual instantation of RAM32X1S, RAM64X1S, RAM128X1S,
-- Description: Manual instantiation of RAM32X1S, RAM64X1S, RAM128X1S,
-- RAM256X1S, or RAM512X1S.
-------------------------------------------------------------------------------
-- This file is part of 'SLAC Firmware Standard Library'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,17 @@ begin
axiSlaveWaitTxn(axilEp, axilWriteMaster, axilReadMaster, v.axilWriteSlave, v.axilReadSlave);

-- Up to 8 delay registers
-- Write delay values to IDELAY primatives
-- Write delay values to IDELAY primitives
-- All writes go to same r.delay register,
-- dataDelaySet(i) or frameDelaySet enables the primative write
-- dataDelaySet(i) or frameDelaySet enables the primitive write
for i in 0 to NUM_CHANNELS_G-1 loop
axiSlaveRegister(axilEp, X"00"+toSlv((i*4), 8), 0, v.delay);
axiSlaveRegister(axilEp, X"00"+toSlv((i*4), 8), 5, v.dataDelaySet(i), '1');
end loop;
axiSlaveRegister(axilEp, X"20", 0, v.delay);
axiSlaveRegister(axilEp, X"20", 5, v.frameDelaySet, '1');

-- Override read from r.delay and use curDealy output from delay primative instead
-- Override read from r.delay and use curDelay output from delay primitive instead
for i in 0 to NUM_CHANNELS_G-1 loop
axiSlaveRegisterR(axilEp, X"00"+toSlv((i*4), 8), 0, axilR.curDelayData(i));
end loop;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ entity Ad9249ReadoutGroup is
adcStreamClk : in sl;
adcStreams : out AxiStreamMasterArray(NUM_CHANNELS_G-1 downto 0) :=
(others => axiStreamMasterInit((false, 2, 8, 0, TKEEP_NORMAL_C, 0, TUSER_NORMAL_C)));
-- optional ready to allow evenout samples readout in adcStreamClk
-- optional ready to allow even out samples readout in adcStreamClk
adcReady : in slv(NUM_CHANNELS_G-1 downto 0) := (others => '1'));
end Ad9249ReadoutGroup;

Expand Down Expand Up @@ -251,17 +251,17 @@ begin
axiSlaveWaitTxn(axilEp, axilWriteMaster, axilReadMaster, v.axilWriteSlave, v.axilReadSlave);

-- Up to 8 delay registers
-- Write delay values to IDELAY primatives
-- Write delay values to IDELAY primitives
-- All writes go to same r.delay register,
-- dataDelaySet(i) or frameDelaySet enables the primative write
-- dataDelaySet(i) or frameDelaySet enables the primitive write
for i in 0 to NUM_CHANNELS_G-1 loop
axiSlaveRegister(axilEp, X"00"+toSlv((i*4), 8), 0, v.delay);
axiSlaveRegister(axilEp, X"00"+toSlv((i*4), 8), 9, v.dataDelaySet(i), '1');
end loop;
axiSlaveRegister(axilEp, X"20", 0, v.delay);
axiSlaveRegister(axilEp, X"20", 9, v.frameDelaySet, '1');

-- Override read from r.delay and use curDealy output from delay primative instead
-- Override read from r.delay and use curDelay output from delay primitive instead
for i in 0 to NUM_CHANNELS_G-1 loop
axiSlaveRegisterR(axilEp, X"00"+toSlv((i*4), 8), 0, curDelayData(i));
end loop;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ begin

axiSlaveWaitTxn(axilEp, axilWriteMaster, axilReadMaster, v.axilWriteSlave, v.axilReadSlave);

-- Write delay values to IDELAY primatives
-- Write delay values to IDELAY primitives
-- Overriding gearbox aligner
-- All writes go to same r.delay register,
axiSlaveRegister(axilEp, X"00", 0, v.delay);
Expand Down
Loading
Loading