data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v
1: b'%Warning-STMTDLY: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:61: Unsupported: Ignoring delay on this delayed statement.\n always #12.5 clock <= (clock === 1\'b0);\n        ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:71: Number is missing value digits: 32\'h\n  $display("SIGNATURE_START: 0x%h", 32\'h`SIGNATURE_START);\n                                    ^~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:71: Define or directive not defined: \'`SIGNATURE_START\'\n  $display("SIGNATURE_START: 0x%h", 32\'h`SIGNATURE_START);\n                                        ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:72: Number is missing value digits: 32\'h\n  $display("SIGNATURE_END: 0x%h", 32\'h`SIGNATURE_END);\n                                  ^~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:72: Define or directive not defined: \'`SIGNATURE_END\'\n  $display("SIGNATURE_END: 0x%h", 32\'h`SIGNATURE_END);\n                                      ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:73: Number is missing value digits: 32\'h\n  $display("CODE_END: 0x%h", 32\'h`CODE_END);\n                             ^~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:73: Define or directive not defined: \'`CODE_END\'\n  $display("CODE_END: 0x%h", 32\'h`CODE_END);\n                                 ^~~~~~~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:75: Number is missing value digits: 32\'h\n  wait((probe_programCounter == 32\'h`CODE_END) || (|probe_errorCode));\n                                ^~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:75: Define or directive not defined: \'`CODE_END\'\n  wait((probe_programCounter == 32\'h`CODE_END) || (|probe_errorCode));\n                                    ^~~~~~~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:75: Unsupported: wait statements\n  wait((probe_programCounter == 32\'h`CODE_END) || (|probe_errorCode));\n  ^~~~\n%Warning-STMTDLY: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:77: Unsupported: Ignoring delay on this delayed statement.\n  #50\n  ^\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:101: Number is missing value digits: 32\'h\n  for (i = 32\'h`SIGNATURE_START; i < 32\'h`SIGNATURE_END; i = i + 4) begin\n           ^~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:101: Define or directive not defined: \'`SIGNATURE_START\'\n  for (i = 32\'h`SIGNATURE_START; i < 32\'h`SIGNATURE_END; i = i + 4) begin\n               ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:101: Number is missing value digits: 32\'h\n  for (i = 32\'h`SIGNATURE_START; i < 32\'h`SIGNATURE_END; i = i + 4) begin\n                                     ^~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:101: Define or directive not defined: \'`SIGNATURE_END\'\n  for (i = 32\'h`SIGNATURE_START; i < 32\'h`SIGNATURE_END; i = i + 4) begin\n                                         ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:102: Unsupported: Use $fdisplay with %x format instead: $fdisplayh\n   $fdisplayh(fd, { memory[i + 3], memory[i + 2], memory[i + 1], memory[i + 0] });\n   ^~~~~~~~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:111: Unsupported or unknown PLI call: $dumpfile\n  $dumpfile("coreArch.vcd");\n  ^~~~~~~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:116: Unsupported or unknown PLI call: $dumpvars\n  $dumpvars(2, coreArch_tb);\n  ^~~~~~~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:121: syntax error, unexpected \'@\'\n   repeat (1000) @(posedge clock);\n                 ^\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:136: Number is missing value digits: 32\'h\n  for (i = 32\'h`SIGNATURE_START; i < 32\'h`SIGNATURE_END; i = i + 4) begin\n           ^~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:136: Define or directive not defined: \'`SIGNATURE_START\'\n  for (i = 32\'h`SIGNATURE_START; i < 32\'h`SIGNATURE_END; i = i + 4) begin\n               ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:136: Number is missing value digits: 32\'h\n  for (i = 32\'h`SIGNATURE_START; i < 32\'h`SIGNATURE_END; i = i + 4) begin\n                                     ^~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:136: Define or directive not defined: \'`SIGNATURE_END\'\n  for (i = 32\'h`SIGNATURE_START; i < 32\'h`SIGNATURE_END; i = i + 4) begin\n                                         ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:137: Unsupported: Use $fdisplay with %x format instead: $fdisplayh\n   $fdisplayh(fd, { memory[i + 3], memory[i + 2], memory[i + 1], memory[i + 0] });\n   ^~~~~~~~~~\n%Warning-STMTDLY: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:147: Unsupported: Ignoring delay on this delayed statement.\n  #2000;\n  ^\n%Warning-STMTDLY: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:156: Unsupported: Ignoring delay on this delayed statement.\n  #100;\n  ^\n%Warning-STMTDLY: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:158: Unsupported: Ignoring delay on this delayed statement.\n  #100;\n  ^\n%Warning-STMTDLY: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:160: Unsupported: Ignoring delay on this delayed statement.\n  #100;\n  ^\n%Warning-STMTDLY: data/full_repos/permissive/476477303/verilog/dv/coreArch/coreArch_tb.v:162: Unsupported: Ignoring delay on this delayed statement.\n  #100;\n  ^\n%Error: Exiting due to 22 error(s), 7 warning(s)\n        ... See the manual and https://verilator.org for more assistance.\n'
module coreArch_tb;
	reg clock;
	reg RSTB;
	reg power1, power2;
	reg power3, power4;

	wire[31:0] memoryAddress;
	wire[3:0] memoryByteSelect;
	wire memoryWriteEnable;
	wire memoryReadEnable;
	wire[31:0] memoryDataWrite;
	wire[31:0] memoryDataRead;
	wire memoryBusy = 1'b0;
	wire memoryAccessFault = 1'b0;
	
	wire management_run = 1'b1;
	wire management_trapEnable = 1'b1;
	wire management_interruptEnable = 1'b1;
	wire management_writeEnable = 1'b0;
	wire[3:0] management_byteSelect = 4'b0000;
	wire[15:0] management_address = 'b0;
	wire[31:0] management_writeData = 'b0;
	wire[31:0] management_readData;

	wire isAddressBreakpoint = 1'b0;
	wire[15:0] userInterrupts = 16'b0;

	wire[1:0] probe_state;
	wire[1:0] probe_env;
	wire[31:0] probe_programCounter;
	wire[6:0] probe_opcode;
	wire[1:0] probe_errorCode;
	wire probe_isBranch;
	wire probe_takeBranch;
	wire probe_isStore;
	wire probe_isLoad;
	wire probe_isCompressed;




	always #12.5 clock <= (clock === 1'b0);

	initial begin
		clock = 0;
	end

	integer fd;
	integer i;

	initial begin
		$display("SIGNATURE_START: 0x%h", 32'h`SIGNATURE_START);
		$display("SIGNATURE_END: 0x%h", 32'h`SIGNATURE_END);
		$display("CODE_END: 0x%h", 32'h`CODE_END);

		wait((probe_programCounter == 32'h`CODE_END) || (|probe_errorCode));

		#50

		if (|probe_errorCode) begin
			$display("%c[1;31m",27);
			`ifdef GL
				$display ("Monitor: Core Arch Test (GL) Failed");
			`else
				$display ("Monitor: Core Arch Test (RTL) Failed");
			`endif
			$display("%c[0m",27);
		end else begin
			$display("%c[1;92m",27);
			`ifdef GL
				$display ("Monitor: Core Arch Test (GL) Completed");
			`else
				$display ("Monitor: Core Arch Test (RTL) Completed");
			`endif
			$display("%c[0m",27);
		end

		$display("Writing memory dump to memory.hex");

		fd = $fopen("DUT-ExperiarSoC.signature", "w");
		
		for (i = 32'h`SIGNATURE_START; i < 32'h`SIGNATURE_END; i = i + 4) begin
			$fdisplayh(fd, { memory[i + 3], memory[i + 2], memory[i + 1], memory[i + 0] });
		end

		$fclose(fd);

		$finish;
	end

	initial begin
		$dumpfile("coreArch.vcd");

`ifdef SIM
		$dumpvars(0, coreArch_tb);
`else
		$dumpvars(2, coreArch_tb);
`endif


		repeat (20) begin
			repeat (1000) @(posedge clock);
		end
		
		$display("%c[1;35m",27);
		`ifdef GL
			$display ("Monitor: Timeout, Core Arch Test (GL) Failed");
		`else
			$display ("Monitor: Timeout, Core Arch Test (RTL) Failed");
		`endif
		$display("%c[0m",27);

		$display("Writing memory dump to memory.hex");

		fd = $fopen("DUT-ExperiarSoC.signature", "w");
		
		for (i = 32'h`SIGNATURE_START; i < 32'h`SIGNATURE_END; i = i + 4) begin
			$fdisplayh(fd, { memory[i + 3], memory[i + 2], memory[i + 1], memory[i + 0] });
		end

		$fclose(fd);

		$finish;
	end

	initial begin
		RSTB <= 1'b0;
		#2000;
		RSTB <= 1'b1;
	end

	initial begin
		power1 <= 1'b0;
		power2 <= 1'b0;
		power3 <= 1'b0;
		power4 <= 1'b0;
		#100;
		power1 <= 1'b1;
		#100;
		power2 <= 1'b1;
		#100;
		power3 <= 1'b1;
		#100;
		power4 <= 1'b1;
	end

	wire VDD3V3;
	wire VDD1V8;
	wire VSS;
	
	assign VDD3V3 = power1;
	assign VDD1V8 = power2;
	assign VSS = 1'b0;

	localparam CORE_EXTENSIONS = 26'b00_0000_0000_0000_0001_0000_0000;

	RV32ICore core(
		.vccd1 (VDD1V8),
		.vssd1 (VSS),
		.clk(clock),
		.rst(!RSTB),
		.memoryAddress(memoryAddress),
		.memoryByteSelect(memoryByteSelect),
		.memoryWriteEnable(memoryWriteEnable),
		.memoryReadEnable(memoryReadEnable),
		.memoryDataWrite(memoryDataWrite),
		.memoryDataRead(memoryDataRead),
		.memoryBusy(memoryBusy),
		.memoryAccessFault(memoryAccessFault),
		.management_run(management_run),
		.management_trapEnable(management_trapEnable),
		.management_interruptEnable(management_interruptEnable),
		.management_writeEnable(management_writeEnable),
		.management_byteSelect(management_byteSelect),
		.management_address(management_address),
		.management_writeData(management_writeData),
		.management_readData(management_readData),
		.coreIndex(8'h00),
		.manufacturerID(11'h000),
		.partID(16'hCD55),
		.versionID(4'h0),
		.extensions(CORE_EXTENSIONS),
		.isAddressBreakpoint(isAddressBreakpoint),
		.userInterrupts(userInterrupts),
		.probe_state(probe_state),
		.probe_env(probe_env),
		.probe_programCounter(probe_programCounter),
		.probe_opcode(probe_opcode),
		.probe_errorCode(probe_errorCode),
		.probe_isBranch(probe_isBranch),
		.probe_takeBranch(probe_takeBranch),
		.probe_isStore(probe_isStore),
		.probe_isLoad(probe_isLoad),
		.probe_isCompressed(probe_isCompressed));



	reg[7:0] memory [0:(16 * 1024 * 1024)-1];

	initial begin
		$display("Reading from coreArch.hex");
		$readmemh("coreArch.hex", memory);
		$display("%s loaded into memory", "coreArch.hex");
		$display("Memory 5 bytes = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", memory[0], memory[1], memory[2], memory[3], memory[4]);
	end

	wire sramEnable = RSTB && ((memoryAddress[31:24] == 8'h00) || (memoryAddress[31:24] == 8'h80));
	wire sramWriteEnable = sramEnable && memoryWriteEnable;
	wire sramReadEnable = sramEnable && memoryReadEnable;
	wire[23:0] localAddress = memoryAddress[23:0];

	always @(posedge clock) begin
		if (sramWriteEnable) begin
			if (memoryByteSelect[0]) memory[localAddress] <= memoryDataWrite[7:0];
			if (memoryByteSelect[1]) memory[localAddress + 1] <= memoryDataWrite[15:8];
			if (memoryByteSelect[2]) memory[localAddress + 2] <= memoryDataWrite[23:16];
			if (memoryByteSelect[3]) memory[localAddress + 3] <= memoryDataWrite[31:24];
			$display("Write of 0x%h to 0x%h", memoryDataWrite, localAddress);
		end
	end

	assign memoryDataRead = {
		memoryByteSelect[3] && sramReadEnable ? memory[localAddress + 3] : 8'b0,
		memoryByteSelect[2] && sramReadEnable ? memory[localAddress + 2] : 8'b0,
		memoryByteSelect[1] && sramReadEnable ? memory[localAddress + 1] : 8'b0,
		memoryByteSelect[0] && sramReadEnable ? memory[localAddress] : 8'b0 
	};

endmodule
module coreArch_tb;

	reg clock;
	reg RSTB;
	reg power1, power2;
	reg power3, power4;

	wire[31:0] memoryAddress;
	wire[3:0] memoryByteSelect;
	wire memoryWriteEnable;
	wire memoryReadEnable;
	wire[31:0] memoryDataWrite;
	wire[31:0] memoryDataRead;
	wire memoryBusy = 1'b0;
	wire memoryAccessFault = 1'b0;
	
	wire management_run = 1'b1;
	wire management_trapEnable = 1'b1;
	wire management_interruptEnable = 1'b1;
	wire management_writeEnable = 1'b0;
	wire[3:0] management_byteSelect = 4'b0000;
	wire[15:0] management_address = 'b0;
	wire[31:0] management_writeData = 'b0;
	wire[31:0] management_readData;

	wire isAddressBreakpoint = 1'b0;
	wire[15:0] userInterrupts = 16'b0;

	wire[1:0] probe_state;
	wire[1:0] probe_env;
	wire[31:0] probe_programCounter;
	wire[6:0] probe_opcode;
	wire[1:0] probe_errorCode;
	wire probe_isBranch;
	wire probe_takeBranch;
	wire probe_isStore;
	wire probe_isLoad;
	wire probe_isCompressed;




	always #12.5 clock <= (clock === 1'b0);

	initial begin
		clock = 0;
	end

	integer fd;
	integer i;

	initial begin
		$display("SIGNATURE_START: 0x%h", 32'h`SIGNATURE_START);
		$display("SIGNATURE_END: 0x%h", 32'h`SIGNATURE_END);
		$display("CODE_END: 0x%h", 32'h`CODE_END);

		wait((probe_programCounter == 32'h`CODE_END) || (|probe_errorCode));

		#50

		if (|probe_errorCode) begin
			$display("%c[1;31m",27);
			`ifdef GL
				$display ("Monitor: Core Arch Test (GL) Failed");
			`else
				$display ("Monitor: Core Arch Test (RTL) Failed");
			`endif
			$display("%c[0m",27);
		end else begin
			$display("%c[1;92m",27);
			`ifdef GL
				$display ("Monitor: Core Arch Test (GL) Completed");
			`else
				$display ("Monitor: Core Arch Test (RTL) Completed");
			`endif
			$display("%c[0m",27);
		end

		$display("Writing memory dump to memory.hex");

		fd = $fopen("DUT-ExperiarSoC.signature", "w");
		
		for (i = 32'h`SIGNATURE_START; i < 32'h`SIGNATURE_END; i = i + 4) begin
			$fdisplayh(fd, { memory[i + 3], memory[i + 2], memory[i + 1], memory[i + 0] });
		end

		$fclose(fd);

		$finish;
	end

	initial begin
		$dumpfile("coreArch.vcd");

`ifdef SIM
		$dumpvars(0, coreArch_tb);
`else
		$dumpvars(2, coreArch_tb);
`endif


		repeat (20) begin
			repeat (1000) @(posedge clock);
		end
		
		$display("%c[1;35m",27);
		`ifdef GL
			$display ("Monitor: Timeout, Core Arch Test (GL) Failed");
		`else
			$display ("Monitor: Timeout, Core Arch Test (RTL) Failed");
		`endif
		$display("%c[0m",27);

		$display("Writing memory dump to memory.hex");

		fd = $fopen("DUT-ExperiarSoC.signature", "w");
		
		for (i = 32'h`SIGNATURE_START; i < 32'h`SIGNATURE_END; i = i + 4) begin
			$fdisplayh(fd, { memory[i + 3], memory[i + 2], memory[i + 1], memory[i + 0] });
		end

		$fclose(fd);

		$finish;
	end

	initial begin
		RSTB <= 1'b0;
		#2000;
		RSTB <= 1'b1;
	end

	initial begin
		power1 <= 1'b0;
		power2 <= 1'b0;
		power3 <= 1'b0;
		power4 <= 1'b0;
		#100;
		power1 <= 1'b1;
		#100;
		power2 <= 1'b1;
		#100;
		power3 <= 1'b1;
		#100;
		power4 <= 1'b1;
	end

	wire VDD3V3;
	wire VDD1V8;
	wire VSS;
	
	assign VDD3V3 = power1;
	assign VDD1V8 = power2;
	assign VSS = 1'b0;

	localparam CORE_EXTENSIONS = 26'b00_0000_0000_0000_0001_0000_0000;

	RV32ICore core(
		.vccd1 (VDD1V8),
		.vssd1 (VSS),
		.clk(clock),
		.rst(!RSTB),
		.memoryAddress(memoryAddress),
		.memoryByteSelect(memoryByteSelect),
		.memoryWriteEnable(memoryWriteEnable),
		.memoryReadEnable(memoryReadEnable),
		.memoryDataWrite(memoryDataWrite),
		.memoryDataRead(memoryDataRead),
		.memoryBusy(memoryBusy),
		.memoryAccessFault(memoryAccessFault),
		.management_run(management_run),
		.management_trapEnable(management_trapEnable),
		.management_interruptEnable(management_interruptEnable),
		.management_writeEnable(management_writeEnable),
		.management_byteSelect(management_byteSelect),
		.management_address(management_address),
		.management_writeData(management_writeData),
		.management_readData(management_readData),
		.coreIndex(8'h00),
		.manufacturerID(11'h000),
		.partID(16'hCD55),
		.versionID(4'h0),
		.extensions(CORE_EXTENSIONS),
		.isAddressBreakpoint(isAddressBreakpoint),
		.userInterrupts(userInterrupts),
		.probe_state(probe_state),
		.probe_env(probe_env),
		.probe_programCounter(probe_programCounter),
		.probe_opcode(probe_opcode),
		.probe_errorCode(probe_errorCode),
		.probe_isBranch(probe_isBranch),
		.probe_takeBranch(probe_takeBranch),
		.probe_isStore(probe_isStore),
		.probe_isLoad(probe_isLoad),
		.probe_isCompressed(probe_isCompressed));



	reg[7:0] memory [0:(16 * 1024 * 1024)-1];

	initial begin
		$display("Reading from coreArch.hex");
		$readmemh("coreArch.hex", memory);
		$display("%s loaded into memory", "coreArch.hex");
		$display("Memory 5 bytes = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", memory[0], memory[1], memory[2], memory[3], memory[4]);
	end

	wire sramEnable = RSTB && ((memoryAddress[31:24] == 8'h00) || (memoryAddress[31:24] == 8'h80));
	wire sramWriteEnable = sramEnable && memoryWriteEnable;
	wire sramReadEnable = sramEnable && memoryReadEnable;
	wire[23:0] localAddress = memoryAddress[23:0];

	always @(posedge clock) begin
		if (sramWriteEnable) begin
			if (memoryByteSelect[0]) memory[localAddress] <= memoryDataWrite[7:0];
			if (memoryByteSelect[1]) memory[localAddress + 1] <= memoryDataWrite[15:8];
			if (memoryByteSelect[2]) memory[localAddress + 2] <= memoryDataWrite[23:16];
			if (memoryByteSelect[3]) memory[localAddress + 3] <= memoryDataWrite[31:24];
			$display("Write of 0x%h to 0x%h", memoryDataWrite, localAddress);
		end
	end

	assign memoryDataRead = {
		memoryByteSelect[3] && sramReadEnable ? memory[localAddress + 3] : 8'b0,
		memoryByteSelect[2] && sramReadEnable ? memory[localAddress + 2] : 8'b0,
		memoryByteSelect[1] && sramReadEnable ? memory[localAddress + 1] : 8'b0,
		memoryByteSelect[0] && sramReadEnable ? memory[localAddress] : 8'b0 
	};

endmodule