data/full_repos/permissive/167856740/vga/vga_wishbone.v
1: b'%Error: data/full_repos/permissive/167856740/vga/vga_wishbone.v:43: Cannot find file containing module: \'vga_generator\'\n vga_generator display_vga(\n ^~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/167856740/vga,data/full_repos/permissive/167856740/vga_generator\n             data/full_repos/permissive/167856740/vga,data/full_repos/permissive/167856740/vga_generator.v\n             data/full_repos/permissive/167856740/vga,data/full_repos/permissive/167856740/vga_generator.sv\n             vga_generator\n             vga_generator.v\n             vga_generator.sv\n             obj_dir/vga_generator\n             obj_dir/vga_generator.v\n             obj_dir/vga_generator.sv\n%Error: data/full_repos/permissive/167856740/vga/vga_wishbone.v:92: Cannot find file containing module: \'text_pixel\'\n text_pixel #(\n ^~~~~~~~~~\n%Warning-WIDTH: data/full_repos/permissive/167856740/vga/vga_wishbone.v:131: Operator SHIFTR expects 32 or 10 bits on the LHS, but LHS\'s VARREF \'y\' generates 9 bits.\n                                                                           : ... In instance vga_wishbone\n  text_data_out <= text_data_memory[((y>>3) * TEXT_WIDTH) + (x>>3)];\n                                       ^~\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/167856740/vga/vga_wishbone.v:132: Operator SHIFTR expects 32 or 10 bits on the LHS, but LHS\'s VARREF \'y\' generates 9 bits.\n                                                                           : ... In instance vga_wishbone\n  text_colour_out <= text_colour_memory[((y>>3) * TEXT_WIDTH) + (x>>3)];\n                                           ^~\n%Warning-WIDTH: data/full_repos/permissive/167856740/vga/vga_wishbone.v:149: Bit extraction of array[4799:0] requires 13 bit index, not 14 bits.\n                                                                           : ... In instance vga_wishbone\n        text_data_memory[ADR_I[13:0]] <= DAT_I;\n                        ^\n%Warning-WIDTH: data/full_repos/permissive/167856740/vga/vga_wishbone.v:149: Operator ASSIGNDLY expects 8 bits on the Assign RHS, but Assign RHS\'s VARREF \'DAT_I\' generates 32 bits.\n                                                                           : ... In instance vga_wishbone\n        text_data_memory[ADR_I[13:0]] <= DAT_I;\n                                      ^~\n%Warning-WIDTH: data/full_repos/permissive/167856740/vga/vga_wishbone.v:153: Operator ASSIGNDLY expects 8 bits on the Assign RHS, but Assign RHS\'s VARREF \'DAT_I\' generates 32 bits.\n                                                                           : ... In instance vga_wishbone\n     text_colour_memory[ADR_I[13:0] - TEXT_DATA_DEPTH] <= DAT_I;\n                                                       ^~\n%Error: Exiting due to 2 error(s), 5 warning(s)\n'
module vga_wishbone #(parameter TEXT_DATA_MEMFILE="", TEXT_COLOUR_MEMFILE="")
    (

	input wire CLK_I,
	input wire RST_I,
	input wire STB_I,
    input wire WE_I,
	input wire [31:0] ADR_I,
	input wire [31:0] DAT_I,
	output wire INT_O,


	input wire mode,
	output wire hsync,
	output wire vsync,
	output reg [3:0] red,
	output reg [3:0] green,
	output reg [3:0] blue
    );
    








	wire [9:0] x;
	wire [8:0] y;


	wire active;
	wire blanking;
		

    reg interrupt_latched;
    reg interrupt_enable;  
          
    assign INT_O = interrupt_latched;


	vga_generator display_vga(
		.clk(CLK_I),
		.pixel_strobe(1'b1),
		.reset(RST_I),
		.mode(mode),
		.hsync(hsync),
		.vsync(vsync),
		.x(x),
		.y(y),
		.active(active),
		.blanking(blanking)
	);


	localparam SCREEN_WIDTH = 640;
	localparam SCREEN_HEIGHT = 480;
	localparam TEXT_WIDTH = SCREEN_WIDTH / 8;
	localparam TEXT_HEIGHT = SCREEN_HEIGHT / 8;
	localparam TEXT_ADDRESS_WIDTH = 13;
	localparam TEXT_DATA_DEPTH = TEXT_WIDTH * TEXT_HEIGHT;
	localparam TEXT_DATA_WIDTH = 8;
	localparam TEXT_COLOUR_DEPTH = TEXT_WIDTH * TEXT_HEIGHT;
	localparam TEXT_COLOUR_WIDTH = 8;



	reg [TEXT_DATA_WIDTH-1:0] text_data_out;
	reg [TEXT_COLOUR_WIDTH-1:0] text_colour_out;
	wire [3:0] pixel_out;


	reg [TEXT_DATA_WIDTH-1:0] text_data_memory [0:TEXT_DATA_DEPTH-1];
	reg [TEXT_COLOUR_WIDTH-1:0] text_colour_memory [0:TEXT_COLOUR_DEPTH-1];

    integer i;
	initial begin
	    for (i=0; i < TEXT_DATA_DEPTH; i=i+1) begin
            text_data_memory[i]= 8'h00;
        end
        
        for (i=0; i < TEXT_COLOUR_DEPTH; i=i+1) begin
            text_colour_memory[i]= 8'hF0;
        end
        
        interrupt_enable = 0;
        interrupt_latched = 0;
	end


	text_pixel #(
		.TEXT_DATA_WIDTH(TEXT_DATA_WIDTH),
		.TEXT_COLOUR_WIDTH(TEXT_COLOUR_WIDTH)
	)
	text_pixel (
        .clk(CLK_I),
        .x(x),
        .y(y),
        .text_data(text_data_out),
        .text_colour(text_colour_out),
        .pixel(pixel_out)
	);


	reg [11:0] palette [0:15];
	reg [11:0] colour;

	initial begin
		$display("Loading VGA colour palette");
		$readmemh("vga_colour_palette.mem", palette);
	end


	always @(posedge CLK_I) begin
	   $display("Blanking: %b", blanking);
	   $display("Active: %b", active);
	   
	   if (RST_I) begin
	       interrupt_enable <= 0;
           interrupt_latched <= 0;
	   end
	   

	    if((blanking == 1'b1) && (interrupt_enable == 1'b1)) begin
	       interrupt_enable <= 0;
	       interrupt_latched <= 1;
        end
	

		text_data_out <= text_data_memory[((y>>3) * TEXT_WIDTH) + (x>>3)];
		text_colour_out <= text_colour_memory[((y>>3) * TEXT_WIDTH) + (x>>3)];

		if (active) begin
			colour <= palette[pixel_out];
		end
		else begin
			colour <= 0;
		end

		red <= colour[11:8];
		green <= colour[7:4];
		blue <= colour[3:0];


		if (STB_I) begin
			if (WE_I) begin
				if(ADR_I[13:0] < TEXT_DATA_DEPTH) begin
				    text_data_memory[ADR_I[13:0]] <= DAT_I;
				    $display("Writing to text data memory");
				end
                else if(ADR_I[13:0] < (TEXT_DATA_DEPTH + TEXT_COLOUR_DEPTH)) begin
					text_colour_memory[ADR_I[13:0] - TEXT_DATA_DEPTH] <= DAT_I;
					$display("Writing to text colour memory");
				end
				else if(ADR_I[13:0] == (TEXT_DATA_DEPTH + TEXT_COLOUR_DEPTH)) begin
                    $display("Enable interrupt");
                    interrupt_enable <= 1;
                end
                else if(ADR_I[13:0] == (TEXT_DATA_DEPTH + TEXT_COLOUR_DEPTH + 1)) begin
                    $display("Disable interrupt");
                    interrupt_enable <= 0;
                end
                else if(ADR_I[13:0] == (TEXT_DATA_DEPTH + TEXT_COLOUR_DEPTH + 2)) begin
                    $display("Clearing interrupt");
                    interrupt_latched <= 0;
                end        
			end
		end
	end
