mirror of
https://github.com/SikongJueluo/Mini-Nav.git
synced 2026-07-12 20:15:31 +08:00
Implement a multi-lane Content Addressable Memory (CAM) that scores rows by XNOR popcount against a query hash and returns the top-1 match. RTL modules: - popcount: parallel group-based population count - argmax_update: iterative best-match tracking with tie-break - cam_core: parameterized scanning engine (NUM_ROWS/HASH_BITS/LANES) with optional SIM_NOISE and SIM_DEBUG ifdef guards - cam_top: thin wrapper exposing cam_core ports Verification: - Python reference model (ref_model.py) for score-level golden comparison - cocotb testbench (test_cam_basic.py) covering write/query/reset and external noise mask scenarios with score debug verification - Noise sweep script (sweep_noise.py) measuring top-1 stability under configurable bit-flip rates - Verilator-oriented Makefile with parameterizable compile options
27 lines
745 B
Systemverilog
27 lines
745 B
Systemverilog
`timescale 1ns/1ps
|
|
|
|
module argmax_update #(
|
|
parameter int ROW_BITS = 9,
|
|
parameter int SCORE_BITS = 10
|
|
) (
|
|
input logic [ROW_BITS-1:0] best_index_i,
|
|
input logic [SCORE_BITS-1:0] best_score_i,
|
|
|
|
input logic [ROW_BITS-1:0] cand_index_i,
|
|
input logic [SCORE_BITS-1:0] cand_score_i,
|
|
|
|
output logic [ROW_BITS-1:0] best_index_o,
|
|
output logic [SCORE_BITS-1:0] best_score_o
|
|
);
|
|
always_comb begin
|
|
best_index_o = best_index_i;
|
|
best_score_o = best_score_i;
|
|
|
|
if ((cand_score_i > best_score_i) ||
|
|
((cand_score_i == best_score_i) && (cand_index_i < best_index_i))) begin
|
|
best_index_o = cand_index_i;
|
|
best_score_o = cand_score_i;
|
|
end
|
|
end
|
|
endmodule
|