main.sv


`timescale 1ns/10ps

import GenPckg::*;
import DrvPckg::*;
import ReceiverPckg::*;
import ScoreboardPckg::*;

module Main ();

logic mclk=0;
logic sclk=0;

afdcuIf ifc( .mclk(mclk), .sclk(sclk) );
Top dut (.ifc(ifc));
mailbox SendBox = new();
mailbox RecivBox = new();
Driver drvObj = new (ifc, SendBox);
Receiver rxObj = new(ifc, RecivBox);
Scoreboard scbdObj = new(ifc, SendBox, RecivBox);
Generator genObj = new(drvObj,rxObj, ifc);

task DUT_READVeirf ();

// genObj.CONFIG();
// assert (genObj.randomize() );
// genObj.READ();
// receivObj.dutOutMonitorREAD();
// scorebrdObj.compareData("READ");

endtask

always
begin
// $display ("In clk generation part of always");
#12.5 mclk++;
end
always
begin
#5000 sclk++;
end

execTest runTbProgram ( );

endmodule

progTb.sv

program execTest ( );

int writeCyclesNmb = 30;

initial
begin
// WRITE Mode test
repeat (1)
fork
begin
genObj.CONFIG (1);
genObj.runWriteMode(0);
end
begin
rxObj.spiOutMonitor(); // This is for SPI_ALL_STATE
rxObj.spiOutMonitor(); // This is for SPI_DATA_STATE
end
begin
scbdObj.compareData_AllState();
scbdObj.compareData_DataState();
end
join

// READ Mode
$display("------------------------- READ Mode --------------------------------");
repeat (1)
begin
genObj.CONFIG (0);
genObj.runReadMode(1);
rxObj.spiOutMonitorRead();
scbdObj.compare_ReadData();
end
//////////////////////////////////////////////////////////////////////
///////////////////////////// Coverage Increasing
/////////////////////////////////////////////////////////////////////
// WRITE Mode test
// repeat (1)
// fork
// $display("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
// $display("&&&&&&&&&&&&&& Running the test with header mode : 0");
// begin
// genObj.CONFIG (1);
// genObj.runWriteMode(0);
// end
// begin
// rxObj.spiOutMonitor(); // This is for SPI_ALL_STATE
// rxObj.spiOutMonitor(); // This is for SPI_DATA_STATE
// end
// begin
// scbdObj.compareData_AllState();
// scbdObj.compareData_DataState();
// end
// join
//
// READ Mode
$display("------------------------- READ Mode --------------------------------");
repeat (1)
begin
$display("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
$display("&&&&&&&&&&&&&& Running the test with header mode : 0");
genObj.CONFIG (0);
genObj.runReadMode(0);
rxObj.spiOutMonitorRead();
scbdObj.compare_ReadData();
end
end

initial $timeformat( -9, 3, " ns", 12);

initial
begin
@ (negedge ifc.b_h_cs);
repeat (70)
@ (posedge ifc.sclk);
//$finish;
// #900 $finish;
end

final
$display ("************* TEST END ******************** \n");

endprogram

Leave a Reply

Your email address will not be published. Required fields are marked *