data/full_repos/permissive/511178588/simulation/cache.v
1: b'%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:23: Selection index out of range: 7:4 outside 3:0\n                                                                             : ... In instance associative_memory\n    dout <= cache[0][7:4];\n                    ^\n                   ... Use "/* verilator lint_off SELRANGE */" and lint_on around source to disable this message.\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:27: Selection index out of range: 7:4 outside 3:0\n                                                                             : ... In instance associative_memory\n    dout <= cache[1][7:4];\n                    ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:31: Selection index out of range: 7:4 outside 3:0\n                                                                             : ... In instance associative_memory\n    dout <= cache[2][7:4];\n                    ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:35: Selection index out of range: 7:4 outside 3:0\n                                                                             : ... In instance associative_memory\n    dout <= cache[3][7:4];\n                    ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:44: Selection index out of range: 7:4 outside 3:0\n                                                                             : ... In instance associative_memory\n    cache[0][7:4] <= din;\n            ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:46: Selection index out of range: 8:8 outside 3:0\n                                                                             : ... In instance associative_memory\n    cache[0][8] <= 1\'b1;\n            ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:49: Selection index out of range: 7:4 outside 3:0\n                                                                             : ... In instance associative_memory\n    cache[1][7:4] <= din;\n            ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:51: Selection index out of range: 8:8 outside 3:0\n                                                                             : ... In instance associative_memory\n    cache[1][8] <= 1\'b1;\n            ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:54: Selection index out of range: 7:4 outside 3:0\n                                                                             : ... In instance associative_memory\n    cache[2][7:4] <= din;\n            ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:56: Selection index out of range: 8:8 outside 3:0\n                                                                             : ... In instance associative_memory\n    cache[2][8] <= 1\'b1;\n            ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:59: Selection index out of range: 7:4 outside 3:0\n                                                                             : ... In instance associative_memory\n    cache[3][7:4] <= din;\n            ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:61: Selection index out of range: 8:8 outside 3:0\n                                                                             : ... In instance associative_memory\n    cache[3][8] <= 1\'b1;\n            ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:58: Selection index out of range: 8:8 outside 3:0\n                                                                             : ... In instance associative_memory\n   else if (cache[3][8] !== 1\'b1)begin\n                    ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:53: Selection index out of range: 8:8 outside 3:0\n                                                                             : ... In instance associative_memory\n   else if (cache[2][8] !== 1\'b1)begin\n                    ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:48: Selection index out of range: 8:8 outside 3:0\n                                                                             : ... In instance associative_memory\n   else if (cache[1][8] !== 1\'b1)begin\n                    ^\n%Warning-SELRANGE: data/full_repos/permissive/511178588/simulation/cache.v:43: Selection index out of range: 8:8 outside 3:0\n                                                                             : ... In instance associative_memory\n   if (cache[0][8] !== 1\'b1)begin\n               ^\n%Error: Exiting due to 16 warning(s)\n'
module associative_memory(addr,din,clk,wr,dout,hit);

	input [3:0] addr;
	input [3:0] din;
   input clk;
   input wr;
   output [3:0] dout;
   output hit;
	reg [3:0] dout;
	reg hit;

		 

	 reg [3:0] cache [8:0];
	
	
	 always @(posedge clk) begin

		if (wr == 1'b0) begin
			if (addr == cache[0][3:0])begin
				dout <= cache[0][7:4];
				hit <= 1'b1;
			end
			else if (addr == cache[1][3:0])begin
				dout <= cache[1][7:4];
				hit <= 1'b1;
			end
			else if (addr == cache[2][3:0])begin
				dout <= cache[2][7:4];
				hit <= 1'b1;
			end
			else if (addr == cache[3][3:0])begin
				dout <= cache[3][7:4];
				hit <= 1'b1;
			end
			else
				hit <= 1'b0;
		end

		else begin
			if (cache[0][8] !== 1'b1)begin
				cache[0][7:4] <= din;
				cache[0][3:0] <= addr;
				cache[0][8] <= 1'b1;
			end
			else if (cache[1][8] !== 1'b1)begin
				cache[1][7:4] <= din;
				cache[1][3:0] <= addr;
				cache[1][8] <= 1'b1;
			end
			else if (cache[2][8] !== 1'b1)begin
				cache[2][7:4] <= din;
				cache[2][3:0] <= addr;
				cache[2][8] <= 1'b1;
			end
			else if (cache[3][8] !== 1'b1)begin
				cache[3][7:4] <= din;
				cache[3][3:0] <= addr;
				cache[3][8] <= 1'b1;
			end
		end
			
	 end

	 		
endmodule
module associative_memory(addr,din,clk,wr,dout,hit);


	input [3:0] addr;
	input [3:0] din;
   input clk;
   input wr;
   output [3:0] dout;
   output hit;
	reg [3:0] dout;
	reg hit;

		 

	 reg [3:0] cache [8:0];
	
	
	 always @(posedge clk) begin

		if (wr == 1'b0) begin
			if (addr == cache[0][3:0])begin
				dout <= cache[0][7:4];
				hit <= 1'b1;
			end
			else if (addr == cache[1][3:0])begin
				dout <= cache[1][7:4];
				hit <= 1'b1;
			end
			else if (addr == cache[2][3:0])begin
				dout <= cache[2][7:4];
				hit <= 1'b1;
			end
			else if (addr == cache[3][3:0])begin
				dout <= cache[3][7:4];
				hit <= 1'b1;
			end
			else
				hit <= 1'b0;
		end

		else begin
			if (cache[0][8] !== 1'b1)begin
				cache[0][7:4] <= din;
				cache[0][3:0] <= addr;
				cache[0][8] <= 1'b1;
			end
			else if (cache[1][8] !== 1'b1)begin
				cache[1][7:4] <= din;
				cache[1][3:0] <= addr;
				cache[1][8] <= 1'b1;
			end
			else if (cache[2][8] !== 1'b1)begin
				cache[2][7:4] <= din;
				cache[2][3:0] <= addr;
				cache[2][8] <= 1'b1;
			end
			else if (cache[3][8] !== 1'b1)begin
				cache[3][7:4] <= din;
				cache[3][3:0] <= addr;
				cache[3][8] <= 1'b1;
			end
		end
			
	 end

	 		
endmodule