|
|
@@ -27,9 +27,10 @@ module mrdimm_snapshot_mux #(
|
|
|
);
|
|
|
reg [`MR_SNAPSHOT_AXIS_OFFSET*8-1:0] header_shadow;
|
|
|
reg [15:0] captured_epoch;
|
|
|
- localparam integer SNAPSHOT_ADDR_WIDTH=$clog2(SNAPSHOT_LENGTH);
|
|
|
- wire [7:0] memory_read_data;
|
|
|
- reg read_in_range;
|
|
|
+ localparam integer SNAPSHOT_ADDR_WIDTH=$clog2(SNAPSHOT_LENGTH/2);
|
|
|
+ wire [15:0] memory_read_data;
|
|
|
+ reg read_in_range,read_high_byte;
|
|
|
+ reg [7:0] header_low_byte;
|
|
|
reg [9:0] index;
|
|
|
reg [1:0] phase;
|
|
|
reg capture_pending;
|
|
|
@@ -38,19 +39,25 @@ module mrdimm_snapshot_mux #(
|
|
|
wire [9:0] bmc_relative=index-`MR_SNAPSHOT_BMC_RAW_OFFSET;
|
|
|
wire [9:0] ct_relative=index-`MR_SNAPSHOT_CT_RAW_OFFSET;
|
|
|
wire [9:0] axis_relative=index-`MR_SNAPSHOT_AXIS_OFFSET;
|
|
|
+ wire copying_axes=index>=`MR_SNAPSHOT_AXIS_OFFSET;
|
|
|
assign bmc_rd_index=in_bmc ? bmc_relative[5:1] : 5'd0;
|
|
|
assign ct_rd_index=in_ct ? ct_relative[5:1] : 5'd0;
|
|
|
wire [7:0] copy_data=in_bmc ? (bmc_relative[0] ? bmc_rd_raw[15:8] : bmc_rd_raw[7:0]) :
|
|
|
in_ct ? (ct_relative[0] ? ct_rd_raw[15:8] : ct_rd_raw[7:0]) :
|
|
|
index>=`MR_SNAPSHOT_AXIS_OFFSET ? axis_data[axis_relative*8 +:8] : header_shadow[index*8 +:8];
|
|
|
- ef2_bram_dp #(.DATA_WIDTH(8),.ADDR_WIDTH(SNAPSHOT_ADDR_WIDTH),.DATA_DEPTH(SNAPSHOT_LENGTH)) u_snapshot_memory (
|
|
|
- .clk(clk),.a_en(locked && phase==2),.a_we(locked && phase==2),
|
|
|
- .a_addr(index[SNAPSHOT_ADDR_WIDTH-1:0]),.a_wdata(copy_data),.a_rdata(),
|
|
|
- .b_en(1'b1),.b_we(1'b0),.b_addr(read_addr[SNAPSHOT_ADDR_WIDTH-1:0]),
|
|
|
- .b_wdata(8'd0),.b_rdata(memory_read_data)
|
|
|
+ wire memory_write=locked && (copying_axes || (phase==2 && index[0]));
|
|
|
+ wire [15:0] memory_write_data=copying_axes ? axis_data[axis_relative*8 +:16] : {copy_data,header_low_byte};
|
|
|
+ ef2_bram_dp #(.DATA_WIDTH(16),.ADDR_WIDTH(SNAPSHOT_ADDR_WIDTH),.DATA_DEPTH(SNAPSHOT_LENGTH/2)) u_snapshot_memory (
|
|
|
+ .clk(clk),.a_en(memory_write),.a_we(memory_write),
|
|
|
+ .a_addr(index[SNAPSHOT_ADDR_WIDTH:1]),.a_wdata(memory_write_data),.a_rdata(),
|
|
|
+ .b_en(1'b1),.b_we(1'b0),.b_addr(read_addr[SNAPSHOT_ADDR_WIDTH:1]),
|
|
|
+ .b_wdata(16'd0),.b_rdata(memory_read_data)
|
|
|
);
|
|
|
- always @(posedge clk) read_in_range<=read_addr<SNAPSHOT_LENGTH;
|
|
|
- assign read_data=read_in_range ? memory_read_data : 8'hFF;
|
|
|
+ always @(posedge clk)begin
|
|
|
+ read_in_range<=read_addr<SNAPSHOT_LENGTH;read_high_byte<=read_addr[0];
|
|
|
+ if(locked && !copying_axes && phase==2 && !index[0])header_low_byte<=copy_data;
|
|
|
+ end
|
|
|
+ assign read_data=read_in_range ? (read_high_byte ? memory_read_data[15:8] : memory_read_data[7:0]) : 8'hFF;
|
|
|
always @(posedge clk or negedge rst_n) begin
|
|
|
if(!rst_n) begin
|
|
|
ready<=0;locked<=0;bmc_locked_bank<=0;ct_locked_bank<=0;index<=0;phase<=0;
|
|
|
@@ -86,16 +93,16 @@ module mrdimm_snapshot_mux #(
|
|
|
header_shadow[`MR_SNAPSHOT_EVENT_PENDING_OVERFLOW_OFFSET*8 +:32]<=event_pending_overflow;
|
|
|
header_shadow[`MR_SNAPSHOT_GLOBAL_FLAGS_OFFSET*8 +:32]<=global_flags;
|
|
|
end else if(locked) begin
|
|
|
- if(phase==2) begin
|
|
|
+ if(copying_axes || phase==2) begin
|
|
|
phase<=0;
|
|
|
- if(index==SNAPSHOT_LENGTH-1) begin
|
|
|
+ if(index==SNAPSHOT_LENGTH-2) begin
|
|
|
locked<=0;
|
|
|
- // At most3*928 copy clocks for12 axes: a16-bit version
|
|
|
+ // 3*160+32*AXIS_COUNT copy clocks: a16-bit version
|
|
|
// advancing at most once/clock cannot wrap unnoticed.
|
|
|
if(source_ready && source_epoch==captured_epoch)ready<=1;
|
|
|
else capture_pending<=1;
|
|
|
end
|
|
|
- else index<=index+1'b1;
|
|
|
+ else index<=index+(copying_axes ? 2 : 1);
|
|
|
end else phase<=phase+1'b1;
|
|
|
end
|
|
|
end
|