data/full_repos/permissive/109400221/hdl/spi/spi_protocoltb.sv
 line:8: before: "package"
1: b'%Error: data/full_repos/permissive/109400221/hdl/spi/spi_protocoltb.sv:9: Unsupported: classes\nclass Packet;\n^~~~~\n%Error: data/full_repos/permissive/109400221/hdl/spi/spi_protocoltb.sv:13: Unsupported: \'static\' class item\nstatic int count = 0;     \n^~~~~~\n%Error: data/full_repos/permissive/109400221/hdl/spi/spi_protocoltb.sv:16: Unsupported: SystemVerilog 2005 reserved word not implemented: \'constraint\'\nconstraint c {\n^~~~~~~~~~\n%Error: data/full_repos/permissive/109400221/hdl/spi/spi_protocoltb.sv:16: syntax error, unexpected IDENTIFIER\nconstraint c {\n           ^\n%Error: data/full_repos/permissive/109400221/hdl/spi/spi_protocoltb.sv:20: Unsupported: SystemVerilog 2005 reserved word not implemented: \'constraint\'\nconstraint d {SS < 10;}\n^~~~~~~~~~\n%Error: data/full_repos/permissive/109400221/hdl/spi/spi_protocoltb.sv:22: Unsupported: SystemVerilog 2005 reserved word not implemented: \'constraint\'\nconstraint e {NUMSLAVES < 32 ;}\n^~~~~~~~~~\n%Error: data/full_repos/permissive/109400221/hdl/spi/spi_protocoltb.sv:58: syntax error, unexpected genvar\ngenvar i;\n^~~~~~\n%Error: data/full_repos/permissive/109400221/hdl/spi/spi_protocoltb.sv:96: Unsupported: SystemVerilog 2005 reserved word not implemented: \'randomize\'\nassert (p.randomize(D)) $display("randomization successful");   \n          ^~~~~~~~~\n%Error: data/full_repos/permissive/109400221/hdl/spi/spi_protocoltb.sv:166: syntax error, unexpected initial\ninitial begin\n^~~~~~~\n%Error: Cannot continue\n        ... See the manual and https://verilator.org for more assistance.\n'
module SPItb #(
	parameter data_width = 8,
	parameter NUMSLAVES = 12,
	parameter clkwidth = 100,
	parameter SS = 10);
	
	

typedef logic [data_width-1:0] DTYPE;


import Randomize::*;

logic mainclk,reset;

DTYPE D;

DTYPE temp,j;



int S,passed,failed,total_tests;
int index;
bit Request;
bit Done;

genvar i;

SPIBus #(.DTYPE(DTYPE),.NUMSLAVES(NUMSLAVES)) SPI();

generate
for(i = 1'b0; i < NUMSLAVES; i=i+1'b1)
begin : loop
SPISlave #(.DTYPE(DTYPE),.ID(i)) Slave(SPI);
end : loop
endgenerate

SPIMaster #(.DTYPE(DTYPE),.clkwidth(clkwidth)) M1(SPI,D,S,Request,Done,mainclk,reset);

always @ (D)begin
temp = D;
$display("D=%d",temp);
end

always #clkwidth mainclk=~mainclk;

initial begin
Packet p;
p = new();
			
p.data_width = data_width;
reset = 1'b0;			
mainclk=1'b0;
$display("In initial block. packetCount=%d",p.count);

passed=0;
failed=0;
total_tests=0;

for(int j=0; j<10; j=j+1) begin
$display("INSIDE J LOOP");
#200 Request = 0;
#100 Request = 1;
     S = SS;
assert (p.randomize(D)) $display("randomization successful");
else $fatal(0, "Packet::randomize failed");
	
     D = p.D;


wait(Done);				
$display("clk=%b, MR = %b, SR %d = %b, Done=%b",SPI.SCLK,D,SS,SPItb.loop[SS].Slave.SR,Done);
if(((SPItb.loop[SS].Slave.SR) === temp)) begin
$display("TEST PASSED");
passed=passed+1;
end
else begin
$display("TEST FAILED");
failed=failed+1;
end   
end

for(int z=0;z<6;z=z+1) begin
$display("INSIDE Z LOOP");

#200 Request = 0;
#100 Request = 1;
     S = SS;
