|
@@ -0,0 +1,347 @@
|
|
|
|
|
+`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 reg [7:0] rd_data
|
|
|
|
|
+);
|
|
|
|
|
+ (* ram_style = "block", syn_ramstyle = "block_ram" *) 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_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
|