/* * Top Level FPGA Module * * by Brendan Doms, Sean McBride, Brian Shih, and Mikell Taylor * (Olin College - Computer Architecture - Fall 2005) * */ // Top level of what's inside our VGA on the spartan `include "hardware_sprite.v" `include "vga.v" module FPGA (Clk50, Reset, buttonUP, buttonDOWN, buttonLEFT, buttonRIGHT, R, G, B, HSync, VSync); input Clk50, Reset, buttonUP, buttonDOWN, buttonLEFT, buttonRIGHT; output R, G, B, HSync, VSync; reg [9:0] posx, posx1, posx2, posx3, posx4; reg [8:0] posy, posy1, posy2, posy3, posy4; reg [18:0] movecounter; wire PClk, Row0, Col0, Active, A; wire [9:0] Col; wire [8:0] Row; // VGA timing module vga vga0( Reset, VSync, HSync, Clk50, PClk, Row, Col, Row0, Col0, Active ); // User controlled sprite wire R0, G0, B0, A0, tR0, tG0, tB0; video_selector vs0 (R, G, B, tR0, tG0, tB0, R0, G0, B0, A0); hardware_sprite hwsp0 (Reset, R0, G0, B0, A0, Clk50, PClk, Row, Col, Active, posx, posy, 0, 0, 0); // "Computer" controlled sprite wire R1, G1, B1, A1, tR1, tG1, tB1; video_selector vs1 (tR0, tG0, tB0, tR1, tG1, tB1, R1, G1, B1, A1); hardware_sprite hwsp1 (Reset, R1, G1, B1, A1, Clk50, PClk, Row, Col, Active, posx1, posy1, 0, 0, 1); wire R2, G2, B2, A2, tR2, tG2, tB2; video_selector vs2 (tR1, tG1, tB1, tR2, tG2, tB2, R2, G2, B2, A2); hardware_sprite hwsp2 (Reset, R2, G2, B2, A2, Clk50, PClk, Row, Col, Active, posx2, posy2, 0, 0, 1); wire R3, G3, B3, A3, tR3, tG3, tB3; video_selector vs3 (tR2, tG2, tB2, tR3, tG3, tB3, R3, G3, B3, A3); hardware_sprite hwsp3 (Reset, R3, G3, B3, A3, Clk50, PClk, Row, Col, Active, posx3, posy3, 0, 0, 1); wire R4, G4, B4, A4; video_selector vs4 (tR3, tG3, tB3, 0, 0, 0, R4, G4, B4, A4); hardware_sprite hwsp4 (Reset, R4, G4, B4, A4, Clk50, PClk, Row, Col, Active, posx4, posy4, 0, 0, 1); always @(posedge Clk50) begin if (Reset) begin // Initialize Values posx = 10'd320; posy = 9'd240; posx1 = 10'd50; posy1 = 9'd50; posx2 = 10'd590; posy2 = 9'd430; posx3 = 10'd50; posy3 = 9'd430; posx4 = 10'd590; posy4 = 9'd50; end else begin movecounter = movecounter + 1; if (movecounter == 0) begin if (buttonUP) posy = posy - 4; if (buttonDOWN) posy = posy + 4; if (buttonLEFT) posx = posx - 4; if (buttonRIGHT) posx = posx + 4; // Make ghosts chase you if (posx1 > posx) posx1 = posx1 - 3; if (posx1 < posx) posx1 = posx1 + 3; if (posy1 > posy) posy1 = posy1 - 3; if (posy1 < posy) posy1 = posy1 + 3; if (posx2 > posx) posx2 = posx2 - 2; if (posx2< posx) posx2 = posx2 + 2; if (posy2 > posy) posy2 = posy2 - 2; if (posy2 < posy) posy2 = posy2 + 2; if (posx3 > posx) posx3 = posx3 - 1; if (posx3 < posx) posx3 = posx3 + 1; if (posy3 > posy) posy3 = posy3 - 1; if (posy3 < posy) posy3 = posy3 + 1; if (posx4 > posx) posx4 = posx4 - 2; if (posx4 < posx) posx4 = posx4 + 1; if (posy4 > posy) posy4 = posy4 - 3; if (posy4 < posy) posy4 = posy4 + 1; end end end endmodule