data/full_repos/permissive/487368624/Lab M/hrLib/mem.v
1: b'%Error: Cannot find file containing module: M/hrLib,data/full_repos/permissive/487368624\n        ... Looked in:\n             data/full_repos/permissive/487368624/Lab/M/hrLib,data/full_repos/permissive/487368624\n             data/full_repos/permissive/487368624/Lab/M/hrLib,data/full_repos/permissive/487368624.v\n             data/full_repos/permissive/487368624/Lab/M/hrLib,data/full_repos/permissive/487368624.sv\n             M/hrLib,data/full_repos/permissive/487368624\n             M/hrLib,data/full_repos/permissive/487368624.v\n             M/hrLib,data/full_repos/permissive/487368624.sv\n             obj_dir/M/hrLib,data/full_repos/permissive/487368624\n             obj_dir/M/hrLib,data/full_repos/permissive/487368624.v\n             obj_dir/M/hrLib,data/full_repos/permissive/487368624.sv\n%Error: Cannot find file containing module: data/full_repos/permissive/487368624/Lab\n%Error: Cannot find file containing module: M/hrLib/mem.v\n%Error: Exiting due to 3 error(s)\n'
module mem(memOut, address, memIn, clk, read, write);


parameter DEBUG = 0;

parameter CAPACITY = 16'hffff;
input clk, read, write;
input [31:0] address, memIn;
output [31:0] memOut;
reg [31:0] memOut;
reg [31:0] arr [0:CAPACITY];
reg fresh = 1;

always @(read or address or arr[address])
begin
	if (fresh == 1)
	begin
		fresh = 0;
		$readmemh("ram.dat", arr);
	end

	if (read == 1)
	begin
		if (address[1:0] != 2'b00)
		begin

			memOut = 32'hxxxxxxxx;
		end
		else if (address > CAPACITY)
		begin

			memOut = 32'hxxxxxxxx;
		end
		else
		begin
			memOut = arr[address];
		end
	end
end

always @(posedge clk)
begin
	if (write == 1)
	begin
		if (address[1:0] != 2'b00)
		begin

		end
		else if (address > CAPACITY)
		begin
			$display("Address %d out of range %d", address, CAPACITY);
		end
		else
		begin
			arr[address] <= memIn;
			if (DEBUG != 0) $display("MEM: wrote %0dd at address %0dd", memIn, address);
		end
	end
end

endmodule
module mem(memOut, address, memIn, clk, read, write);



parameter DEBUG = 0;

parameter CAPACITY = 16'hffff;
input clk, read, write;
input [31:0] address, memIn;
output [31:0] memOut;
reg [31:0] memOut;
reg [31:0] arr [0:CAPACITY];
reg fresh = 1;

always @(read or address or arr[address])
begin
	if (fresh == 1)
	begin
		fresh = 0;
		$readmemh("ram.dat", arr);
	end

	if (read == 1)
	begin
		if (address[1:0] != 2'b00)
		begin

			memOut = 32'hxxxxxxxx;
		end
		else if (address > CAPACITY)
		begin

			memOut = 32'hxxxxxxxx;
		end
		else
		begin
			memOut = arr[address];
		end
	end
end

always @(posedge clk)
begin
	if (write == 1)
	begin
		if (address[1:0] != 2'b00)
		begin

		end
		else if (address > CAPACITY)
		begin
			$display("Address %d out of range %d", address, CAPACITY);
		end
		else
		begin
			arr[address] <= memIn;
			if (DEBUG != 0) $display("MEM: wrote %0dd at address %0dd", memIn, address);
		end
	end
end

endmodule