if(z==0)  D = '0;	
else if(z==1)  D = '1;
else if(z==2)  D = 'x;	
else if(z==3)  D = {(data_width/2){2'b10}};	
else if(z==4)  D = {(data_width/2){2'b01}};	
else D = 'z;
	


wait(Done);
$display("clk=%b, MR = %b, SR %d = %b, Done=%b",SPI.SCLK,D,SS,SPItb.loop[SS].Slave.SR,Done);
if(((SPItb.loop[SS].Slave.SR) === temp))begin
$display("TEST PASSED");
passed=passed+1;
end
else begin
$display("TEST FAILED");
failed=failed+1;
end
end
 $stop;
end



always@(M1.MR,Done,Request,SPI.SCLK,mainclk,SPItb.loop[SS].Slave.SR,reset)			
$display($time," mainclk=%b, reset=%b, spi.sclk=%b, Request=%b, MR=%b, Done=%b, SR=%b",mainclk,reset,SPI.SCLK,Request,M1.MR,Done, SPItb.loop[SS].Slave.SR);

final begin
$display("NUMSLAVES=%d, datawidth=%d, SS=%d",NUMSLAVES,data_width,SS);
$display("total tests=%d, passed=%d, failed=%d",passed+failed,passed,failed);
if(failed==0) $display("TEST PASSED ! ! !");
else $display("TEST FAILED ! ! !");
end
endmodule
module SPItb #(
	parameter data_width = 8,
	parameter NUMSLAVES = 12,
	parameter clkwidth = 100,
	parameter SS = 10);

	
	

typedef logic [data_width-1:0] DTYPE;


import Randomize::*;

logic mainclk,reset;

DTYPE D;

DTYPE temp,j;



int S,passed,failed,total_tests;
int index;
bit Request;
bit Done;

genvar i;

SPIBus #(.DTYPE(DTYPE),.NUMSLAVES(NUMSLAVES)) SPI();

generate
for(i = 1'b0; i < NUMSLAVES; i=i+1'b1)
begin : loop
SPISlave #(.DTYPE(DTYPE),.ID(i)) Slave(SPI);
end : loop
endgenerate

SPIMaster #(.DTYPE(DTYPE),.clkwidth(clkwidth)) M1(SPI,D,S,Request,Done,mainclk,reset);

always @ (D)begin
temp = D;
$display("D=%d",temp);
end

always #clkwidth mainclk=~mainclk;

initial begin
Packet p;
p = new();
			
p.data_width = data_width;
reset = 1'b0;			
mainclk=1'b0;
$display("In initial block. packetCount=%d",p.count);

passed=0;
failed=0;
total_tests=0;

for(int j=0; j<10; j=j+1) begin
$display("INSIDE J LOOP");
#200 Request = 0;
#100 Request = 1;
     S = SS;
assert (p.randomize(D)) $display("randomization successful");
else $fatal(0, "Packet::randomize failed");
	
     D = p.D;


wait(Done);				
$display("clk=%b, MR = %b, SR %d = %b, Done=%b",SPI.SCLK,D,SS,SPItb.loop[SS].Slave.SR,Done);
if(((SPItb.loop[SS].Slave.SR) === temp)) begin
$display("TEST PASSED");
passed=passed+1;
end
else begin
$display("TEST FAILED");
failed=failed+1;
end   
end

for(int z=0;z<6;z=z+1) begin
$display("INSIDE Z LOOP");

#200 Request = 0;
#100 Request = 1;
     S = SS;
if(z==0)  D = '0;	
else if(z==1)  D = '1;
else if(z==2)  D = 'x;	
else if(z==3)  D = {(data_width/2){2'b10}};	
else if(z==4)  D = {(data_width/2){2'b01}};	
else D = 'z;
	


wait(Done);
$display("clk=%b, MR = %b, SR %d = %b, Done=%b",SPI.SCLK,D,SS,SPItb.loop[SS].Slave.SR,Done);
if(((SPItb.loop[SS].Slave.SR) === temp))begin
$display("TEST PASSED");
passed=passed+1;
end
else begin
$display("TEST FAILED");
failed=failed+1;
end
end
 $stop;
end



always@(M1.MR,Done,Request,SPI.SCLK,mainclk,SPItb.loop[SS].Slave.SR,reset)			
$display($time," mainclk=%b, reset=%b, spi.sclk=%b, Request=%b, MR=%b, Done=%b, SR=%b",mainclk,reset,SPI.SCLK,Request,M1.MR,Done, SPItb.loop[SS].Slave.SR);

final begin
$display("NUMSLAVES=%d, datawidth=%d, SS=%d",NUMSLAVES,data_width,SS);
$display("total tests=%d, passed=%d, failed=%d",passed+failed,passed,failed);
if(failed==0) $display("TEST PASSED ! ! !");
else $display("TEST FAILED ! ! !");
end
endmodule