mirror of
https://github.com/YosysHQ/yosys
synced 2025-11-25 15:09:34 +00:00
The existing read port assignment algorithm uses Cartesian product expansion, which has O(options^N) complexity. For memories with many read ports (e.g., 64 parallel reads), this causes exponential memory usage (60GB+) and timeouts. This commit adds a beam search algorithm that activates for >8 read ports. It maintains only the top K (default 16) configurations at each step, reducing complexity to O(N * options * K). Tested with: - 64 read ports: completes in ~1s vs OOM - 32 read ports: completes in ~1s vs timeout - Maintains existing behavior for ≤8 ports 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
27 lines
735 B
Verilog
27 lines
735 B
Verilog
// Test case for beam search optimization in memory_libmap
|
|
// This memory with 32 parallel read ports would cause exponential
|
|
// blowup (O(4^32) = 10^19 configurations) without beam search pruning
|
|
|
|
module memlib_beam_search (
|
|
input wire clk,
|
|
input wire we,
|
|
input wire [9:0] wr_addr,
|
|
input wire [7:0] wr_data,
|
|
input wire [9:0] base_addr,
|
|
output reg [255:0] parallel_out // 32 x 8 = 256 bits
|
|
);
|
|
|
|
reg [7:0] mem [0:1023];
|
|
integer i;
|
|
|
|
always @(posedge clk) begin
|
|
if (we)
|
|
mem[wr_addr] <= wr_data;
|
|
|
|
// 32 parallel reads - triggers beam search
|
|
for (i = 0; i < 32; i = i + 1) begin
|
|
parallel_out[i*8 +: 8] <= mem[base_addr + i];
|
|
end
|
|
end
|
|
|
|
endmodule
|