My title page contents

VGA吃豆人游戏+Verilog+TD

名称:VGA吃豆人游戏+Verilog+TD

软件:TD

语言:Verilog

 

代码功能:

---实现经典吃豆人游戏

演示视频:


项目相关图片预览

---

代码实现思路

本项目采用模块化设计,顶层模块负责各子模块的连接与时序同步。时钟分频模块生成VGA和游戏逻辑所需时钟,按键消抖模块确保玩家输入稳定,IO模块解析方向控制。画面控制模块根据吃豆人和鬼怪的位置动态生成VGA显示信号,得分统计模块实时更新分数。各模块通过信号线协同工作,实现游戏逻辑与硬件显示的高效结合。整体设计突出FPGA并行处理优势,保证游戏流畅运行。

---

代码结构

clk_wizard

io

picture_ctrl

ssd_controller

vga_driver

food/ghost/player/rectangle等

---

部分代码预览


//顶层模块 pacman.v 前100行
module pacman(CLOCK, btn_up, btn_down, btn_left, btn_right, bit_sel, segment, V_sync, H_sync, RGB_red, RGB_blue, RGB_green);
   input        CLOCK;
   //input        RESET;
   input        btn_up;
   input        btn_down;
   input        btn_left;
   input        btn_right;
   
   output [3:0] bit_sel;
   output [7:0] segment;
 
   output       V_sync;
   output       H_sync;
   output [3:0] RGB_red;
   output [3:0] RGB_blue;
   output [3:0] RGB_green;
   
   
   parameter    c_CLOCK_FREQ = 40_000_000;
   
   wire         s_GameClock;
   
   wire         s_VGAClock;
   wire         s_Locked;
   wire         s_Reset;
   
   wire [2:0]   s_Color;
   wire [15:0]  s_Score;
   
   wire [31:0]  s_HPos;
   wire [31:0]  s_VPos;
   
   wire         s_Move;
   wire [3:0]   s_Direction;
   

  clk_wizard clock_wizard(
     .clk0_out(s_VGAClock),
     .reset(1'b0),
     .extlock(s_Locked),
     .refclk(CLOCK)
  );

   
   assign s_Reset = (~s_Locked);
   

   picture_ctrl U_controller(
      .pic_clk(s_VGAClock),
      .p_GameClock(s_GameClock),
      .p_Reset(s_Reset),
      .x_pix(s_HPos),
      .y_pix(s_VPos),
      .pic_dir(s_Direction),
      .pic_move(s_Move),
      .pic_rgb(s_Color),
      .dis_score(s_Score)
   );
   
   
   ssd_controller #(c_CLOCK_FREQ) U_seg(
      .p_Reset(s_Reset),
      .pic_clk(s_VGAClock),
      .p_Data(s_Score),
      .o_bit_sel(bit_sel),
      .o_segment(segment)
   );
   
 
   io U_btn(
      .pic_clk(s_VGAClock),
      .p_Reset(s_Reset),
      .btn_up(btn_up),
      .btn_down(btn_down),
      .btn_left(btn_left),
      .btn_right(btn_right),
      .o_Clock(s_GameClock),
      .o_Move(s_Move),
      .o_Direction(s_Direction)
   );
   

   vga_driver U_vga(
      .pic_clk(s_VGAClock),
      .p_Reset(s_Reset),
      .p_Color(s_Color),
      .H_position(s_HPos),
      .V_position(s_VPos),
      .VGA_hsync_o(H_sync),
      .VGA_vsync_o(V_sync),
      .VGA_R(RGB_red),
      .VGA_G(RGB_green),
      .VGA_B(RGB_blue)
   );

endmodule


 代码下载(付费后可见):




1、代码文件需要付费后才可见。
2、支付问题请联系微信公众号客服。
3、优质Verilog/VHDL代码资源,所见即所得。
Verilog/VHDL资源下载 » VGA吃豆人游戏+Verilog+TD

发表评论

模板文件不存在: ./template/plugins/comment/pc/index.htm

注册为本站会员,充值100得150,详情咨询客服

目前为止共有 *** 位优秀的会员加入! 立刻加入会员