mirror of
https://github.com/MPSU/APS.git
synced 2025-09-15 17:20:10 +00:00
Правки тб памяти
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -21,8 +21,9 @@
|
|||||||
|
|
||||||
module tb_data_mem();
|
module tb_data_mem();
|
||||||
|
|
||||||
parameter ADDR_SIZE = 4096;
|
parameter ADDR_SIZE = 16384;
|
||||||
parameter TIME_OPERATION = 50;
|
parameter TIME_OPERATION = 20;
|
||||||
|
parameter STEP = 8;
|
||||||
|
|
||||||
logic CLK;
|
logic CLK;
|
||||||
logic REQ;
|
logic REQ;
|
||||||
@@ -36,14 +37,12 @@ parameter TIME_OPERATION = 50;
|
|||||||
.mem_req_i (REQ),
|
.mem_req_i (REQ),
|
||||||
.write_enable_i (WE ),
|
.write_enable_i (WE ),
|
||||||
.addr_i (A ),
|
.addr_i (A ),
|
||||||
.write_data_i (WD),
|
.write_data_i (WD ),
|
||||||
.read_data_o (RD)
|
.read_data_o (RD )
|
||||||
);
|
);
|
||||||
|
|
||||||
logic [31:0] RDa;
|
logic [31:0] RDa;
|
||||||
|
|
||||||
integer i, err_count = 0;
|
integer i, err_count = 0;
|
||||||
|
|
||||||
assign A = i;
|
assign A = i;
|
||||||
|
|
||||||
parameter CLK_FREQ_MHz = 100;
|
parameter CLK_FREQ_MHz = 100;
|
||||||
@@ -57,7 +56,7 @@ parameter TIME_OPERATION = 50;
|
|||||||
$display( "\nStart test: \n\n==========================\nCLICK THE BUTTON 'Run All'\n==========================\n"); $stop();
|
$display( "\nStart test: \n\n==========================\nCLICK THE BUTTON 'Run All'\n==========================\n"); $stop();
|
||||||
REQ = 1;
|
REQ = 1;
|
||||||
WE = 0;
|
WE = 0;
|
||||||
i = 1; #10;
|
i = 0; #10;
|
||||||
if (RD !== 32'hx) begin
|
if (RD !== 32'hx) begin
|
||||||
$display("The data memory should not be initialized by the $readmemh function");
|
$display("The data memory should not be initialized by the $readmemh function");
|
||||||
err_count = err_count + 1;
|
err_count = err_count + 1;
|
||||||
@@ -67,8 +66,8 @@ parameter TIME_OPERATION = 50;
|
|||||||
WE = 1;
|
WE = 1;
|
||||||
WD = $urandom;
|
WD = $urandom;
|
||||||
end
|
end
|
||||||
for (i = 0; i < (ADDR_SIZE+1); i = i + 1) begin
|
for (i = 0; i < (ADDR_SIZE+STEP); i = i + 1 + $urandom() % STEP) begin
|
||||||
if (i != (ADDR_SIZE+1)) begin
|
if (i < (ADDR_SIZE)) begin
|
||||||
REQ = |($urandom %10);
|
REQ = |($urandom %10);
|
||||||
WE = 0;
|
WE = 0;
|
||||||
#TIME_OPERATION;
|
#TIME_OPERATION;
|
||||||
@@ -87,10 +86,11 @@ parameter TIME_OPERATION = 50;
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
|
WE = 0;
|
||||||
REQ = 1;
|
REQ = 1;
|
||||||
#TIME_OPERATION;
|
#TIME_OPERATION;
|
||||||
if (RD !== 32'd3735928559) begin
|
if (RD !== 32'd3735928559) begin
|
||||||
$display("When reading (write_enable_i = %h) at an address greater than 4095, it should return dead_beef yor data: %h_%h, time: %t", WE, RD[31:16],RD[15:0], $time);
|
$display("When reading (write_enable_i = %h) at an address greater than 16383 (addr = %d), it should return dead_beef your data: %h_%h, time: %t", WE, A, RD[31:16],RD[15:0], $time);
|
||||||
err_count = err_count + 1;
|
err_count = err_count + 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -98,31 +98,29 @@ parameter TIME_OPERATION = 50;
|
|||||||
end
|
end
|
||||||
#TIME_OPERATION;
|
#TIME_OPERATION;
|
||||||
REQ = 1;
|
REQ = 1;
|
||||||
WE = 1;
|
|
||||||
#TIME_OPERATION;
|
|
||||||
for (i = 0; i < 8; i = i + 4) begin
|
|
||||||
WD = i? 32'hfecd_ba98: 32'h7654_3210;
|
|
||||||
#TIME_OPERATION;
|
|
||||||
end
|
|
||||||
WE = 0;
|
WE = 0;
|
||||||
i = 2;
|
|
||||||
#TIME_OPERATION;
|
#TIME_OPERATION;
|
||||||
if (RD !== 32'hba98_7654) begin
|
for (i = 0; i < 4; i = i + 1) begin
|
||||||
$display("data is being written to the cell incorrectly. RAM [0:7] must be 0x0123456789abcdef, time: %t", $time);
|
if(i==0) begin
|
||||||
|
repeat(2)@(posedge CLK);
|
||||||
|
RDa = RD;
|
||||||
|
end else
|
||||||
|
if(RD !== RDa) begin
|
||||||
|
$display("incorrect conversion of the reading address = %h, time: %t", A, $time);
|
||||||
err_count = err_count + 1;
|
err_count = err_count + 1;
|
||||||
|
end
|
||||||
|
#TIME_OPERATION;
|
||||||
end
|
end
|
||||||
@(posedge CLK)
|
i = 0; WE = 0; REQ = 1;
|
||||||
i = 0;
|
@(posedge CLK);
|
||||||
@(negedge CLK);
|
@(negedge CLK);
|
||||||
if (RD !== 32'hba98_7654) begin
|
i = 4;
|
||||||
|
#1; RDa = RD;
|
||||||
|
@(posedge CLK); #1;
|
||||||
|
if (RD == RDa) begin
|
||||||
$display("reading from data memory must be synchronous, time: %t", $time);
|
$display("reading from data memory must be synchronous, time: %t", $time);
|
||||||
err_count = err_count + 1;
|
err_count = err_count + 1;
|
||||||
end
|
end
|
||||||
@(posedge CLK); #5;
|
|
||||||
if (RD !== 32'h7654_3210) begin
|
|
||||||
$display("synchronous data memory read error, time: %t", $time);
|
|
||||||
err_count = err_count + 1;
|
|
||||||
end
|
|
||||||
$display("Number of errors: %d", err_count);
|
$display("Number of errors: %d", err_count);
|
||||||
if( !err_count ) $display("\ndata_mem SUCCESS!!!\n");
|
if( !err_count ) $display("\ndata_mem SUCCESS!!!\n");
|
||||||
$finish();
|
$finish();
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user