完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
就是调试不来,话说我都不知到这个是应该新建verilog HDL还是VHDL 0.0(注释是我自己加上去的,因为采用verilogHDL错误少点所以用的'//')....哎代码调试不出,波形仿真就更困难了,话说这是建立一个文件呢还是拆分成多个文件呀,,求高手帮忙,我是菜菜。
Info: Command: quartus_map --read_settings_files=on --write_settings_files=off vendor -c vendor Error (10170): Verilog HDL syntax error at vendor.v(1) near text ";"; expecting ".", or an identifier, or "*", or "/" Info: Found 0 design units, including 0 entities, in source file vendor.v Error: Quartus II Analysis & Synthesis was unsuccessful. 1 error, 0 warnings Error: Peak virtual memory: 170 megabytes Error: Processing ended: Sun Apr 27 12:32:18 2014 Error: Elapsed time: 00:00:01 Error: Total CPU time (on all processors): 00:00:01 Error: Quartus II Full Compilation was unsuccessful. 3 errors, 0 warnings 代码如下, library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity vendor is port( reset :in std_logic; //系统内部给其他顾客重新操作的复位信号 clk :in std_logic; //由外接信号发生器提供的1024Hz系统时钟信号 ok_buy :in std_logic; //购买确认的按键信号 cancel_buy :in std_logic; //购买取消的按键信号 coin_5 :in std_logic; //投入五角硬币的动作按键 coin_10 :in std_logic; //投入壹圆硬币的动作按键 select_cola :in std_logic; //选择可口可乐的按键信号 select_pepsi :in std_logic; //选择百事可乐的按键信号 led_cola_ok :out std_logic; //灯亮显示还有可口可乐 led_pepsi_ok :out std_logic; //灯亮显示还有百事可乐 led_cola_sel :out std_logic; //灯亮显示可口可乐选择键被按 led_pepsi_sel :out std_logic; //灯亮显示百事可乐选择键被按 led_buy :out std_logic; //灯亮显示按了购买确认键 led_cancel :out std_logic; //灯亮显示按了购买取消键 led_five :out std_logic_vector(2 downto 0);//3个LED,投入1个五角硬币亮一个LED led_ten :out std_logic_vector(1 downto 0);//2个LED,投入1个壹圆硬币亮一个LED led_five_return :out std_logic_vector(2 downto 0);//3个LED,以每秒4次的闪烁代表退出的硬币 led_ten_return :out std_logic_vector(2 downto 0);//2个LED,以每秒4次的闪烁代表退出的硬币 led_cola_out :out std_logic;//灯亮显示可口可乐已出货 led_pepsi_out :out std_logic //灯亮显示百事可乐已出货 ); end; architecture arch of vendor is signal ok :std_logic;//用来维持ok_buy的状态 signal cancel :std_logic;//用来维持cancel_buy的状态 signal money_ok :std_logic;//投入金额正确 signal return_clk :std_logic;//退币的闪烁信号4Hz signal cola_choice :std_logic;//用来维持select_cola的状态 signal pepsi_choice :std_logic;//用来维持select_pepsi的状态 signal total_amount_five:integer range 0 to 15;//五角硬币的累计投入金额 signal total_amount_ten :integer range 0 to 20;//壹圆硬币的累计投入金额 signal cola_out :std_logic;//可口可乐已经出货的信号 signal pepsi_out :std_logic;//百事可乐已经出货的信号 begin return_clock:block //5.1.1产生退币闪烁信号的电路模块 signal count:std_logic_vector(7 downto 0); begin process(reset,clk) begin if reset='1' then count<="00000000"; //高电平复位 return_clk<='0'; elseif rising_edge(clk) then //时钟上升沿有效 count<=count+"00000001"; if count(7)='1' then return_clk<='1';//退币 else return_clk<='0'; end if; end if; end process; end block; coin_10_counting:block //5.1.2投入壹圆硬币的处理电路模块 signal no_coin_ten:integer range 0 to 2; begin process(reset,coin_10) begin if reset='1' then total_amount_ten<=0; //复位 no_coin_ten<=0; led_ten<="00"; elseif rising_edge(coin_10) then //按下投入一元硬币的按钮 total_amount_ten<=total_amount_ten+10; if no_coin_ten<2 then //投入一元钱 led_ten(no_coin_ten)<='1'; //灯亮几盏表示投入多少个硬币 no_coin_ten<=no_coin_ten+1; else no_coin_ten<=2; //投入两元钱 end if; end if; end process; end block; coin_5_counting:block //5.1.3投入五角硬币的处理电路模块 signal no_coin_five:integer range 0 to 3; begin process(reset,coin_5) begin if reset='1' then total_amount_five<=0; //复位 no_coin_five<=0; led_five<="000"; elsif rising_edge(coin_5) then //按下投入五角钱硬币的按钮 total_amount_five<=total_amount_five+5; if no_coin_five<3 then //投入0.5—1元钱 led_five(no_coin_five)<='1'; no_coin_five<=no_coin_five+1; else no_coin_five<=3; //投入多于1.5元 end if; end if; end process; end block; select_drink:block //5.1.4饮料选择处理电路模块 begin process(reset,clk) begin if reset='1' then led_cola_sel<='0'; //复位 led_pepsi_sel<='0'; elseif rising_edge(clk) then //时钟上升沿 if select_cola='1' then //选择可乐 led_cola_sel<='1'; //相应的信号灯亮 cola_choice<='1'; //维持选择状态 led_pepsi_sel<='0'; end if; if select_pepsi='1' then //选择百事 led_cola_sel<='0'; pepsi_choice<='1'; //维持选择状态 led_pepsi_sel<='1'; //相应的灯亮 end if; end if; end process; end block; ok_or_cancel:block //5.1.5确认与取消处理电路模块 begin p1:process(reset,ok_buy) begin if reset='1' then ok<='0'; //复位 led_buy<='0'; elsif rising_edge(ok_buy) then //按确认按钮 ok<='1'; //维持状态 led_buy<='1'; //确认灯亮 end if; end process; p2:process(reset,cancel_buy) begin if reset='1' then cancel<='0'; //复位 led_cancel<='0'; elsif rising_edge(cancel_buy) then //按取消键 cancel<='1'; //维持状态 led_cancel<='1'; //取消灯亮 end if; end process; end block; coin_returned:block //5.1.6退币处理电路模块 signal total_amount:integer range 0 to 35; begin process(reset,clk) begin if reset='1' then //复位 total_amount<=0; money_ok<='0'; led_five_return<=(others=>'0'); led_ten_return<=(others=>'0'); elseif rising_edge(clk) then //时钟上升沿 total_amount<=total_amount_ten+total_amount_five;//投入总钱数,十进制,单位角 if total_amount>=15 then money_ok<='1';//投入1.5元,正确 else money_ok<='0'; end if; if (cancel='1') then //取消购买 for i in 0 to 2 loop led_five_return(i)<=return_clk; //退五角钱 end loop; for i in 0 to 1 loop led_ten_return(i)<=return_clk; //退一元 end loop; elseif (pepsi_out='1' or cola_out='1') then case total_amount is when 0 to 14=>for i in 0 to 2 loop //钱数不够1.5元,退钱 led_five_return(i)<=return_clk; end loop; for i in 0 to 1 loop led_ten_return(i)<=return_clk; end loop; when 15=>null; //投入等于1.5元 when 20=>led_five_return(2)<=return_clk; //投入两元,退回一个0.5元硬币 when 25=>led_ten_return(0)<=return_clk; //投入2.5元,退回一个一元硬币 when 30=>led_ten_return(1)<=return_clk; //投入3元,退回一个一元硬币 led_five_return(1)<=return_clk; //一个0.5元硬币 when others=>led_ten_return(0)<=return_clk; led_ten_return(1)<=return_clk; end case; end if; end if; end process; end block; give_check:block //5.1.7出货并计算存货电路模块 signal no_cola:integer range 0 to 20; signal no_pepsi:integer range 0 to 20; begin cola_out<='1' when (money_ok='1' and ok='1' and cola_choice='1') else '0'; led_cola_out<=cola_out; //可乐出货灯亮 pepsi_out<='1' when (money_ok='1' and ok='1' and pepsi_choice='1') else '0'; led_pepsi_out<=pepsi_out; //百事出货灯亮 cola:process(reset,cola_out) begin if reset='1' then no_cola<=20; //复位 led_cola_ok<='1'; elseif rising_edge(cola_out) then //可乐卖出 no_cola<=no_cola-1; //卖出一个计一次数 if no_cola=0 then led_cola_ok<='0'; //可乐全部售出 else led_cola_ok<='1'; //还有存货 end if; end if; end process; pepsi:process(reset,pepsi_out) begin if reset='1' then no_pepsi<=20; //复位 led_pepsi_ok<='1'; elseif rising_edge(pepsi_out) then //百事卖出 no_pepsi<=no_pepsi-1; //卖出一个计一次数 if no_pepsi=0 then led_pepsi_ok<='0';//百事全部售出 else led_pepsi_ok<='1'; //还有存货 end if; end if; end process; end block; end arch;
|
|
相关推荐
1个回答
|
|
这个是VHDL的代码,你花上一天的时间看看VHDL的语法
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1586 浏览 1 评论
1351 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
1563 浏览 0 评论
930 浏览 0 评论
2361 浏览 0 评论
1471 浏览 37 评论
5681 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 19:25 , Processed in 0.436725 second(s), Total 40, Slave 32 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号