计算机组成原理课程设计报告-基于vhdl的自动售货机设计与实现内容摘要:

控制器 译码 RAM 分频器 显示 控制系统 金额模块 显示模块 物品模块 信号模块 梁正凯 基于 VHDL 的自动售货机的设计与实现 第 10 页 共 21 页 10 ① 金额模块:用于依据设置的金额,计算用户投币的总金额,物品的单价、总价,以及用户的余额。 ② 显示模块 :将计算的结果及用户操作信号译码后显示在显示屏上。 ③ 物品模块:记录物品的种类、对应的单价、以及其数量 ④ 信号模块:系统对系统时钟,用户的买、选择、完成信号,显示 开关信号等信号的设置。 程序源代码 梁正凯 基于 VHDL 的自动售货机的设计与实现 第 11 页 共 21 页 11 文件名:。 功能:货物信息存储,进程控制,硬币处理,余额计算,显示等功能。 说明:显示的钱数 coin 的 以 5 角为单位。 library ieee。 use。 use。 use。 entity PL_auto1 is port ( clk:in std_logic。 系统时钟 set,get,sel,finish: in std_logic。 设定、买、选择、完成信号 coin0,coin1: in std_logic。 5 角硬币、 1 元硬币 price,quantity :in std_logic_vector(3 downto 0)。 价格、数量数据 item0 , act:out std_logic_vector(3 downto 0)。 显示、开关信号 y0,y1 :out std_logic_vector(6 downto 0)。 钱数、商品数量显示数据 act10,act5 :out std_logic)。 1 元硬币、 5 角硬币 end PL_auto1。 architecture behav of PL_auto1 is type ram_type is array(3 downto 0)of std_logic_vector(7 downto 0)。 signal ram :ram_type。 定义 RAM signal item: std_logic_vector(1 downto 0)。 商品种类 signal coin: std_logic_vector(3 downto 0)。 币数计数器 signal pri,qua:std_logic_vector(3 downto 0)。 商品单价、数量 signal clk1: std_logic。 控制系统的时钟信号 begin :process(set,clk1) variable quan:std_logic_vector(3 downto 0)。 begin if set=39。 139。 then ram(conv_integer(item))=price amp。 quantity。 act=0000。 把商品的单价、数量置入到 RAM elsif clk139。 event and clk1=39。 139。 then act5=39。 039。 act10=39。 039。 if coin0=39。 139。 then if coin1001then coin=coin+1。 投入 5 角硬币, coin 自加1 else coin=0000。 end if。 elsif coin1=39。 139。 then if coin1001then coin=coin+2。 投入 1 元硬币, coin 自加2 梁正凯 基于 VHDL 的自动售货机的设计与实现 第 12 页 共 21 页 12 else coin=0000。 end if。 elsif sel=39。 139。 then item=item+1。 对商品进行循环选择 elsif get=39。 139。 then 对商品进行购买。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。