endmodule
module vga_wishbone #(parameter TEXT_DATA_MEMFILE="", TEXT_COLOUR_MEMFILE="")
    (

	input wire CLK_I,
	input wire RST_I,
	input wire STB_I,
    input wire WE_I,
	input wire [31:0] ADR_I,
	input wire [31:0] DAT_I,
	output wire INT_O,


	input wire mode,
	output wire hsync,
	output wire vsync,
	output reg [3:0] red,
	output reg [3:0] green,
	output reg [3:0] blue
    );

    








	wire [9:0] x;
	wire [8:0] y;


	wire active;
	wire blanking;
		

    reg interrupt_latched;
    reg interrupt_enable;  
          
    assign INT_O = interrupt_latched;


	vga_generator display_vga(
		.clk(CLK_I),
		.pixel_strobe(1'b1),
		.reset(RST_I),
		.mode(mode),
		.hsync(hsync),
		.vsync(vsync),
		.x(x),
		.y(y),
		.active(active),
		.blanking(blanking)
	);


	localparam SCREEN_WIDTH = 640;
	localparam SCREEN_HEIGHT = 480;
	localparam TEXT_WIDTH = SCREEN_WIDTH / 8;
	localparam TEXT_HEIGHT = SCREEN_HEIGHT / 8;
	localparam TEXT_ADDRESS_WIDTH = 13;
	localparam TEXT_DATA_DEPTH = TEXT_WIDTH * TEXT_HEIGHT;
	localparam TEXT_DATA_WIDTH = 8;
	localparam TEXT_COLOUR_DEPTH = TEXT_WIDTH * TEXT_HEIGHT;
	localparam TEXT_COLOUR_WIDTH = 8;



	reg [TEXT_DATA_WIDTH-1:0] text_data_out;
	reg [TEXT_COLOUR_WIDTH-1:0] text_colour_out;
	wire [3:0] pixel_out;


	reg [TEXT_DATA_WIDTH-1:0] text_data_memory [0:TEXT_DATA_DEPTH-1];
	reg [TEXT_COLOUR_WIDTH-1:0] text_colour_memory [0:TEXT_COLOUR_DEPTH-1];

    integer i;
	initial begin
	    for (i=0; i < TEXT_DATA_DEPTH; i=i+1) begin
            text_data_memory[i]= 8'h00;
        end
        
        for (i=0; i < TEXT_COLOUR_DEPTH; i=i+1) begin
            text_colour_memory[i]= 8'hF0;
        end
        
        interrupt_enable = 0;
        interrupt_latched = 0;
	end


	text_pixel #(
		.TEXT_DATA_WIDTH(TEXT_DATA_WIDTH),
		.TEXT_COLOUR_WIDTH(TEXT_COLOUR_WIDTH)
	)
	text_pixel (
        .clk(CLK_I),
        .x(x),
        .y(y),
        .text_data(text_data_out),
        .text_colour(text_colour_out),
        .pixel(pixel_out)
	);


	reg [11:0] palette [0:15];
	reg [11:0] colour;

	initial begin
		$display("Loading VGA colour palette");
		$readmemh("vga_colour_palette.mem", palette);
	end


	always @(posedge CLK_I) begin
	   $display("Blanking: %b", blanking);
	   $display("Active: %b", active);
	   
	   if (RST_I) begin
	       interrupt_enable <= 0;
           interrupt_latched <= 0;
	   end
	   

	    if((blanking == 1'b1) && (interrupt_enable == 1'b1)) begin
	       interrupt_enable <= 0;
	       interrupt_latched <= 1;
        end
	

		text_data_out <= text_data_memory[((y>>3) * TEXT_WIDTH) + (x>>3)];
		text_colour_out <= text_colour_memory[((y>>3) * TEXT_WIDTH) + (x>>3)];

		if (active) begin
			colour <= palette[pixel_out];
		end
		else begin
			colour <= 0;
		end

		red <= colour[11:8];
		green <= colour[7:4];
		blue <= colour[3:0];


		if (STB_I) begin
			if (WE_I) begin
				if(ADR_I[13:0] < TEXT_DATA_DEPTH) begin
				    text_data_memory[ADR_I[13:0]] <= DAT_I;
				    $display("Writing to text data memory");
				end
                else if(ADR_I[13:0] < (TEXT_DATA_DEPTH + TEXT_COLOUR_DEPTH)) begin
					text_colour_memory[ADR_I[13:0] - TEXT_DATA_DEPTH] <= DAT_I;
					$display("Writing to text colour memory");
				end
				else if(ADR_I[13:0] == (TEXT_DATA_DEPTH + TEXT_COLOUR_DEPTH)) begin
                    $display("Enable interrupt");
                    interrupt_enable <= 1;
                end
                else if(ADR_I[13:0] == (TEXT_DATA_DEPTH + TEXT_COLOUR_DEPTH + 1)) begin
                    $display("Disable interrupt");
                    interrupt_enable <= 0;
                end
                else if(ADR_I[13:0] == (TEXT_DATA_DEPTH + TEXT_COLOUR_DEPTH + 2)) begin
                    $display("Clearing interrupt");
                    interrupt_latched <= 0;
                end        
			end
		end
	end
endmodule