//Final projecet bomes and love for muffins. // I = posx) && (col < posx + WIDTH) && (row >= posy) && (row < posy + HEIGHT)); and a0 (R, sR, drawing); and a1 (G, sG, drawing); and a2 (B, sB, drawing); and a3 (A, sA, drawing); // Initialize values always @(posedge clk) begin if (Reset) begin // Initialize things shapecounter = 0; if (color) shape = 2; else shape = 0; end end always @(posedge pclk) begin xcoord = col-posx; ycoord = row-posy; // Change the shape shapecounter = shapecounter + 1; if (shapecounter == 0) begin if (shape == 0) shape = 3'd1; else if (shape == 1) shape = 3'd0; else if (shape == 2) shape = 3'd3; else if (shape == 3) shape = 3'd2; end end endmodule // 16x16 sprite memory, has 6 shapes saved module sprite_memory(Reset, R, G, B, A, clk, pclk, xcoord, ycoord, shape); input [3:0] xcoord, ycoord; input [2:0] shape; input clk, pclk, Reset; output R, G, B, A; reg R, G, B, A; reg [63:0] shaperow; // Sprite Shape 1 (Red Ghost 1) reg [63:0] shape1mem[15:0]; // Sprite Shape 2 (Red Ghost 2) reg [63:0] shape2mem[15:0]; // Sprite Shape 3 (Cyan Ghost 1) reg [63:0] shape3mem[15:0]; // Sprite Shape 4 (Cyan Ghost 2) reg [63:0] shape4mem[15:0]; // Initialize always @(posedge clk) begin if (Reset) begin // Initialize shape 1 shape1mem[0] = 64'b0000000000000000100110011001100110011001100110010000000000000000; shape1mem[1] = 64'b0000000000001001100110011001100110011001100110011001000000000000; shape1mem[2] = 64'b0000000010011001100110011001100110011001100110011001100100000000; shape1mem[3] = 64'b0000100110011001111111111001100110011001111111111001100110010000; shape1mem[4] = 64'b1001100110011111111111111111100110011111111111111111100110011001; shape1mem[5] = 64'b1001100110011111001111111111100110011111001111111111100110011001; shape1mem[6] = 64'b1001100110011111001111111111100110011111001111111111100110011001; shape1mem[7] = 64'b1001100110011001001111111001100110011001001111111001100110011001; shape1mem[8] = 64'b1001100110011001100110011001100110011001100110011001100110011001; shape1mem[9] = 64'b1001100110011001100110011001100110011001100110011001100110011001; shape1mem[10] = 64'b1001100110011001100110011001100110011001100110011001100110011001; shape1mem[11] = 64'b1001100110011001100110011001100110011001100110011001100110011001; shape1mem[12] = 64'b1001100110011001100110011001100110011001100110011001100110011001; shape1mem[13] = 64'b1001100110010000100110011001100110010000100110011001100110010000; shape1mem[14] = 64'b1001100100000000000010011001100100000000000010011001100100000000; shape1mem[15] = 64'b1001000000000000000000001001000000000000000000001001000000000000; // Initialize shape 2 shape2mem[0] = 64'b0000000000000000100110011001100110011001100110010000000000000000; shape2mem[1] = 64'b0000000000001001100110011001100110011001100110011001000000000000; shape2mem[2] = 64'b0000000010011001100110011001100110011001100110011001100100000000; shape2mem[3] = 64'b0000100110011001111111111001100110011001111111111001100110010000; shape2mem[4] = 64'b1001100110011111111111111111100110011111111111111111100110011001; shape2mem[5] = 64'b1001100110011111001111111111100110011111001111111111100110011001; shape2mem[6] = 64'b1001100110011111001111111111100110011111001111111111100110011001; shape2mem[7] = 64'b1001100110011001001111111001100110011001001111111001100110011001; shape2mem[8] = 64'b1001100110011001100110011001100110011001100110011001100110011001; shape2mem[9] = 64'b1001100110011001100110011001100110011001100110011001100110011001; shape2mem[10] = 64'b1001100110011001100110011001100110011001100110011001100110011001; shape2mem[11] = 64'b1001100110011001100110011001100110011001100110011001100110011001; shape2mem[12] = 64'b1001100110011001100110011001100110011001100110011001100110011001; shape2mem[13] = 64'b0000100110011001100110010000100110011001100110010000100110011001; shape2mem[14] = 64'b0000000010011001100100000000000010011001100100000000000010011001; shape2mem[15] = 64'b0000000000001001000000000000000000001001000000000000000000001001; // Initialize shape 3 shape3mem[0] = 64'b0000000000000000011101110111011101110111011101110000000000000000; shape3mem[1] = 64'b0000000000000111011101110111011101110111011101110111000000000000; shape3mem[2] = 64'b0000000001110111011101110111011101110111011101110111011100000000; shape3mem[3] = 64'b0000011101110111111111110111011101110111111111110111011101110000; shape3mem[4] = 64'b0111011101111111111111111111011101111111111111111111011101110111; shape3mem[5] = 64'b0111011101111111001111111111011101111111001111111111011101110111; shape3mem[6] = 64'b0111011101111111001111111111011101111111001111111111011101110111; shape3mem[7] = 64'b0111011101110111001111110111011101110111001111110111011101110111; shape3mem[8] = 64'b0111011101110111011101110111011101110111011101110111011101110111; shape3mem[9] = 64'b0111011101110111011101110111011101110111011101110111011101110111; shape3mem[10] = 64'b0111011101110111011101110111011101110111011101110111011101110111; shape3mem[11] = 64'b0111011101110111011101110111011101110111011101110111011101110111; shape3mem[12] = 64'b0111011101110111011101110111011101110111011101110111011101110111; shape3mem[13] = 64'b0111011101110000011101110111011101110000011101110111011101110000; shape3mem[14] = 64'b0111011100000000000001110111011100000000000001110111011100000000; shape3mem[15] = 64'b0111000000000000000000000111000000000000000000000111000000000000; // Initialize shape 4 shape4mem[0] = 64'b0000000000000000011101110111011101110111011101110000000000000000; shape4mem[1] = 64'b0000000000000111011101110111011101110111011101110111000000000000; shape4mem[2] = 64'b0000000001110111011101110111011101110111011101110111011100000000; shape4mem[3] = 64'b0000011101110111111111110111011101110111111111110111011101110000; shape4mem[4] = 64'b0111011101111111111111111111011101111111111111111111011101110111; shape4mem[5] = 64'b0111011101111111001111111111011101111111001111111111011101110111; shape4mem[6] = 64'b0111011101111111001111111111011101111111001111111111011101110111; shape4mem[7] = 64'b0111011101110111001111110111011101110111001111110111011101110111; shape4mem[8] = 64'b0111011101110111011101110111011101110111011101110111011101110111; shape4mem[9] = 64'b0111011101110111011101110111011101110111011101110111011101110111; shape4mem[10] = 64'b0111011101110111011101110111011101110111011101110111011101110111; shape4mem[11] = 64'b0111011101110111011101110111011101110111011101110111011101110111; shape4mem[12] = 64'b0111011101110111011101110111011101110111011101110111011101110111; shape4mem[13] = 64'b0000011101110111011101110000011101110111011101110000011101110111; shape4mem[14] = 64'b0000000001110111011100000000000001110111011100000000000001110111; shape4mem[15] = 64'b0000000000000111000000000000000000000111000000000000000000000111; end end // Assign signals to proper outputs always @(posedge pclk) begin if (shape == 0) shaperow = shape1mem[ycoord]; if (shape == 1) shaperow = shape2mem[ycoord]; if (shape == 2) shaperow = shape3mem[ycoord]; if (shape == 3) shaperow = shape4mem[ycoord]; R = shaperow[(xcoord*4)+3]; G = shaperow[(xcoord*4)+2]; B = shaperow[(xcoord*4)+1]; A = shaperow[xcoord*4]; end endmodule