Files
Mini-Nav/hw/rtl/cam_params.svh
SikongJueluo e4cbb5e30d feat(hw/rtl): implement full Top-K CAM search pipeline with serial result output
- add TOPK_K, FIFO_DEPTH, RESULT_SERIAL parameters to cam_params
- add candidate_fifo: synchronous ready/valid FIFO for (row, score) candidates
- add topk_tracker: tracks top-K candidates with clear/ready handshake
- add result_serializer: serializes packed Top-K array into rank-ordered stream
- refactor match_engine_pipeline from 4-state to 8-state Top-K pipeline
- extend cam_top with serial Top-K interface (result_rank/row/score/last)
- add backward-compatible top1_index/top1_score aliases from rank-0 beat
- add comprehensive tests for all new modules
2026-05-19 22:43:21 +08:00

73 lines
2.3 KiB
Systemverilog

//==============================================================================
// CAM Parameter Definitions
//==============================================================================
// This file defines shared compile-time parameters for the Content-Addressable
// Memory (CAM) subsystem. All `define macros use `ifndef guards to allow
// command-line override via +define+.
//
// Macros:
// NUM_ROWS — Number of rows in the CAM array
// HASH_BITS — Width of the hash value in bits
// LANES — Number of parallel comparison lanes
// TOPK_K — Number of best matches retained per query
// FIFO_DEPTH — Candidate FIFO entries between match engine and tracker
// RESULT_SERIAL — Enables rank-ordered serial result output
// ROW_BITS — Bits needed to index NUM_ROWS rows ($clog2(NUM_ROWS))
// SCORE_BITS — Bits needed to represent HASH_BITS-bit scores ($clog2(HASH_BITS+1))
//
// The TIE_BREAK_SENTINEL localparam is a bitmask with all bits set to 1'b1,
// used as the initial / tie-breaking value in the row-priority arbiter.
//==============================================================================
`ifndef CAM_PARAMS_SVH
`define CAM_PARAMS_SVH
// Number of CAM rows.
`ifndef NUM_ROWS
`define NUM_ROWS 4096
`endif
// Width of the hash value stored per row.
`ifndef HASH_BITS
`define HASH_BITS 512
`endif
// Number of parallel comparison lanes.
`ifndef LANES
`define LANES 8
`endif
// Number of Top-K results to retain and serialize.
`ifndef TOPK_K
`define TOPK_K 4
`endif
// Candidate FIFO depth between score generation and Top-K tracking.
`ifndef FIFO_DEPTH
`define FIFO_DEPTH 16
`endif
// Result interface mode. First implementation uses serial Top-K output.
`ifndef RESULT_SERIAL
`define RESULT_SERIAL 1
`endif
// Bits required to represent a row index.
`ifndef ROW_BITS
`define ROW_BITS $clog2(`NUM_ROWS)
`endif
// Bits required to represent a full-score count.
`ifndef SCORE_BITS
`define SCORE_BITS $clog2(`HASH_BITS + 1)
`endif
// Tie-break sentinel: all ones in the row-index width.
// Used as the initial best-index value before any match is found.
localparam logic [(`ROW_BITS)-1:0] TIE_BREAK_SENTINEL = {(`ROW_BITS){1'b1}};
// First banked-pipeline implementation requires NUM_ROWS divisible by LANES.
// Tail lanes and unaligned read batches are intentionally out of scope.
`endif // CAM_PARAMS_SVH