| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- `timescale 1ns/1ps
- // Isolated, synthesisable architecture candidates for the eight remaining
- // 6400 resource A/B decisions. These modules are not part of a product source
- // closure. They intentionally expose the same observable transaction for
- // each pair so simulation/formal checks can precede resource comparison.
- module ab_fsm_binary (
- input wire clk, input wire rst_n, input wire advance, input wire recover,
- output reg [2:0] state_code
- );
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) state_code <= 3'd0;
- else if (recover) state_code <= 3'd0;
- else if (advance) begin
- case (state_code)
- 3'd0: state_code <= 3'd1;
- 3'd1: state_code <= 3'd2;
- 3'd2: state_code <= 3'd3;
- 3'd3: state_code <= 3'd4;
- 3'd4: state_code <= 3'd5;
- 3'd5: state_code <= 3'd6;
- default: state_code <= 3'd0;
- endcase
- end
- end
- endmodule
- module ab_fsm_onehot (
- input wire clk, input wire rst_n, input wire advance, input wire recover,
- output reg [2:0] state_code, output wire [6:0] raw_state
- );
- (* fsm_encoding = "one-hot" *) reg [6:0] state;
- assign raw_state = state;
- always @* begin
- case (state)
- 7'b0000001: state_code = 3'd0;
- 7'b0000010: state_code = 3'd1;
- 7'b0000100: state_code = 3'd2;
- 7'b0001000: state_code = 3'd3;
- 7'b0010000: state_code = 3'd4;
- 7'b0100000: state_code = 3'd5;
- 7'b1000000: state_code = 3'd6;
- default: state_code = 3'd0;
- endcase
- end
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) state <= 7'b0000001;
- else if (recover) state <= 7'b0000001;
- else if (advance) begin
- case (state)
- 7'b0000001: state <= 7'b0000010;
- 7'b0000010: state <= 7'b0000100;
- 7'b0000100: state <= 7'b0001000;
- 7'b0001000: state <= 7'b0010000;
- 7'b0010000: state <= 7'b0100000;
- 7'b0100000: state <= 7'b1000000;
- default: state <= 7'b0000001;
- endcase
- end
- end
- endmodule
- // Dedicated serializers preserve simultaneous Host response and BMC poll
- // progress. The shared candidate is smaller but intentionally exposes its
- // single-owner limitation so the concurrency test can reject it on function.
- module ab_bmc_tx_dedicated (
- input wire clk, input wire rst_n,
- input wire host_start, input wire [7:0] host_data,
- input wire bmc_start, input wire [7:0] bmc_data,
- output wire host_bit, output wire bmc_bit,
- output wire host_busy, output wire bmc_busy
- );
- reg [7:0] host_shift;
- reg [7:0] bmc_shift;
- reg [3:0] host_left;
- reg [3:0] bmc_left;
- assign host_bit = host_left == 0 ? 1'b1 : host_shift[0];
- assign bmc_bit = bmc_left == 0 ? 1'b1 : bmc_shift[0];
- assign host_busy = host_left != 0;
- assign bmc_busy = bmc_left != 0;
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) begin
- host_shift <= 0; bmc_shift <= 0; host_left <= 0; bmc_left <= 0;
- end else begin
- if (host_start && host_left == 0) begin host_shift <= host_data; host_left <= 8; end
- else if (host_left != 0) begin host_shift <= {1'b1, host_shift[7:1]}; host_left <= host_left - 1'b1; end
- if (bmc_start && bmc_left == 0) begin bmc_shift <= bmc_data; bmc_left <= 8; end
- else if (bmc_left != 0) begin bmc_shift <= {1'b1, bmc_shift[7:1]}; bmc_left <= bmc_left - 1'b1; end
- end
- end
- endmodule
- module ab_bmc_tx_shared (
- input wire clk, input wire rst_n,
- input wire host_start, input wire [7:0] host_data,
- input wire bmc_start, input wire [7:0] bmc_data,
- output wire host_bit, output wire bmc_bit,
- output wire host_busy, output wire bmc_busy
- );
- reg [7:0] shift;
- reg [3:0] left;
- reg owner_bmc;
- assign host_bit = (left != 0 && !owner_bmc) ? shift[0] : 1'b1;
- assign bmc_bit = (left != 0 && owner_bmc) ? shift[0] : 1'b1;
- assign host_busy = left != 0 && !owner_bmc;
- assign bmc_busy = left != 0 && owner_bmc;
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) begin shift <= 0; left <= 0; owner_bmc <= 0; end
- else if (left != 0) begin shift <= {1'b1, shift[7:1]}; left <= left - 1'b1; end
- else if (host_start) begin shift <= host_data; left <= 8; owner_bmc <= 0; end
- else if (bmc_start) begin shift <= bmc_data; left <= 8; owner_bmc <= 1; end
- end
- endmodule
- module ab_store_ff (
- input wire clk, input wire wr_en, input wire [7:0] wr_addr, input wire [7:0] wr_data,
- input wire [7:0] rd_addr, output reg [7:0] rd_data
- );
- (* ram_style = "registers", syn_ramstyle = "registers" *) reg [7:0] mem [0:255];
- always @(posedge clk) begin
- if (wr_en) mem[wr_addr] <= wr_data;
- rd_data <= mem[rd_addr];
- end
- endmodule
- module ab_store_eram (
- input wire clk, input wire wr_en, input wire [7:0] wr_addr, input wire [7:0] wr_data,
- input wire [7:0] rd_addr, output wire [7:0] rd_data
- );
- `ifdef PROD2U_TD_VENDOR_RAM
- wire [7:0] port_a_data;
- EF2_LOGIC_BRAM #(
- .DATA_WIDTH_A(8), .DATA_WIDTH_B(8),
- .ADDR_WIDTH_A(8), .ADDR_WIDTH_B(8),
- .DATA_DEPTH_A(256), .DATA_DEPTH_B(256),
- .BYTE_ENABLE(0), .BYTE_A(1), .BYTE_B(1),
- .MODE("DP"), .REGMODE_A("NOREG"), .REGMODE_B("NOREG"),
- .WRITEMODE_A("NORMAL"), .WRITEMODE_B("NORMAL"),
- .RESETMODE("ASYNC"), .IMPLEMENT("9K")
- ) u_ram (
- .dia(wr_data), .addra(wr_addr), .cea(1'b1), .ocea(1'b1),
- .clka(clk), .wea(wr_en), .rsta(1'b0), .bea(1'b1),
- .dib(8'd0), .addrb(rd_addr), .ceb(1'b1), .oceb(1'b1),
- .clkb(clk), .web(1'b0), .rstb(1'b0), .beb(1'b1),
- .doa(port_a_data), .dob(rd_data)
- );
- `else
- reg [7:0] mem [0:255];
- reg [7:0] rd_data_reg;
- assign rd_data = rd_data_reg;
- always @(posedge clk) begin
- if (wr_en) mem[wr_addr] <= wr_data;
- rd_data_reg <= mem[rd_addr];
- end
- `endif
- endmodule
- module ab_pi_positional #(
- parameter signed [15:0] KP = 16'sd3,
- parameter signed [15:0] KI = 16'sd1
- ) (
- input wire clk, input wire rst_n, input wire sample,
- input wire signed [15:0] error, output reg signed [31:0] control,
- output wire signed [31:0] integral_state
- );
- reg signed [31:0] integral;
- assign integral_state = integral;
- wire signed [31:0] p_term = KP * error;
- wire signed [31:0] i_term = KI * error;
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) begin integral <= 0; control <= 0; end
- else if (sample) begin
- integral <= integral + i_term;
- control <= p_term + integral + i_term;
- end
- end
- endmodule
- module ab_pi_incremental #(
- parameter signed [15:0] KP = 16'sd3,
- parameter signed [15:0] KI = 16'sd1
- ) (
- input wire clk, input wire rst_n, input wire sample,
- input wire signed [15:0] error, output reg signed [31:0] control,
- output wire signed [15:0] previous_error_state
- );
- reg signed [15:0] previous_error;
- assign previous_error_state = previous_error;
- wire signed [16:0] delta_error = error - previous_error;
- wire signed [32:0] p_delta = KP * delta_error;
- wire signed [31:0] p_delta_narrow = p_delta[31:0];
- wire signed [31:0] i_delta = KI * error;
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) begin previous_error <= 0; control <= 0; end
- else if (sample) begin
- control <= control + p_delta_narrow + i_delta;
- previous_error <= error;
- end
- end
- endmodule
- module ab_safety_parallel #(
- parameter [7:0] LIMIT = 8'd77
- ) (
- input wire clk, input wire rst_n,
- input wire wr_en, input wire [4:0] wr_index, input wire [7:0] wr_temperature,
- input wire start, output reg busy, output reg done, output reg [23:0] mask
- );
- reg [7:0] temperatures [0:23];
- integer i;
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) begin busy <= 0; done <= 0; mask <= 0; end
- else begin
- done <= 0;
- if (wr_en) temperatures[wr_index] <= wr_temperature;
- if (start) begin
- busy <= 1;
- for (i = 0; i < 24; i = i + 1) mask[i] <= temperatures[i] >= LIMIT;
- end else if (busy) begin busy <= 0; done <= 1; end
- end
- end
- endmodule
- module ab_safety_sequential #(
- parameter [7:0] LIMIT = 8'd77
- ) (
- input wire clk, input wire rst_n,
- input wire wr_en, input wire [4:0] wr_index, input wire [7:0] wr_temperature,
- input wire start, output reg busy, output reg done, output reg [23:0] mask
- );
- reg [7:0] temperatures [0:23];
- reg [4:0] index;
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) begin busy <= 0; done <= 0; mask <= 0; index <= 0; end
- else begin
- done <= 0;
- if (wr_en) temperatures[wr_index] <= wr_temperature;
- if (start && !busy) begin busy <= 1; index <= 0; end
- else if (busy) begin
- mask[index] <= temperatures[index] >= LIMIT;
- if (index == 23) begin busy <= 0; done <= 1; end
- else index <= index + 1'b1;
- end
- end
- end
- endmodule
- module ab_commit_copy (
- input wire clk, input wire rst_n,
- input wire wr_en, input wire [4:0] wr_index, input wire [15:0] wr_data,
- input wire commit, input wire [4:0] rd_index, output wire [15:0] rd_data
- );
- reg [15:0] staging [0:23];
- reg [15:0] active [0:23];
- integer i;
- assign rd_data = active[rd_index];
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) begin end
- else begin
- if (wr_en) staging[wr_index] <= wr_data;
- if (commit) for (i = 0; i < 24; i = i + 1) active[i] <= staging[i];
- end
- end
- endmodule
- module ab_commit_bank (
- input wire clk, input wire rst_n,
- input wire wr_en, input wire [4:0] wr_index, input wire [15:0] wr_data,
- input wire commit, input wire [4:0] rd_index, output wire [15:0] rd_data
- );
- reg [15:0] bank0 [0:23];
- reg [15:0] bank1 [0:23];
- reg active_bank;
- assign rd_data = active_bank ? bank1[rd_index] : bank0[rd_index];
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) active_bank <= 0;
- else begin
- if (wr_en) begin
- if (active_bank) bank0[wr_index] <= wr_data;
- else bank1[wr_index] <= wr_data;
- end
- if (commit) active_bank <= ~active_bank;
- end
- end
- endmodule
- module ab_crc_independent (
- input wire clk, input wire rst_n, input wire clear,
- input wire rx_valid, input wire [7:0] rx_data,
- input wire tx_valid, input wire [7:0] tx_data,
- output reg [15:0] rx_crc, output reg [15:0] tx_crc
- );
- function [15:0] next_crc;
- input [15:0] current; input [7:0] data;
- integer i; reg [15:0] value;
- begin
- value = current ^ {data, 8'h00};
- for (i = 0; i < 8; i = i + 1)
- value = value[15] ? (value << 1) ^ 16'h1021 : value << 1;
- next_crc = value;
- end
- endfunction
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) begin rx_crc <= 16'hffff; tx_crc <= 16'hffff; end
- else if (clear) begin rx_crc <= 16'hffff; tx_crc <= 16'hffff; end
- else begin
- if (rx_valid) rx_crc <= next_crc(rx_crc, rx_data);
- if (tx_valid) tx_crc <= next_crc(tx_crc, tx_data);
- end
- end
- endmodule
- module ab_crc_shared (
- input wire clk, input wire rst_n, input wire clear,
- input wire rx_valid, input wire [7:0] rx_data,
- input wire tx_valid, input wire [7:0] tx_data,
- output reg [15:0] rx_crc, output reg [15:0] tx_crc
- );
- function [15:0] next_crc;
- input [15:0] current; input [7:0] data;
- integer i; reg [15:0] value;
- begin
- value = current ^ {data, 8'h00};
- for (i = 0; i < 8; i = i + 1)
- value = value[15] ? (value << 1) ^ 16'h1021 : value << 1;
- next_crc = value;
- end
- endfunction
- wire select_rx = rx_valid;
- wire [15:0] selected_crc = select_rx ? rx_crc : tx_crc;
- wire [7:0] selected_data = select_rx ? rx_data : tx_data;
- wire [15:0] updated_crc = next_crc(selected_crc, selected_data);
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) begin rx_crc <= 16'hffff; tx_crc <= 16'hffff; end
- else if (clear) begin rx_crc <= 16'hffff; tx_crc <= 16'hffff; end
- else if (rx_valid) rx_crc <= updated_crc;
- else if (tx_valid) tx_crc <= updated_crc;
- end
- endmodule
- module ab_snapshot_copy (
- input wire clk, input wire rst_n, input wire capture, input wire [7:0] seed,
- input wire [7:0] rd_addr, output wire [7:0] rd_data
- );
- reg [7:0] snapshot [0:192];
- integer i;
- assign rd_data = snapshot[rd_addr];
- /* verilator lint_off BLKLOOPINIT */
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) begin end
- else if (capture)
- for (i = 0; i < 193; i = i + 1) snapshot[i] <= i[7:0] ^ seed;
- end
- /* verilator lint_on BLKLOOPINIT */
- endmodule
- module ab_snapshot_stream (
- input wire clk, input wire rst_n, input wire capture, input wire [7:0] seed,
- input wire [7:0] rd_addr, output wire [7:0] rd_data
- );
- reg [7:0] locked_seed;
- assign rd_data = rd_addr ^ locked_seed;
- always @(posedge clk or negedge rst_n) begin
- if (!rst_n) locked_seed <= 0;
- else if (capture) locked_seed <= seed;
- end
- endmodule
|