日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【Verilog】马里奥小游戏的FPGA实现

發布時間:2024/1/8 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Verilog】马里奥小游戏的FPGA实现 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

經典馬里奧小游戲的FPGA實現


新年好!祝各位朋友新年快樂!!健康平安!!!
代碼有部分刪減,不影響理解。


  • 演示視頻.
  • 具體過程:
    • 按下十字按鍵的中央按鍵開始游戲。
    • 碰到柱子邊界游戲結束。
    • 累計平安通過一定數量的柱子障礙,獲得積分獎勵,
    • 可選擇繼續游戲,失敗則成績全部清零;或直接結束游戲,并存檔游戲進度。
  • 原理:VGA顯示、基本邏輯約束
  • 目的:分享、學習、成長、感謝。

具體代碼片段:

`timescale 1ns / 1ps //阿汪先生的博客 module project_all(clk,disp_rgb,hsync,vsync,btn_up,btn_down,btn_left,btn_right,rst,btn_start); input clk,rst; input btn_up,btn_down,btn_left,btn_right,btn_start; output[11:0] disp_rgb; output hsync,vsync;reg[9:0] hcount; reg[9:0] vcount; reg[11:0] data; reg[11:0] data0; reg[11:0] data1; reg[11:0] data2; reg[11:0] data3; reg[1:0] flag=0; wire hcount_ov; wire vcount_ov; wire dat_act; wire hsync; wire vsync; reg vga_clk=0; reg cnt_clk=0; reg[11:0] hd_dat; reg[11:0] a=0; reg[11:0] b=0,c=0,d=0,e=0,f=0,g=0,h=0,e1=0,e2=0,e3=0,e4=0,e5=0,e6=0; reg[11:0] x1=0,xr1=0,x2=0,xr2=0,xr3=0,xr4=0,xr5=0,xr6=0; reg[31:0] rand1=32'b11001011010011010110101101100101; reg[31:0] rand2=32'b10100110010101010010110101010110; reg[7:0] count=0; reg out_sig=1'b0; reg [7:0] cnt; //VGA行,場掃描時序參數表 parameter hsync_end = 10'd95, hdat_begin = 10'd143, hdat_end = 10'd783, hpixel_end = 10'd799, vsync_end = 10'd1, vdat_begin = 10'd34, vdat_end = 10'd514, vline_end = 10'd524, fk_top = 10'd173, fk_bottom = 10'd198, fk_leftside= 10'd759, fk_rightside=10'd784, fk_speed = 10'd3; //速度控制always@(posedge clk) beginif(cnt_clk == 1)beginvga_clk <= ~vga_clk;cnt_clk <= 0;endelsecnt_clk <= cnt_clk + 1; end /**********VGA驅動**********/ //行掃描 always@(posedge vga_clk) beginif(hcount_ov)hcount <= 10'd0;elsehcount <= hcount + 10'd1; end assign hcount_ov = (hcount == hpixel_end);//場掃描 always@(posedge vga_clk) beginif(hcount_ov)beginif(vcount_ov)vcount <= 10'd0;elsevcount <= vcount + 10'd1;end end assign vcount_ov = (vcount == vline_end);//數據、同步信號輸入 assign dat_act = ((hcount >= hdat_begin) && (hcount < hdat_end)) && ((vcount > vdat_begin) && (vcount<vdat_end)); assign hsync = (hcount > hsync_end); assign vsync = (vcount > vsync_end); assign disp_rgb = (dat_act)?data:3'h00; //偽隨機數 always@(posedge vga_clk) beginif(e1==0)beginx1 <= rand1 % (4'd7);if(rand1==0)rand1 <= 32'b11001011010011010110101101100101; //每次左移數據后再取余,實現偽隨機數elserand1 <= rand1 << 1; endelsex1<=x1;xr1 <= x1 * 5'd20; //120 endalways@(posedge vga_clk) beginif(e2==0)beginx2 <= rand2 % (4'd7);if(rand2==0)rand2 <= 32'b10100110010101010010110101010110;elserand2 <= rand2 << 1; endelsex2<=x2;xr2 <= x2 * 5'd20; //120endalways@(posedge vga_clk) beginif(e3==0)xr3 <= xr1+xr2; //240elsexr3<=xr3; endalways@(posedge vga_clk) begin if(e4==0)xr4 <= xr1 + xr2 /2'd2; //180elsexr4 <= xr4; endalways@(posedge vga_clk) begin if(e5==0)xr5 <= xr2 + xr1 / 2'd2; //180elsexr5 <= xr5; endalways@(posedge vga_clk) begin if(e6==0)xr6 <= xr2 ; //120elsexr6 <= xr6; end//開始和內容切換 always @ (posedge vga_clk) beginif(!rst)begindata =data0;end elsebegin case(flag)2'd0: data =data0;2'd1: data =data1;2'd2: data =data2;2'd3: data =data3;endcaseend end //控制 always@(posedge vcount_ov) beginif(btn_start)flag=1;elseflag=flag;//馬里奧移動方向的控制 if(flag == 1) begin //方塊上移 if(btn_up && (fk_top-a+c)>=40) a = a+fk_speed; elsea=a;//方塊下移 if(btn_down && (fk_bottom-a+c) <= 510)c = c+fk_speed;elsec=c;//左移 if(btn_left && (fk_leftside -b+d)>=144) b=b+fk_speed;elseb=b; //右移 if(btn_right && (fk_rightside-b+d)<=784)d=d+fk_speed;elsed=d;//柱子移動 //a柱if(e1<=644)e1=e1+1;elsee1=0;//b柱 if( (e1>=110) || (e2>0) )e2=e2+1;elsee2=0;if(e2 == 644)e2=0;elsee2=e2; //為避免篇幅過長,省略c、d、e、f柱子的移動代碼//柱子右邊界 //a if((fk_leftside-b+d) >= (136+e1) && (fk_leftside-b+d) <= (140+e1) && (fk_top-a+c) <= (300-xr1)) //上begincount =0;a=0;b=0;c=0;d=0;e1=0;e2=0;e3=0;e4=0;e5=0;e6=0;flag = 2;endelsebegincount =count;a=a;b=b;c=c;d=d;e1=e1;e2=e2;e3=e3;e4=e4;e5=e5;e6=e6;end //b if( (fk_leftside-b+d) >= (136+e2) && (fk_leftside-b+d) <= (140+e2) && (fk_bottom-a+c) >= (200+xr2)) //下begincount =0;a=0;b=0;c=0;d=0;e1=0;e2=0;e3=0;e4=0;e5=0;e6=0;flag = 2;endelsebegincount =count;a=a;b=b;c=c;d=d;e1=e1;e2=e2;e3=e3;e4=e4;e5=e5;e6=e6;end //為避免篇幅過長,省略c、d、e、f柱子的右邊界的代碼//柱子下邊界 //a if( (fk_top-a+c) >= (296-xr1) && (fk_top-a+c) <= (300-xr1) && (fk_leftside-b+d) < (140+e1) && (fk_rightside-b+d) > (119+e1)) //上begincount =0;a=0;b=0;c=0;d=0;e1=0;e2=0;e3=0;e4=0;e5=0;e6=0;flag = 2;endelsebegincount =count;a=a;b=b;c=c;d=d;e1=e1;e2=e2;e3=e3;e4=e4;e5=e5;e6=e6; end //為避免篇幅過長,省略c、d、e、f柱子的下邊界代碼//柱子上邊界 //bif( (fk_bottom-a+c) >= (200+xr2) && (fk_bottom-a+c) <= (204+xr2) && (fk_leftside-b+d) < (140+e2) && (fk_rightside-b+d) > (119+e2)) //下begincount =0;a=0;b=0;c=0;d=0;e1=0;e2=0;e3=0;e4=0;e5=0;e6=0;flag = 2;endelsebegincount =count;a=a;b=b;c=c;d=d;e1=e1;e2=e2;e3=e3;e4=e4;e5=e5;e6=e6; end //dif( (fk_bottom-a+c) >= (240+xr4) && (fk_bottom-a+c) <= (244+xr4) && (fk_leftside-b+d) < (140+e4) && (fk_rightside-b+d) > (119+e4)) //下begincount =0;a=0;b=0;c=0;d=0;e1=0;e2=0;e3=0;e4=0;e5=0;e6=0;flag = 2;endelsebegincount =count;a=a;b=b;c=c;d=d;e1=e1;e2=e2;e3=e3;e4=e4;e5=e5;e6=e6; end //eif( (fk_bottom-a+c) >= (200+xr5) && (fk_bottom-a+c) <= (204+xr5) && (fk_leftside-b+d) < (140+e5) && (fk_rightside-b+d) > (119+e5)) //下begincount =0;a=0;b=0;c=0;d=0;e1=0;e2=0;e3=0;e4=0;e5=0;e6=0;flag = 2;endelsebegincount =count;a=a;b=b;c=c;d=d;e1=e1;e2=e2;e3=e3;e4=e4;e5=e5;e6=e6; end//柱子左邊界 //a if( (fk_rightside-b+d) >= (119+e1) && (fk_rightside-b+d) <= (123+e1) && (fk_top-a+c) <= (300-xr1)) //上begincount =0;a=0;b=0;c=0;d=0;e1=0;e2=0;e3=0;e4=0;e5=0;e6=0;flag=2;endelsebegincount =count;a=a;b=b;c=c;d=d;e1=e1;e2=e2;e3=e3;e4=e4;e5=e5;e6=e6;end //b if( (fk_rightside-b+d) >= (119+e2) && (fk_rightside-b+d) <= (123+e2) && (fk_bottom-a+c) >= (200+xr2)) //下begincount =0;a=0;b=0;c=0;d=0;e1=0;e2=0;e3=0;e4=0;e5=0;e6=0;flag=2;endelsebegina=a;b=b;c=c;d=d;e1=e1;e2=e2;e3=e3;e4=e4;e5=e5;e6=e6;end //為避免篇幅過長,省略c、d、e、f柱子的左邊界代碼//計數 //aif((fk_rightside-b+d) == (119 +e1))begincount=1;end//b else if((fk_rightside-b+d) == (119 +e2))begincount=2;end//c else if((fk_rightside-b+d) == (119 +e3))begincount=3;end//d else if((fk_rightside-b+d) == (119 +e4))begincount=4;end//e else if((fk_rightside-b+d) == (119 +e5))begincount=5;end//f else if((fk_rightside-b+d) <= (119 +e6))begincount=6;endif(count == 6) //達到目標障礙數,進入獎勵結算頁面begina=0;b=0;c=0;d=0;e1=0;e2=0;e3=0;e4=0;e5=0;e6=0;flag = 3;count =0; endelsebegincount =count;a=a;b=b;c=c;d=d;e1=e1;e2=e2;e3=e3;e4=e4;e5=e5;e6=e6;end end elseflag = flag; endalways @ (count) begincnt = count; end //圖像顯示 always @ (posedge vga_clk) begin //柱子 //6根柱子以“上下上下下上”的序列順序出現 //aif(hcount>(119+e1) && hcount < (140+e1 ) && vcount < (300-xr1) && vcount >35 ) //上data1 <= 12'h010;//b else if(hcount>(119+e2) && hcount < (140+e2 ) && vcount > (200+xr2) && vcount <515) //下data1 <= 12'h010;//c else if(hcount>(119+e3) && hcount < (140+e3 ) && vcount < (300-xr3) && vcount > 35) //上data1 <= 12'h010; //d else if(hcount>(119+e4) && hcount < (140+e4 ) && vcount > (240+xr4) && vcount <515) //下data1 <= 12'h010;//eelse if(hcount>(119+e5) && hcount < (140+e5 ) && vcount > (200+xr5) && vcount <515) //下data1 <= 12'h010;//f else if(hcount>(119+e6) && hcount < (140+e6 ) && vcount < (300-xr6) && vcount > 35) //上data1 <= 12'h010; //馬里奧 //圖片不同顏色區域分別賦值 //1else if(hcount >= (768-b+d) && hcount <= (773-b+d) && vcount >= (173-a+c) && vcount <=(174-a+c))data1 <= 12'hf00;//2else if(hcount >= (764-b+d) && hcount <= (773-b+d) && vcount >( 174-a+c) && vcount <=(175-a+c))data1 <= 12'hf00; //3else if(hcount >= (764-b+d) && hcount <= (773-b+d) && vcount > (175-a+c) && vcount <=(176-a+c))data1 <= 12'hf00;//4else if(hcount > (767-b+d) && hcount <=( 768-b+d) && vcount > (176-a+c) && vcount <=(177-a+c))data1 <= 12'h68b;else if(hcount > (768-b+d) && hcount <= (770-b+d) && vcount > (176-a+c) && vcount <=(177-a+c))data1 <= 12'hffc;else if(hcount > (770-b+d) && hcount <= (773-b+d) && vcount > (176-a+c) && vcount <=(177-a+c))data1 <= 12'h0cd;//5else if(hcount >( 767-b+d) && hcount <= (768-b+d) && vcount > (177-a+c) && vcount <=(178-a+c))data1 <= 12'h68b;else if(hcount > (764-b+d) && hcount <= (767-b+d) && vcount >( 177-a+c) && vcount <=(178-a+c))data1 <= 12'h68b;else if(hcount > (768-b+d) && hcount <= (775-b+d) && vcount > (177-a+c) && vcount <=(178-a+c))data1 <= 12'h0cd;else if(hcount > (775-b+d) && hcount <=( 777-b+d) && vcount > (177-a+c) && vcount <=(178-a+c))data1 <= 12'h0cd;//6else if(hcount > (762-b+d) && hcount <= (775-b+d) && vcount > (178-a+c) && vcount <=(179-a+c))data1 <= 12'hffc;else if(hcount >( 775-b+d) && hcount <= (777-b+d) && vcount >( 178-a+c) && vcount <=(179-a+c))data1 <= 12'h0cd;//7else if(hcount > (762-b+d) && hcount <= (766-b+d) && vcount >( 179-a+c) && vcount <=(180-a+c))data1 <= 12'hffc;else if(hcount > (766-b+d) && hcount <= (767-b+d) && vcount > (179-a+c) && vcount <=(180-a+c))data1 <= 12'h0cd; else if(hcount > (767-b+d) && hcount <= (773-b+d) && vcount >( 179-a+c) && vcount <=(180-a+c))data1 <= 12'hffc;else if(hcount > (773-b+d) && hcount <= (777-b+d) && vcount > (179-a+c) && vcount <=(180-a+c))data1 <= 12'h0cd;//8else if(hcount > (764-b+d) && hcount <= (767-b+d) && vcount > (180-a+c) && vcount <=(181-a+c))data1 <= 12'h0cd;else if(hcount > (767-b+d) && hcount <= (773-b+d) && vcount > (180-a+c) && vcount <=(181-a+c))data1 <= 12'hffc;//9else if(hcount > (765-b+d) && hcount <= (774-b+d) && vcount > (181-a+c) && vcount <=(182-a+c))data1 <= 12'h0cd;//10else if(hcount > (767-b+d) && hcount <= (773-b+d) && vcount > (182-a+c) && vcount <=(183-a+c))data1 <= 12'h0cd;//11else if(hcount > (766-b+d) && hcount <= (774-b+d) && vcount > (183-a+c) && vcount <=(184-a+c))data1 <= 12'hf00;//12else if(hcount > (764-b+d) && hcount <= (776-b+d) && vcount > (184-a+c) && vcount <=(185-a+c))data1 <= 12'hf00; //13else if(hcount > (763-b+d) && hcount <= (772-b+d) && vcount > (185-a+c) && vcount <=(186-a+c))data1 <= 12'hf00; else if(hcount >( 772-b+d) && hcount <=( 774-b+d) && vcount >( 185-a+c) && vcount <=(186-a+c))data1 <= 12'h00f;else if(hcount > (774-b+d) && hcount <= (778-b+d) && vcount > (185-a+c) && vcount <=(186-a+c))data1 <= 12'hf00; //14else if(hcount > (761-b+d) && hcount <= (766-b+d) && vcount >( 186-a+c) && vcount <=(187-a+c))data1 <= 12'hf00; else if(hcount > (766-b+d) && hcount <= (768-b+d) && vcount > (186-a+c) && vcount <=(187-a+c))data1 <= 12'h00f;else if(hcount > (768-b+d) && hcount <= (772-b+d) && vcount >( 186-a+c) && vcount <=(187-a+c))data1 <= 12'hf00; else if(hcount > (772-b+d) && hcount <= (774-b+d) && vcount > (186-a+c) && vcount <=(187-a+c))data1 <= 12'h00f;else if(hcount > (774-b+d) && hcount <= (781-b+d) && vcount > (186-a+c) && vcount <=(187-a+c))data1 <= 12'hf00; //15else if(hcount > (760-b+d) && hcount <= (766-b+d) && vcount > (187-a+c) && vcount <=(188-a+c))data1 <= 12'hf00;else if(hcount > (766-b+d) && hcount <= (768-b+d) && vcount > (187-a+c) && vcount <=(188-a+c))data1 <= 12'h00f;else if(hcount > (768-b+d) && hcount <= (772-b+d) && vcount > (187-a+c) && vcount <=(188-a+c))data1 <= 12'hf00; else if(hcount > (772-b+d) && hcount <= (774-b+d) && vcount > (187-a+c) && vcount <=(188-a+c))data1 <= 12'h00f;else if(hcount > (774-b+d) && hcount <= (783-b+d) && vcount > (187-a+c) && vcount <=(188-a+c))data1 <= 12'hf00; //16else if(hcount > (759-b+d) && hcount <= (764-b+d) && vcount > (188-a+c) && vcount <=(189-a+c))data1 <= 12'hf00; else if(hcount > (764-b+d) && hcount <= (766-b+d) && vcount >( 188-a+c) && vcount <=(189-a+c))data1 <= 12'hffc;else if(hcount > (766-b+d) && hcount <= (774-b+d) && vcount >( 188-a+c) && vcount <=(189-a+c))data1 <= 12'h00f; else if(hcount > (774-b+d) && hcount <= (776-b+d) && vcount > (188-a+c) && vcount <=(189-a+c))data1 <= 12'hffc; else if(hcount > (776-b+d) && hcount <= (778-b+d) && vcount >( 188-a+c) && vcount <=(189-a+c))data1 <= 12'hf00; else if(hcount > (778-b+d) && hcount < (784-b+d) && vcount > (188-a+c) && vcount <=(189-a+c))data1 <= 12'hffc; //17else if(hcount > (759-b+d) && hcount <= (761-b+d) && vcount > (189-a+c) && vcount <=(190-a+c))data1 <= 12'hffc;else if(hcount > (761-b+d) && hcount <= (762-b+d) && vcount > (189-a+c) && vcount <=(190-a+c))data1 <= 12'hf00;else if(hcount > (762-b+d) && hcount <= (766-b+d) && vcount > (189-a+c) && vcount <=(190-a+c))data1 <= 12'hffc;else if(hcount > (766-b+d) && hcount <= (774-b+d) && vcount > (189-a+c) && vcount <=(190-a+c))data1 <= 12'h00f;else if(hcount > (774-b+d) && hcount < (784-b+d) && vcount > (189-a+c) && vcount <=(190-a+c))data1 <= 12'hffc; //18else if(hcount > (759-b+d) && hcount <= (767-b+d) && vcount > (190-a+c) && vcount <=(191-a+c))data1 <= 12'hffc;else if(hcount > (767-b+d) && hcount <= (773-b+d) && vcount >( 190-a+c) && vcount <=(191-a+c))data1 <= 12'h00f;else if(hcount > (773-b+d) && hcount < (784-b+d) && vcount > (190-a+c) && vcount <=(191-a+c))data1 <= 12'hffc; //19else if(hcount > (759-b+d) && hcount <= (767-b+d) && vcount > (191-a+c) && vcount <=(192-a+c))data1 <= 12'hffc;else if(hcount > (767-b+d) && hcount <= (773-b+d) && vcount > (191-a+c) && vcount <=(192-a+c))data1 <= 12'h00f;else if(hcount > (773-b+d) && hcount < (784-b+d) && vcount > (191-a+c) && vcount <=(192-a+c))data1 <= 12'hffc; //20else if(hcount > (765-b+d) && hcount <= (775-b+d) && vcount > (192-a+c) && vcount <=(193-a+c))data1 <= 12'h00f; //21else if(hcount > (763-b+d) && hcount <= (777-b+d) && vcount > (193-a+c) && vcount <=(194-a+c))data1 <= 12'h00f; //22else if(hcount > (761-b+d) && hcount <= (779-b+d) && vcount > (194-a+c) && vcount <=(195-a+c))data1 <= 12'h00f; //23else if(hcount > (762-b+d) && hcount <= (765-b+d) && vcount >( 195-a+c) && vcount <=(196-a+c))data1 <= 12'hb22;else if(hcount > (775-b+d) && hcount <= (778-b+d) && vcount > (195-a+c) && vcount <=(196-a+c))data1 <= 12'hb22; //24else if(hcount > (760-b+d) && hcount <=(765-b+d) && vcount > (196-a+c) && vcount <=(197-a+c))data1 <= 12'hb22;else if(hcount > (775-b+d) && hcount <= (781-b+d) && vcount > (196-a+c) && vcount <=(197-a+c))data1 <= 12'hb22;//25else if(hcount > (760-b+d) && hcount <= (765-b+d) && vcount > (197-a+c) && vcount <=(198-a+c))data1 <= 12'hb22;else if(hcount > (775-b+d) && hcount <= (781-b+d) && vcount > (197-a+c) && vcount <=(198-a+c))data1 <= 12'hb22; else data1 <= 12'h000;end// GO! //繪制游戲初始準備界面 always@(posedge vga_clk) begin if((hcount>= 274 && hcount <= 294) && (vcount >= 200 && vcount <=350)) data0 <= 12'h111;else if((hcount >= 274 && hcount <=394) && (vcount >= 200 && vcount <=220)) data0 <= 12'h111;else if((hcount >= 274 && hcount <= 394) && (vcount >= 330 && vcount <=350)) data0 <= 12'h111;else if((hcount >= 334 && hcount <= 394) && (vcount >= 275 && vcount <=295)) data0 <= 12'h111;else if((hcount >= 374 && hcount <= 394) && (vcount >= 275 && vcount <= 350)) data0 <= 12'h111;else if((hcount >= 454 && hcount <= 574) && (vcount >= 200 && vcount <= 220)) data0 <= 12'h111;else if((hcount >= 454 && hcount <= 574) && (vcount >= 330 && vcount <= 350)) data0 <= 12'h111;else if((hcount >= 454 && hcount <= 474) && (vcount >= 200 && vcount <= 350)) data0 <= 12'h111;else if((hcount >= 554 && hcount <= 574) && (vcount >= 200 && vcount <= 350)) data0 <= 12'h111;else if((hcount >= 634 && hcount <= 654) && (vcount >= 200 && vcount<= 310)) data0 <= 12'h111;else if((hcount >= 634 && hcount<= 654) && (vcount >= 330 && vcount <= 350)) data0 <= 12'h111;else data0 <= 12'h000; end//GG! //繪制游戲結束界面 always@(posedge vga_clk) begin if((hcount>= 274 && hcount <= 294) && (vcount >= 200 && vcount <=350)) data2 <= 12'hf00;else if((hcount >= 274 && hcount <=394) && (vcount >= 200 && vcount <=220)) data2 <= 12'hf00;else if((hcount >= 274 && hcount <= 394) && (vcount >= 330 && vcount <=350)) data2 <= 12'hf00;else if((hcount >= 334 && hcount <= 394) && (vcount >= 275 && vcount <=295)) data2 <= 12'hf00;else if((hcount >= 374 && hcount <= 394) && (vcount >= 275 && vcount <= 350)) data2 <= 12'hf00;else if((hcount>= 454 && hcount <= 474) && (vcount >= 200 && vcount <=350)) data2 <= 12'hf00;else if((hcount >= 454 && hcount <= 574) && (vcount >= 200 && vcount <=220)) data2 <= 12'hf00;else if((hcount >= 454 && hcount <= 574) && (vcount >= 330 && vcount <=350)) data2 <= 12'hf00;else if((hcount >= 514 && hcount <= 574) && (vcount >= 275 && vcount <=295)) data2 <= 12'hf00;else if((hcount >= 554 && hcount <= 574) && (vcount >= 275 && vcount <= 350)) data2 <= 12'hf00;else if((hcount >= 634 && hcount <= 654) && (vcount >= 200 && vcount<= 310)) data2 <= 12'hf00;else if((hcount >= 634 && hcount<= 654) && (vcount >= 330 && vcount <= 350)) data2 <= 12'hf00;else data2 <= 12'h000; end//$10 always@(posedge vga_clk) begin if((hcount>= 454 && hcount <= 474) && (vcount >= 200 && vcount <=350)) data3 <= 12'h000;else if((hcount >= 534 && hcount <= 554) && (vcount >= 200 && vcount <=350)) data3 <= 12'h000;else if((hcount >= 604 && hcount <= 624) && (vcount >= 200 && vcount <=350)) data3 <= 12'h000;else if((hcount >= 534 && hcount <= 624) && (vcount >= 200 && vcount <=220)) data3 <= 12'h000;else if((hcount >= 534 && hcount <= 624) && (vcount >= 330 && vcount <=350)) data3 <= 12'h000;else if((hcount >= 304 && hcount <= 324) && (vcount >= 220 && vcount <=240)) data3 <= 12'hf00;else if((hcount >= 284 && hcount <= 304) && (vcount >= 200 && vcount <=220)) data3 <= 12'hf00;else if((hcount >= 344 && hcount <= 364) && (vcount >= 220 && vcount <=240)) data3 <= 12'hf00;else if((hcount >= 364 && hcount <= 384) && (vcount >= 200 && vcount <=220)) data3 <= 12'hf00;else if((hcount >= 274 && hcount <= 394) && (vcount >= 240 && vcount <=260)) data3 <= 12'hf00;else if((hcount >= 274 && hcount <= 394) && (vcount >= 300 && vcount <=320)) data3 <= 12'hf00;else if((hcount >= 324 && hcount <= 344) && (vcount >= 240 && vcount <=350)) data3 <= 12'hf00;else data3 <= 12'hfff; endendmodule //阿汪先生的博客.ws

//水平有限,能者見笑,大家見諒。

//感謝~~~

總結

以上是生活随笔為你收集整理的【Verilog】马里奥小游戏的FPGA实现的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。