自动售货机设计与实现_第1页
自动售货机设计与实现_第2页
自动售货机设计与实现_第3页
自动售货机设计与实现_第4页
自动售货机设计与实现_第5页
已阅读5页,还剩50页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

深圳大学实验报告课程名称:数字系统现场集成技术实验项目名称:自动售货机设计与实现学院:信息工程学院 专业:集成电路设计与集成系统 指导教师: 报告人:学号:班级:同组人:学号:班级:实验时间:实验报告提交时间:一、实验目的1、进一步熟悉ISE软件的使用,熟悉FPGA开发流程;2、掌握编写fpga代码的步骤,学会绘制ASM图;3、学会调用ip核实现系统的设计。二、实验设备1、装有ISE软件的PC机一台;2、nexys2开发板一块。三、实验内容与要求设计一个秒表基本要求:该实验为团队协作,2人一个小组。可以对3种不同种类的货物进行自动售货,价格分别为A=4.00,B=2.50,C=1.00。售货机可以接受10元,5元,1元三种硬币(即有三种输入信号SY,WY,IY),并且在7段数码管(二位代表元,一位代表角)显示已投入的总钱数,选择货物的输入信号Ia,Ib,Ic,输出指示信号为Sa,Sb,Sc分别表示售出相应的货物,同时输出的信号yuan,jiao代表找零,并显示在7段数码管上。高级要求(可选):VGA显示3种货物图片及其价格,鼠标点击购买数量(1-9)后显示总价,安规格说明2中的button2-button4输入硬币,VGA显示已投入的总钱数,鼠标点击购买后,显示找零数目,购买物品闪烁,交易完成。规格说明:1. 按一下button1按钮,表示购买货物A,第一个LED灯亮;按两下button1按钮,表示购买货物B,第二个LED灯亮;按三下button1按钮,表示购买货物C,第三个LED灯亮,同时7段数码管显示所要购买货物的价格。2. LED灯亮后,开始输入硬币。button2按一下,输入10元,按两下,输入二十元,以此类推;Button3按一下输入5元,按两下输入10元,以此类推;button4按一下输入1元,按两下输入2元,以此类推。7段数码管显示已投入的总钱数,再次按下button1键,7段数码管显示找零数目,同时指示货物的LED灯熄灭。3. 如果投入的钱币不够就按下button1键确认购买,数码管显示“ER”。4. 本实验使用FPGA板:nexys2(建project时,需要选择该芯片的型号)。四、实验步骤1、设计系统框图,设计采取自上而下的设计方案,整个秒表系统的原理图如下所示。主要包括四个模块——分频模块、vga协议模块、鼠标、vga数据处理模块。而vga数据处理模块里面又有好几个模块–有vga数码管显示模块,显示地址模块(用来生成地址给rom的),还有好多各rom的显示模块,板子按键的处理模块以及鼠标按键的处理模块。总的RTL图分频器Vga协议Vga数据处理MouseVga数据处理总体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;--数据包位数constantWATCHDOG:integer:=320;--400usec所需sys_clk脉冲数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);--位计数器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状态机输出数据signalfall,n_fall:std_logic;--m1状态机输出数据signaloutput_strobe:std_logic;--锁存数据到输出寄存器signalpacket_good:std_logic;--检查数据是否有效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状态m2statech:process(reset,clk)beginif(reset='1')thenm2_state<=m2_reset;elsif(clk'eventandclk='1')thenm2_state<=m2_next_state;endif;endprocess;--m2状态传输逻辑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=>--复位后向鼠标发送命令字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;--用状态机的9个状态实现命令字传输,使鼠标进入"streaming"模式,--并等待鼠标正确应答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';--数据位开始位,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';--数据位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';--数据位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';--数据位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"模式,状态极必须等待足够长的时间,--确保鼠标正确应答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状态结束--位计数器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;--数据移位寄存器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;--看门狗时间计数器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';--接收数据包有效标志packet_good<='1';--输出数据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协议------------------------------------------------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数据处理-------------------------------------------------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三位数码管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) );//****************************************************************************************//另一个三位数码管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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论