自動售貨機設(shè)計與實現(xiàn)_第1頁
自動售貨機設(shè)計與實現(xiàn)_第2頁
自動售貨機設(shè)計與實現(xiàn)_第3頁
自動售貨機設(shè)計與實現(xiàn)_第4頁
自動售貨機設(shè)計與實現(xiàn)_第5頁
已閱讀5頁,還剩50頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

深圳大學實驗報告課程名稱:數(shù)字系統(tǒng)現(xiàn)場集成技術(shù)實驗項目名稱:自動售貨機設(shè)計與實現(xiàn)學院:信息工程學院 專業(yè):集成電路設(shè)計與集成系統(tǒng) 指導教師: 報告人:學號:班級:同組人:學號:班級:實驗時間:實驗報告提交時間:一、實驗?zāi)康?、進一步熟悉ISE軟件的使用,熟悉FPGA開發(fā)流程;2、掌握編寫fpga代碼的步驟,學會繪制ASM圖;3、學會調(diào)用ip核實現(xiàn)系統(tǒng)的設(shè)計。二、實驗設(shè)備1、裝有ISE軟件的PC機一臺;2、nexys2開發(fā)板一塊。三、實驗內(nèi)容與要求設(shè)計一個秒表基本要求:該實驗為團隊協(xié)作,2人一個小組。可以對3種不同種類的貨物進行自動售貨,價格分別為A=4.00,B=2.50,C=1.00。售貨機可以接受10元,5元,1元三種硬幣(即有三種輸入信號SY,WY,IY),并且在7段數(shù)碼管(二位代表元,一位代表角)顯示已投入的總錢數(shù),選擇貨物的輸入信號Ia,Ib,Ic,輸出指示信號為Sa,Sb,Sc分別表示售出相應(yīng)的貨物,同時輸出的信號yuan,jiao代表找零,并顯示在7段數(shù)碼管上。高級要求(可選):VGA顯示3種貨物圖片及其價格,鼠標點擊購買數(shù)量(1-9)后顯示總價,安規(guī)格說明2中的button2-button4輸入硬幣,VGA顯示已投入的總錢數(shù),鼠標點擊購買后,顯示找零數(shù)目,購買物品閃爍,交易完成。規(guī)格說明:1. 按一下button1按鈕,表示購買貨物A,第一個LED燈亮;按兩下button1按鈕,表示購買貨物B,第二個LED燈亮;按三下button1按鈕,表示購買貨物C,第三個LED燈亮,同時7段數(shù)碼管顯示所要購買貨物的價格。2. LED燈亮后,開始輸入硬幣。button2按一下,輸入10元,按兩下,輸入二十元,以此類推;Button3按一下輸入5元,按兩下輸入10元,以此類推;button4按一下輸入1元,按兩下輸入2元,以此類推。7段數(shù)碼管顯示已投入的總錢數(shù),再次按下button1鍵,7段數(shù)碼管顯示找零數(shù)目,同時指示貨物的LED燈熄滅。3. 如果投入的錢幣不夠就按下button1鍵確認購買,數(shù)碼管顯示“ER”。4. 本實驗使用FPGA板:nexys2(建project時,需要選擇該芯片的型號)。四、實驗步驟1、設(shè)計系統(tǒng)框圖,設(shè)計采取自上而下的設(shè)計方案,整個秒表系統(tǒng)的原理圖如下所示。主要包括四個模塊——分頻模塊、vga協(xié)議模塊、鼠標、vga數(shù)據(jù)處理模塊。而vga數(shù)據(jù)處理模塊里面又有好幾個模塊–有vga數(shù)碼管顯示模塊,顯示地址模塊(用來生成地址給rom的),還有好多各rom的顯示模塊,板子按鍵的處理模塊以及鼠標按鍵的處理模塊。總的RTL圖分頻器Vga協(xié)議Vga數(shù)據(jù)處理MouseVga數(shù)據(jù)處理總體2、所編寫的代碼如下。------------------------頂層文件----程序主代碼------------------------------------------ moduletop_2(clear,clk, rst_p, key_1yuan, key_5yuan, key_10yuan, video_r,video_g, video_b, ps2clk, ps2data, hsync, vsync,);inputclear;inputclk;inputrst_p;inputkey_1yuan;inputkey_5yuan;inputkey_10yuan;inoutps2clk;inoutps2data;wirerst_n;assignrst_n=~rst_p;output[2:0]video_r;output[2:0]video_g;output[1:0]video_b;outputhsync;outputvsync;wireclk_25M;wire[9:0]x;wire[9:0]y;wire[7:0]vga_rgb;wire[7:0]mousergb;wire[9:0]mousex;wire[9:0]mousey;wireleft_button;wireright_button;wiredata; mouseu1ps2mouse ( .clk_sys(clk_25M),.reset(rst_p),.ps2_clk(ps2clk),.ps2_data(ps2data),.left_button(left_button),.right_button(right_button),.mousex(mousex),.mousey(mousey) ); div#(.counter(32'b1))div_2(.inclk(clk),.rst_n(rst_n),.outclk(clk_25M)); //xiaofka(//.clk(clk_25M),// .rst_n(rst_n),// .x(x),// .y(y),// .rgb(vga_rgb)//); vga_picture_allvga_picture_all ( .clk(clk_25M), .rst_n(rst_n), .mx(mousex), .my(mousey), .left_button(left_button), .right_button(right_button), .key_1yuan(key_1yuan), .key_5yuan(key_5yuan), .key_10yuan(key_10yuan), .vga_x(x), .vga_y(y), .vga_rgb(vga_rgb) ); VGA_protocolVGA_protocol ( .video_clk(clk_25M), .rst_n(rst_n), //raminterface .video_rgb(vga_rgb), .video_x(x), //pointcoordinate .video_y(y), //VGAtransfer .video_hsync(hsync), .video_vsync(vsync), .video_en(en_vga), .video_r(video_r), .video_g(video_g), .video_b(video_b) ); endmodule-------------------------------------------------------------------------------------------------------------------以下是每個模塊的代碼------------------------------------------------------------------------------分頻-----------------------------------------------------------modulediv#(parametercounter=32'd1)(inclk,rst_n,outclk);inputinclk;inputrst_n;outputregoutclk;wireoutclk_pre;reg[31:0]cnt;wire[31:0]cnt_pre;always@(posedgeinclkornegedgerst_n)beginif(!rst_n) begin outclk<=0; cnt<=1; end elsebegin outclk<=outclk_pre; cnt<=cnt_pre; endend assigncnt_pre=(cnt==counter?1'b1:(cnt+1'b1));assignoutclk_pre=(cnt==counter?~outclk:outclk);endmodule-----------------------------------------------------------------------------------------------------------鼠標-----------------------------------libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;useIEEE.STD_LOGIC_ARITH.ALL;useIEEE.STD_LOGIC_UNSIGNED.ALL;entitymouseisPort(clk_sys:instd_logic;reset:instd_logic;ps2_clk:inoutstd_logic;ps2_data:inoutstd_logic;left_button:outstd_logic;right_button:outstd_logic;mousex:inoutstd_logic_vector(9downto0);mousey:inoutstd_logic_vector(9downto0));endmouse;architectureBehavioralofmouseisconstantTOTAL_BITS:integer:=33;--數(shù)據(jù)包位數(shù)constantWATCHDOG:integer:=320;--400usec所需sys_clk脈沖數(shù)typem2statetypeis(m2_reset,m2_wait,m2_gather,m2_verify,m2_use,m2_hold_clk_l,m2_data_low_1,m2_data_high_1,m2_data_low_2,m2_data_high_2,m2_data_low_3,m2_data_high_3,m2_error_no_ack,m2_await_response);signalm2_state,m2_next_state:m2statetype;signalwatchdog_timer_done:std_logic;--命令傳輸超時標志signalq:std_logic_vector(TOTAL_BITS-1downto0);--位序列signalbitcount:std_logic_vector(5downto0);--位計數(shù)器signalwatchdog_timer_count:std_logic_vector(8downto0);--等待時間signalps2_clk_hi_z:std_logic;signalps2_data_hi_z:std_logic;signalfallsig,risesig:std_logic_vector(2downto0);signalclean_clk:std_logic;--從m1跟隨ps2_clk反向輸出signalrise,n_rise:std_logic;--m1狀態(tài)機輸出數(shù)據(jù)signalfall,n_fall:std_logic;--m1狀態(tài)機輸出數(shù)據(jù)signaloutput_strobe:std_logic;--鎖存數(shù)據(jù)到輸出寄存器signalpacket_good:std_logic;--檢查數(shù)據(jù)是否有效signalmouseyy:std_logic_vector(9downto0);signalclk:std_logic;--mouseclk------signalcount:integerrange0to62;signaldata_ready:std_logic;--rx_read_osignalerror_no_ack:std_logic;beginprocess(clk_sys,reset)beginif(reset='1')thenclk<='0';count<=0;elsif(clk_sys'eventandclk_sys='1')thenif(count=62)thencount<=0;clk<=NOTclk;elsecount<=count+1;endif;endif;endprocess;ps2_clk<='0'whenps2_clk_hi_z='0'else'Z';ps2_data<='0'whenps2_data_hi_z='0'else'Z';--------------------------------------檢測ps2clk上升沿和下降沿------------------------------------detect_ps2clkfall:process(clk,reset,ps2_clk)beginifreset='1'thenfallsig<="000";elsifclk'eventandclk='1'thenfallsig(0)<=ps2_clk;fallsig(1)<=fallsig(0);fallsig(2)<=fallsig(1);endif;endprocess;fall<='1'whenfallsig="110"else'0';detect_ps2clkrise:process(clk,reset,ps2_clk)beginifreset='1'thenrisesig<="000";elsifclk'eventandclk='1'thenrisesig(0)<=ps2_clk;risesig(1)<=risesig(0);risesig(2)<=risesig(1);endif;endprocess;rise<='1'whenrisesig="001"else'0';------------------m2狀態(tài)m2statech:process(reset,clk)beginif(reset='1')thenm2_state<=m2_reset;elsif(clk'eventandclk='1')thenm2_state<=m2_next_state;endif;endprocess;--m2狀態(tài)傳輸邏輯m2statetr:process(m2_state,q,fall,rise,watchdog_timer_done,bitcount,ps2_data,packet_good)begin--輸出信號的缺省值ps2_clk_hi_z<='1';ps2_data_hi_z<='1';error_no_ack<='0';output_strobe<='0';casem2_stateiswhenm2_reset=>--復位后向鼠標發(fā)送命令字m2_next_state<=m2_hold_clk_l;whenm2_wait=>if(fall='1')thenm2_next_state<=m2_gather;elsem2_next_state<=m2_wait;endif;whenm2_gather=>if((watchdog_timer_done='1')and(bitcount=TOTAL_BITS))thenm2_next_state<=m2_verify;elsem2_next_state<=m2_gather;endif;whenm2_verify=>--if(bitcount<TOTAL_BITS)then--替換"packet_good='1'"--m2_next_state<=m2_wait;--elsem2_next_state<=m2_use;--endif;whenm2_use=>output_strobe<='1';m2_next_state<=m2_wait;--用狀態(tài)機的9個狀態(tài)實現(xiàn)命令字傳輸,使鼠標進入"streaming"模式,--并等待鼠標正確應(yīng)答whenm2_hold_clk_l=>ps2_clk_hi_z<='0';--啟動看門狗!if(watchdog_timer_done='1')thenm2_next_state<=m2_data_low_1;elsem2_next_state<=m2_hold_clk_l;endif;whenm2_data_low_1=>ps2_data_hi_z<='0';--數(shù)據(jù)位開始位,d[0]andd[1]if(fall='1'and(bitcount=2))thenm2_next_state<=m2_data_high_1;elsem2_next_state<=m2_data_low_1;endif;whenm2_data_high_1=>ps2_data_hi_z<='1';--數(shù)據(jù)位d[2]if(fall='1'and(bitcount=3))thenm2_next_state<=m2_data_low_2;elsem2_next_state<=m2_data_high_1;endif;whenm2_data_low_2=>ps2_data_hi_z<='0';--數(shù)據(jù)位d[3]if(fall='1'and(bitcount=4))thenm2_next_state<=m2_data_high_2;elsem2_next_state<=m2_data_low_2;endif;whenm2_data_high_2=>ps2_data_hi_z<='1';--數(shù)據(jù)位d[4],d[5],d[6],d[7]if(fall='1'and(bitcount=8))thenm2_next_state<=m2_data_low_3;elsem2_next_state<=m2_data_high_2;endif;whenm2_data_low_3=>ps2_data_hi_z<='0';--奇偶校驗位if(fall='1')thenm2_next_state<=m2_data_high_3;elsem2_next_state<=m2_data_low_3;endif;whenm2_data_high_3=>ps2_data_hi_z<='1';--允許鼠標拉成低電平(ACK脈沖)if(fall='1'and(ps2_data='1'))thenm2_next_state<=m2_error_no_ack;elsif(fall='1'and(ps2_data='0'))thenm2_next_state<=m2_await_response;elsem2_next_state<=m2_data_high_3;endif;whenm2_error_no_ack=>error_no_ack<='1';m2_next_state<=m2_error_no_ack;--為了鼠標正確進入"streaming"模式,狀態(tài)極必須等待足夠長的時間,--確保鼠標正確應(yīng)答0xFA。whenm2_await_response=>--if(bitcount=22)thenm2_next_state<=m2_verify;--else--m2_next_state<=m2_await_response;--endif;whenothers=>m2_next_state<=m2_wait;endcase;endprocess;-----------------------------m2狀態(tài)結(jié)束--位計數(shù)器bitcoun:process(reset,clk)beginif(reset='1')thenbitcount<=(others=>'0');--normalresetelsif(clk'eventandclk='1')thenif(fall='1')thenbitcount<=bitcount+1;elsif(watchdog_timer_done='1')thenbitcount<=(others=>'0');--rxwatchdogtimerresetendif;endif;endprocess;--數(shù)據(jù)移位寄存器dataseq:process(reset,clk)beginif(reset='1')thenq<=(others=>'0');elsif(clk'eventandclk='1')thenif(fall='1')thenq<=ps2_data&q(TOTAL_BITS-1downto1);endif;endif;endprocess;--看門狗時間計數(shù)器watchcount:process(reset,rise,fall,clk)beginif((reset='1')or(rise='1')or(fall='1'))thenwatchdog_timer_count<=(others=>'0');elsif(clk'eventandclk='1')thenif(watchdog_timer_done='0')thenwatchdog_timer_count<=watchdog_timer_count+1;endif;endif;endprocess;watchdog_timer_done<='1'when(watchdog_timer_count=WATCHDOG-1)else'0';--接收數(shù)據(jù)包有效標志packet_good<='1';--輸出數(shù)據(jù)outdata:process(reset,clk)beginif(reset='1')thenleft_button<='0';right_button<='0';--x_increment<=(others=>'0');--y_increment<=(others=>'0');elsif(clk'eventandclk='1')thenif(output_strobe='1')thenleft_button<=q(1);right_button<=q(2);--x_increment<='0'&q(19downto12);mouseyy<=not(q(6)&q(6)&q(30downto23))+"1";endif;endif;endprocess;cordinatex:process(reset,clk)beginif(reset='1')thenmousex<="0000001010";--"0101000000";--320elsif(clk'eventandclk='1')thenif(output_strobe='1')thenif((mousex="1001111111"andq(5)='0'))or((mousex="0000000000"andq(5)='1'))thenmousex<=mousex;elsemousex<=mousex+(q(5)&q(5)&q(19downto12));--q(5):xsignq(6):ysignendif;endif;endif;endprocess;cordinatey:process(reset,clk)beginif(reset='1')thenmousey<="0000001010";--"0011110000";--240elsif(clk'eventandclk='1')thenif(output_strobe='1')thenif((mousey="1110111111"andq(6)='1'))or((mousey="0000000000"andq(6)='0'))thenmousey<=mousey;elsemousey<=mousey+mouseyy;--(q(6)&q(6)&q(30downto23));endif;endif;endif;endprocess;--mousey<="1001010101"-mouseyy;data_ready<=output_strobe;endBehavioral;----------------------------------------------------------------------------------------------------------------vga協(xié)議------------------------------------------------moduleVGA_protocol#( parameterHSTS=800, //allhsynctimes HSTDISP=640, //hsyncdisplaytimes HSTPW=96, //hsyncplusewidthtimes HSTFP=16, //hsyncfrontplusetimes HSTBP=48, //hsyncbackplusetimes VSTS=521, //allvsyncplusetimes VSTDISP=480, //vsyncdisplayplusetimes VSTPW=2, //vsyncplusetimes VSTFP=10, //vsyncfrontplusetimes VSTBP=29, //vsyncbackplusetimes width_x=10, //displayxcoordinatewidth width_y=10 //displayycoordinatewidth ) ( video_clk, rst_n, //raminterface video_rgb, video_x, //pointcoordinate video_y, //VGAtransfer video_hsync, video_vsync, video_en, video_r, video_g, video_b );inputvideo_clk;//25Minputrst_n;//reset//ram接口input[7:0]video_rgb;output[width_x-1:0]video_x;output[width_y-1:0]video_y;//fpga與vga接口信息outputvideo_hsync;//行同步信號outputvideo_vsync;//場同步信號outputvideo_en;//輸出使能output[2:0]video_r;output[2:0]video_g;output[1:0]video_b;//coordinatecountreg[width_x-1:0]x_cnt;reg[width_y-1:0]y_cnt;wire[width_x-1:0]x_cnt_pre;wire[width_y-1:0]y_cnt_pre;//generatex_cntalways@(posedgevideo_clkornegedgerst_n) if(!rst_n) x_cnt<={width_x{1'b0}}; else x_cnt<=x_cnt_pre;assignx_cnt_pre=(x_cnt==HSTS-1'b1)?{width_x{1'b0}}:(x_cnt+1'b1);//generatecnt_yalways@(posedgevideo_clkornegedgerst_n) if(!rst_n) y_cnt<={width_y{1'b0}}; else y_cnt<=y_cnt_pre;assigny_cnt_pre=(y_cnt==VSTS-1'b1)?{width_y{1'b0}}:((x_cnt==HSTS-1'b1)?(y_cnt+1'b1):y_cnt);//generatehsyncreghsync_r;wirehsync_r_pre;always@(posedgevideo_clkornegedgerst_n) if(!rst_n) hsync_r<=1'b1; else hsync_r<=hsync_r_pre;assignhsync_r_pre=(x_cnt=={width_x{1'b0}})?1'b0:((x_cnt==HSTPW)?1'b1:hsync_r);assignvideo_hsync=hsync_r_pre;//generatevsyncregvsync_r;wirevsync_r_pre;always@(posedgevideo_clkornegedgerst_n) if(!rst_n) vsync_r<=1'b1;else vsync_r<=vsync_r_pre;assignvsync_r_pre=(y_cnt=={width_y{1'b0}})?1'b0:((y_cnt==VSTPW)?1'b1:vsync_r);assignvideo_vsync=vsync_r;//generateenwirevideo_en;wirehs_en;wirevs_en;assignhs_en=(x_cnt>=HSTPW+HSTBP)&(x_cnt<HSTPW+HSTBP+HSTDISP);assignvs_en=(y_cnt>=VSTPW+VSTBP)&(y_cnt<VSTPW+VSTBP+VSTDISP);assignvideo_en=hs_en&vs_en;//generatepointcoordinate(x,y)assignvideo_x=hs_en?(x_cnt-HSTPW-HSTBP):{width_x{1'b0}};assignvideo_y=vs_en?(y_cnt-VSTPW-VSTBP):{width_y{1'b0}};//r,g,b控制液晶屏顏色顯示assignvideo_r=video_en?video_rgb[7:5]:3'b000;assignvideo_g=video_en?video_rgb[4:2]:3'b000;assignvideo_b=video_en?video_rgb[1:0]:2'b00;endmodule------------------------------------------------------------------------------------------------------------------------vga數(shù)據(jù)處理-------------------------------------------------modulevga_picture_all #( parameterpattern_x=10'd234, pattern_y=9'd140, pattern_width=10'd40, pattern_high=9'd100, frame_width=4'd4, framecolor=8'h00 ) ( clk, mx, my, left_button, right_button, key_1yuan, key_5yuan, key_10yuan, rst_n, vga_x, vga_y, vga_rgb ); inputleft_button;inputright_button;inputclk;inputrst_n;input[9:0]vga_x;input[9:0]vga_y;inputkey_1yuan;inputkey_5yuan;inputkey_10yuan;input[9:0]mx;input[9:0]my;//wireen_frame1_1;//wireen_frame2_2;//wireen_frame3_3;//wireen_frame4_4;wireen_change_out;wireen_buy_out;output[7:0]vga_rgb;wire[11:0]addr1;wire[11:0]addr2;wire[11:0]addr3;wire[11:0]addr4;wireen1;wireen2;wireen3;wireen4;wireen;wire[7:0]rgb1;wire[7:0]rgb2;wire[7:0]rgb3;wire[7:0]rgb4;wire[9:0]yuanaddr1;wire[9:0]yuanaddr2;wire[9:0]yuanaddr3;wire[9:0]yuanaddr4;wireyuanen1;wireyuanen2;wireyuanen3;wireyuanen4;wireyuanrgb1;wireyuanrgb2;wireyuanrgb3;wireyuanrgb4;wire[7:0]framergb1;wire[7:0]framergb2;wire[7:0]framergb3;wire[7:0]framergb4;wire[7:0]rgb;wireyuanrgb;wire[7:0]framergb;wire[7:0]vga_rgb_pre;wire[7:0]mousergb;wireen_frame1;wireen_frame2;wireen_frame3;wireen_frame4;wireen_frame1_1;wireen_frame2_2;wireen_frame3_3;wireen_frame4_4;reg[7:0]framergb1_1;reg[7:0]framergb2_2;reg[7:0]framergb3_3;reg[7:0]framergb4_4;wireclk_10ms;wire[3:0]all_shi;wire[3:0]all_ge;wire[3:0]all_fen;wireen_buy;wire[9:0]addr_buy;wirebuy_rgb;wireen_change;wire[9:0]addr_change;wirechange_rgb;//wire[7:0]framergb1_1;//wire[7:0]framergb2_2;//wire[7:0]framergb3_3;//wire[7:0]framergb4_4;wire[7:0]display_vga1;wire[7:0]display_vga2;wire[7:0]display_vga3;wire[7:0]display_vga4;wire[7:0]display_vga5;wire[7:0]display_vga6;wire[3:0]buy_shi;wire[3:0]buy_ge;wire[3:0]buy_fen;wirebuy_rgb_pre;wirechange_rgb_pre;wireen_buy_zero;wireen_change_zero;assignrgb=en1?rgb1: en2?rgb2: en3?rgb3: en4?rgb4:8'hff;assignframergb=en_frame1?framergb1_1:en_frame2?framergb2_2: en_frame3?framergb3_3: en_frame4?framergb4_4:8'hff;assignbuy_rgb_pre=en_buy?buy_rgb:1'b1;assignchange_rgb_pre=en_change?change_rgb:1'b1;assignyuanrgb=yuanen1?yuanrgb1: yuanen2?yuanrgb2: yuanen3?yuanrgb3: yuanen4?yuanrgb4:1'b1; assignvga_rgb_pre=rgb&framergb&{8{yuanrgb}}&{8{buy_rgb_pre}}&{8{change_rgb_pre}}&display_vga1&display_vga2&display_vga3&display_vga4&display_vga5&display_vga6;assignvga_rgb=en?mousergb:vga_rgb_pre;assignen_frame1_1=(mx>=pattern_x&&(mx<=pattern_x+pattern_width)&&my>=pattern_y&&(my<=pattern_y+pattern_high))?1'b1:1'b0;assignen_frame2_2=((mx>=10'd282)&&(mx<=10'd322)&&my>=pattern_y&&(my<=pattern_y+pattern_high))?1'b1:1'b0;assignen_frame3_3=((mx>=pattern_x+2*(pattern_width+2*frame_width))&&(mx<=pattern_x+2*(pattern_width+2*frame_width)+pattern_width)&&my>=pattern_y&&(my<=pattern_y+pattern_high))?1'b1:1'b0;assignen_frame4_4=((mx>=pattern_x+3*(pattern_width+2*frame_width))&&(mx<=pattern_x+3*(pattern_width+2*frame_width)+pattern_width)&&my>=pattern_y&&(my<=pattern_y+pattern_high))?1'b1:1'b0;////assignframergb1_1=en_frame1_1?(framergb1|8'he0):framergb1;//assignframergb2_2=en_frame2_2?(framergb2|8'he0):framergb2;//assignframergb3_3=en_frame3_3?(framergb3|8'he0):framergb3;//assignframergb4_4=en_frame4_4?(framergb4|8'he0):framergb4;//always@(posedgeclkornegedgerst_n)beginif(!rst_n)framergb1_1<=8'hff;elseif(en_frame1_1==1)framergb1_1<=8'he0;elseframergb1_1<=framergb1;end//always@(posedgeclkornegedgerst_n)beginif(!rst_n)framergb2_2<=8'hff;elseif(en_frame2_2==1)framergb2_2<=8'he0;elseframergb2_2<=framergb2;endalways@(posedgeclkornegedgerst_n)beginif(!rst_n)framergb3_3<=8'hff;elseif(en_frame3_3==1)framergb3_3<=8'he0;elseframergb3_3<=framergb3;endalways@(posedgeclkornegedgerst_n)beginif(!rst_n)framergb4_4<=8'hff;elseif(en_frame4_4==1)framergb4_4<=8'he0;elseframergb4_4<=framergb4;enddiv#(.counter(32'd125000))div_10ms(.inclk(clk),.rst_n(rst_n),.outclk(clk_10ms));//按鍵KEYkey( .clk_10ms(clk_10ms),.rst_n(rst_n), .key_1yuan(key_1yuan), .key_5yuan(key_5yuan), .key_10yuan(key_10yuan), .en_buy_zero(en_buy_zero), .en_change_zero(en_change_zero), .buy_fen(buy_fen), .buy_ge(buy_ge), .buy_shi(buy_shi), .all_shi(all_shi),.all_ge(all_ge),.all_fen(all_fen)); //鼠標按鍵mouse_keymouse_key( .clk_10ms(clk_10ms),.rst_n(rst_n), .left_button(left_button), .right_button(right_button), .en_frame1_1(en_frame1_1), .en_frame2_2(en_frame2_2), .en_frame3_3(en_frame3_3), .en_frame4_4(en_frame4_4), .en_buy_in(en_buy_out), .en_change_in(en_change_out), .en_buy_zero(en_buy_zero), .en_change_zero(en_change_zero), .buy_shi(buy_shi),.buy_ge(buy_ge), .buy_fen(buy_fen));//鼠標方塊triangleu1triangle ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .dian_x(mx), .dian_y(my), .en(en), .vga_rgb(mousergb) ); //*********************************************************************************//vga三位數(shù)碼管VGASegDisplay #( .LeftTopx(10'd234), .LeftTopy(10'd300) ) dosplay_1 ( .data(buy_shi), .dp(1'b0), .vga_x(vga_x), .vga_y(vga_y), .vga_rgb(display_vga1) ); VGASegDisplay #( .LeftTopx(10'd259), .LeftTopy(10'd300) ) dosplay_2 ( .data(buy_ge), .dp(1'b1), .vga_x(vga_x), .vga_y(vga_y), .vga_rgb(display_vga2) );VGASegDisplay #( .LeftTopx(10'd290), .LeftTopy(10'd300) ) dosplay_3 ( .data(buy_fen), .dp(1'b0), .vga_x(vga_x), .vga_y(vga_y), .vga_rgb(display_vga3) );//****************************************************************************************//另一個三位數(shù)碼管VGASegDisplay #( .LeftTopx(10'd234), .LeftTopy(10'd380) ) dosplay_4 ( .data(all_shi), .dp(1'b0), .vga_x(vga_x), .vga_y(vga_y), .vga_rgb(display_vga4) ); VGASegDisplay #( .LeftTopx(10'd259), .LeftTopy(10'd380) ) dosplay_5 ( .data(all_ge), .dp(1'b1), .vga_x(vga_x), .vga_y(vga_y), .vga_rgb(display_vga5) );VGASegDisplay #( .LeftTopx(10'd290), .LeftTopy(10'd380) ) dosplay_6 ( .data(all_fen), .dp(1'b0), .vga_x(vga_x), .vga_y(vga_y), .vga_rgb(display_vga6) );//**********************************************************************************************assignen_buy_out=(mx>=350&mx<=390&my>=310&my<=330)?1'b1:1'b0;read_module#( .pattern_x(10'd350), .pattern_y(10'd310), .pattern_width(10'd40), .pattern_high(9'd20) ) buyaddr ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(en_buy), .addr(addr_buy) );buybuy(.clka(clk),//inputclka.addra(addr_buy),//input[8:0]addra.douta(buy_rgb)//output[0:0]douta);assignen_change_out=(mx>=350&mx<=390&my>=390&my<=410)?1'b1:1'b0;read_module#( .pattern_x(10'd350), .pattern_y(10'd390), .pattern_width(10'd40), .pattern_high(9'd20) ) changeaddr ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(en_change), .addr(addr_change) );changechange(.clka(clk),//inputclka.addra(addr_change),//input[8:0]addra.douta(change_rgb)//output[0:0]douta);//茉莉蜜茶//取地址read_module#( .pattern_x(pattern_x), .pattern_y(pattern_y) ) molimicha_addr ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(en1), .addr(addr1) ); molimicha1molimicha(.clka(clk),.addra(addr1),.douta(rgb1));frame#( .x_lengthframe(pattern_width+2*frame_width), .y_lengthframe(pattern_high+2*frame_width), .x_frame(pattern_x-frame_width), .y_frame(pattern_y-frame_width), .widthframe(frame_width), .framecolor(8'h00) ) rommolichaframe1 ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(en_frame1), .frame_rgb(framergb1) ); read_module#( .pattern_x(pattern_x), .pattern_y(pattern_y+pattern_high+frame_width), .pattern_high(9'd20) ) yuan45addr ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(yuanen1), .addr(yuanaddr1) ); yuan4_5yuan4_5( .clka(clk),//inputclka .addra(yuanaddr1),//input[9:0]addra .douta(yuanrgb1)//output[7:0]douta);//-------------------------------------------------------------------------------------------------------------------//冰紅茶read_module#( .pattern_x(10'd282), .pattern_y(pattern_y) ) binghongchaaddr ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(en2), .addr(addr2) );//取圖片binghongchabinghongcha( .clka(clk),//inputclka .addra(addr2),//input[11:0]addra .douta(rgb2)//output[7:0]douta);//方框 frame#( .x_lengthframe(pattern_width+2*frame_width), .y_lengthframe(pattern_high+2*frame_width), .x_frame(10'd278), .y_frame(pattern_y-frame_width), .widthframe(frame_width), .framecolor(framecolor) ) binghongchaframe2 ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(en_frame2), .frame_rgb(framergb2) );//取價格地址 read_module#( .pattern_x(10'd282), .pattern_y(pattern_y+pattern_high+frame_width), .pattern_high(9'd20) ) yuan2_5addr ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(yuanen2), .addr(yuanaddr2) );//價格 yuan2_5yuan2_5(.clka(clk),//inputclka.addra(yuanaddr2),//input[9:0]addra.douta(yuanrgb2)//output[7:0]douta);//----------------------------------------------------------------------------------------------------------//芬達//取地址 read_module#( .pattern_x(pattern_x+2*(pattern_width+2*frame_width)), .pattern_y(pattern_y) ) fendaaddr ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(en3), .addr(addr3) ); //取圖片 fendafenda(.clka(clk),//inputclka.addra(addr3),//input[11:0]addra.douta(rgb3)//output[7:0]douta);//方框 frame#( .x_lengthframe(pattern_width+2*frame_width), .y_lengthframe(pattern_high+2*frame_width), .x_frame(pattern_x+2*pattern_width+3*frame_width), .y_frame(pattern_y-frame_width), .widthframe(frame_width), .framecolor(framecolor) ) fendaframe3 ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(en_frame3), .frame_rgb(framergb3) );//取價格地址 read_module#( .pattern_x(pattern_x+2*(pattern_width+2*frame_width)), .pattern_y(pattern_y+pattern_high+frame_width), .pattern_high(9'd20) ) yuan15addr ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(yuanen3), .addr(yuanaddr3) );//價格 yuan1point5yuan1_5(.clka(clk),//inputclka.addra(yuanaddr3),//input[9:0]addra.douta(yuanrgb3)//output[7:0]douta);//--------------------------------------------------------------------------------------------------------//水蜜桃//取地址 read_module#( .pattern_x(pattern_x+3*(pattern_width+2*frame_width)), .pattern_y(pattern_y) ) shuimitaoaddr ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(en4), .addr(addr4) );//取圖片 shuimitaoshuimitao( .clka(clk), .addra(addr4), .douta(rgb4) );//方框 frame#( .x_lengthframe(pattern_width+2*frame_width), .y_lengthframe(pattern_high+2*frame_width), .x_frame(pattern_x+3*pattern_width+5*frame_width), .y_frame(pattern_y-frame_width), .widthframe(frame_width), .framecolor(framecolor) ) shuimitaoframe4 ( .clk(clk), .rst_n(rst_n), .vga_x(vga_x), .vga_y(vga_y), .en(en_frame4), .frame_rgb(framergb4) );//取價格地址 read_module#( .pattern_x(pattern_x+3*(pattern_width+2*frame_width)), .pattern_y(pattern_y+pattern_high+frame_width), .pattern_high(9'd20) ) yuan1

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論