Files
Mini-Nav/hw/rtl/cam_core.sv
SikongJueluo f5daaa2667 refactor(cam): extract match engine into separate module and centralize parameters
- Split cam_core into pure memory (cam_core.sv) and match engine (match_engine.sv)
- Add cam_params.svh with centralized parameter definitions (NUM_ROWS, HASH_BITS, LANES, etc.)
- Update cam_top.sv to use shared parameters and compose match_engine
- Update Makefile to include new match_engine module and correct Verilator define syntax
2026-05-02 23:28:32 +08:00

33 lines
981 B
Systemverilog

`timescale 1ns / 1ps
`include "cam_params.svh"
module cam_core (
input logic clk,
input logic rst_n,
input logic wr_en,
input logic [(`ROW_BITS)-1:0] wr_row,
input logic [(`HASH_BITS)-1:0] wr_hash,
input logic [(`LANES)*(`ROW_BITS)-1:0] rd_addr_lanes_flat,
output logic [(`LANES)*(`HASH_BITS)-1:0] rd_hash_lanes_flat
);
logic [(`HASH_BITS)-1:0] cam_mem[0:(`NUM_ROWS)-1];
// Memory write path.
always_ff @(posedge clk) begin
if (wr_en) begin
cam_mem[wr_row] <= wr_hash;
end
end
// Per-lane combinational read.
genvar l;
generate
for (l = 0; l < `LANES; l++) begin : rd_lane
assign rd_hash_lanes_flat[l*`HASH_BITS +: `HASH_BITS] =
cam_mem[rd_addr_lanes_flat[l*`ROW_BITS +: `ROW_BITS]];
end
endgenerate
endmodule