abstractaccelerator/Flow/design/ifu/el2_ifu_tb_memread.sv

95 lines
2.3 KiB
Systemverilog
Raw Normal View History

2022-05-10 21:06:26 +08:00
//********************************************************************************
// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 Western Digital Corporation or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//********************************************************************************
module el2_ifu_tb_memread;
2022-05-23 22:16:04 +08:00
logic [15:0] compressed [0:128000]; // vector of compressed instructions
logic [31:0] expected [0:128000]; // vector of correspoding expected instruction
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
logic rst_l;
logic clk;
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
int clk_count;
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
logic [31:0] expected_val;
logic [15:0] compressed_din;
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
logic [31:0] actual;
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
logic error;
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
integer i;
initial begin
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
clk = 0;
rst_l = 0;
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
// initialize the reads and populate the instruction arrays
$readmemh("left64k", compressed);
$readmemh("right64k", expected);
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
$dumpfile("top.vcd");
$dumpvars;
$dumpon;
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
end
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
always #50 clk = ~clk;
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
always @(posedge clk) begin
clk_count = clk_count + 1;
if (clk_count >= 1 & clk_count <= 3) rst_l <= 1'b0;
else rst_l <= 1'b1;
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
if (clk_count > 3) begin
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
compressed_din[15:0] <= compressed[clk_count-3]; // c.mv
expected_val[31:0] <= expected[clk_count-3];
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
end
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
if (clk_count == 65000) begin
$dumpoff;
$finish;
end
end // always @ (posedge clk)
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
always @(negedge clk) begin
if (clk_count > 3 & error) begin
$display("clock: %d compressed %h error actual %h expected %h", clk_count, compressed_din,
actual, expected_val);
end
end
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
el2_ifu_compress_ctl align (
.*,
.din (compressed_din[15:0]),
.dout(actual[31:0])
);
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
assign error = actual[31:0] != expected_val[31:0];
2022-05-10 21:06:26 +08:00
2022-05-23 22:16:04 +08:00
endmodule // el2_ifu_tb_memread
2022-05-10 21:06:26 +08:00