下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
排队电路设计(EDA)内容及要求单窗口排队机电路,给每个新来者编号,并计算队伍长度。(1)进队、离队两个信号作为输入,当前服务号码和队长各由4个数码管显示;(2)初始时队长0,进队号码由1顺序递增,输出编号;(3)有人入队,长度加,有人离队长度减;(4)工作时钟适当即可;(5)完成全部流程:设计规范文档、模块设计、代码输入、功能仿真、约束与综合、布局布线、时序仿真、下载验证等。代码如下:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entitycountisport(rst,clk:instd_logic;selbit:outstd_logic_vector(7downto0);--位选数码管signalsel:std_logic_vector(2downto0);jin,chu:instd_logic;--jin为进队信号,chu为出队信号lednum:outstd_logic_vector(6downto0));---输出显示endcount;architecturebehavofcountissignalnum_ll,num_lh,num_hl,num_hh:std_logic_vector(3downto0);-----定义新来者编号signalcus_ll,cus_lh,cus_hl,cus_hh:std_logic_vector(3downto0);----定义当前服务号码signallength_ll,length_lh,length_hl,length_hh:std_logic_vector(3downto0);---定义队伍长度signaltmpbcdnum:std_logic_vector(3downto0);signalcnt4:integerrange0to10;signalsel:std_logic_vector(2downto0);signalcnt10:std_logic_vector(11downto0);signaltmpclk:std_logic;beginp1:process(clk,rst,jin)(输入代码)beginIfrst='1'thennum_ll<="0000";num_lh<="0000";num_hl<="0000";num_hh<="0000";------复位信号则全部清零elsifclk'eventandclk='1'then---时钟上升沿到来且有进队ifjin='1'thennum_ll<=num_ll+1;ifnum_ll<"1001"thennum_ll<=num_ll+1;10elsifnum_lh<"1001"thennum_lh<=num_lh+1;num_ll<="0000";elsifnum_hl<"1001"thennum_hl<=num_hl+1;num_lh<="0000";elsifnum_hh<"1001"thennum_hh<=num_hh+1;num_hl<="0000";elsif(num_ll<="1001"andnum_lh<="1001"andnum_hl<="1001"andnum_hh<="1001")thennum_ll<="0000";num_lh<="0000";num_hl<="0000";num_hh<="0000";----计数,从0000计到9999,再从0000循环;endif;endif;endif;endprocessp1;p2:process(rst,clk,dout)beginifrst='1'thencus_ll<="0000";cus_lh<="0000";cus_hl<="0000";cus_hh<="0000";elsifclk'eventandclk='1'thenifchu='1'thencus_ll<=cus_ll+1;ifcus_ll<"1001"thencus_ll<=cus_ll+1;elsifcus_lh<"1001"thencus_lh<=cus_lh+1;cus_ll<="0000";elsifcus_hl<"1001"thencus_hl<=cus_hl+1;cus_lh<="0000";elsifcus_hh<"1001"thencus_hh<=cus_hh+1;cus_hl<="0000";elsif(cus_ll<="1001"andcus_lh<="1001"andcus_hl<="1001"andcus_hh<="1001")thencus_ll<="0000";cus_lh<="0000";cus_hl<="0000";cus_hh<="0000";endif;----当前服务号码的变化类似于新来者编号endif;endif;endprocessp2;p3:process(rst,tmpclk)beginifrst='1'thencnt4<=0;elsiftmpclk'eventandtmpclk='1'thenifcnt4<8thencnt4<=cnt4+1;elsecnt4<=0;endif;-----计数,为后边扫描信号做准备endif;endprocessp3;free_counter:blocksignalq:std_logic_vector(24downto0);beginp4:process(clk,rst)beginifrst='0'thenq<=(OTHERS=>'0');elsifclk'eventandclk='1'thenq<=q+1;endif;endprocessp4;selout<=sel;sel<="000"whencnt4=0else"001"whencnt4=1else"010"whencnt4=2else"011"whencnt4=3else"100"whencnt4=4else"101"whencnt4=5else"110"whencnt4=6else"111"whencnt4=7else"000";-----实现位选数码管endblockfree_counter;P5:process(rst,clk)beginifrst='0'thencnt10<=0;elsifclk'eventandclk='1'thencnt10<=cnt10+1;----cnt10用来计数实现时钟分频elsecnt10<=0;endif;-----时钟分频endif;endprocessp5;tmpclk<=cnt10(10);p5:process(rst,clk,chu)beginifrst='1'thenlength_ll<="0000";length_lh<="0000";length_hl<="0000";length_hh<="0000";elsifclk'eventandclk='1'thenifchu<='1'thenlength_ll<=num_ll-cus_ll;-----减法得到队长length_lh<=num_lh-cus_lh;---并将值附给相应位length_hl<=num_hl-cus_hl;length_hh<=num_hh-cus_hh;endif;endif;endprocessp5;p6:process(tmpclk,cnt4)beginiftmpclk'eventandtmpclk='1'andcnt4<8thencasecnt4is----扫描信号when0=>selbit<="11111110";tmpbcdnum<=cus_ll;when1=>selbit<="11111101";tmpbcdnum<=cus_lh;when2=>selbit<="11111011";tmpbcdnum<=cus_hl;when3=>selbit<="11110111";tmpbcdnum<=cus_hh;when4=>selbit<="11101111";tmpbcdnum<=length_ll;when5=>selbit<="11011111";tmpbcdnum<=length_lh;when6=>selbit<="10111111";tmpbcdnum<=length_hl;when7=>selbit<="01111111";tmpbcdnum<=length_hh;whenothers=>selbit<="11111111";endcase;endif;endprocessp6;p7:process(tmpbcdnum)begincasetmpbcdnumiswhen"0000"=>lednum<="0111111";when"0001"=>lednum<="0000110";when"0010"=>lednum<="1011011";when"0011"=>lednum<="1001111";when"0100"=>lednum<="1100110";when"
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 云南省昆明市2027年高三第三次模拟考试高考物理试卷(含答案解析)
- 十五五智能无人前台:量子加密技术保障访客隐私安全新路径
- 十五五规划前瞻:智能产康设备纳入国家康复医疗战略体系
- 小镇青年父母画像:智能服药提醒器的下沉市场机遇探析
- 双碳约束下无线睡眠数据网关:能耗优化与ESG合规的商业化路径
- 十五五规划前瞻:智算中心绿色低碳成为国家算力新基建标配
- 河南省郑州市十校联考2026-2027学年高一上学期期中考试语文试题含答案
- 2026年AI+家居行业智能家居系统报告
- 2026年互联网保险行业报告:市场拓展与创新发展
- 2026年纺织行业能源管理优化报告
- 产业研究报告-中国智能车载显示行业发展现状、市场规模、投资前景分析(智研咨询)
- 《医疗器械经营质量管理规范》培训试题及答案
- 2026秋小学英语人教 PEP(三起)四年级上册语法基础易错题练习试题附答案(三套)
- 2026年电池PACK装配工考试试题(含答案)
- (一诊)绵阳市2024级高三第一次诊断性考试英语试卷B卷(含答案及解析)+听力音频
- 2026年河南省巩义市高一化学上册期末考试检测卷含完整答案(全优)
- 手术部位标识管理规范
- 2026云南小龙潭矿务局招聘125人易考易错模拟试题(共500题)试卷后附参考答案
- 2026秋新教科版科学四年级上册教学课件:第三单元 第5课 设计我们的乐器
- XX工程科技创新与“四新技术”应用方案
- 2026年锂电池回收与梯次利用项目可行性研究报告
评论
0/150
提交评论