




已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity calculator is Port(clr,clk,dent,ch,set :in std_logic; add,sub,mul,div :in std_logic; outrange,minus :out logic; led1: out std_logic_vector(6 downto 0); led2: out std_logic_vector(6 downto 0);led3: out std_logic_vector(6 downto 0);led4: out std_logic_vector(6 downto 0); end calculator;architecture Behavioral of calculator issignal sec_1_10,sec1 :std_logic;signal get,minus_sig :integer range 0 to 3;signal choose : integer range 0 to 5;signal chose : integer range 0 to 7;signal L2,LL2,LLL2,LLLL2 : integer range 0 to 10;signal L1,LL1,LLL1,LLLL1: integer range 0 to 10;signal L,LL,LLL,LLLL : integer range 0 to 10;signal nn : integer range 0 to 9999;signal bi : integer range 0 to 20000;begin分频模块 process(clr,clk)variable c: integer range 0 to 10;beginif clr=0 then c:=0;elsif rising_edge(clk) thenif c5 then sec1=1;else sec1=0;end if;end process;process(clr,clk)variable c : integer range 0 to 3200000;begin if clr=0 then c:=0;elsif rising_edge(clk) thenif c1600000 then sec_1_10=1;else sec_1_10=0;end if;end process;键控模块process (sec_1_10,clr,mul,div,sub,add,set)variable cc,dd : std_logic;variable p,pp : integer range 0 to 3;variable c : integer range 0 to 5;variable m : integer range 0 to 7;variable d,e,f,g : integer range 0 to 9;variable ee : integer range 0 to 90;variable ff : integer range 0 to 900;variable gg : integer range 0 to 9000;beginif clr=0 or (mul=0 or div=0 or sub=0 or add=0)and set=1 and ch=1)then c:=0; d:=0; e:=0; f:=0; g:=0;ee:=0; ff:=0; gg:=0; m:=0; p:=0; cc:=0; dd:=0;pp:=0;elsif rising_edge(sec_1_10) thenif dent=1 thenif m7 then m:=m+1;else m:=7;end if;elsif set=0 and add=0 then dd:=1;elsif dd=1 thenif pp3 then pp:=pp+1;else pp:=0;dd:=0;end if;elsif div=0and set=0 then cc:=1;elsif cc=1 thenif p3 then p:=p+1;else p:=3;cc:=0;end if;elsif ch=0 thenif c5 then c:=c+1;else c:=1;end if;elsif c=2 and set=0thenif d9 then d:=d+1;else d:=0;end if;elsif c=3 and set=0thenif e9 then e:=e+1;ee:=ee+10;else e:=0;ee:=0;end if;elsif c=4 and set=0thenif f9 then f:=f+1;ff:=ff+100;else f:=0;ff:=0;end if;elsif c=5 and set=0thenif g9 then g:=g+1;gg:=gg+1000;else g:=0;gg:=0;end if;else null;end if;end if;choose=c;L1=d;LL1=e; LLL1=f; LLLLL1=g;nn=d+ee+ff+gg;chose=m;get=p;minus_sig=pp;end process;运算及存储模块process (clr,sec1,bi)variable min mmin : std_logic;variable ad,sb,mu,dv :std_logic_vector(1 downto 0);variable c,d, f,g,m : integer range 0 to 20000;beginif clr=0 then min:=1; c:=0; d:=0; f:=0; g:=0;bi=0;sb:=“00”;ad :=“00”;mu :=“00”; dv:=“00”;outrange =1;elsif rising_edge(sec1) thenif set=0 and mul=0then mmin:=min;if ad :=“00”and sb :=“00”and mu:=“00” and dv:=“00” then m:=nn;else m:=bi;end if;elsif set=0 and div=0 then bi=m;d:=m;min:=mmin;ad:=“10”;elsif minus_sig=3 then min:=not(min);elsif sub=0 and set=1 then sb:=“01”;ad :=“00”;mu :=“00”; dv:=“00”;elsif add=0 and set=1 then ad:=“01”;sb :=“00”;mu :=“00”; dv:=“00”;elsif mul=0 and set=1 then mu:=“01”;ad :=“00”;sb :=“00”; dv:=“00”;f:=0;g:=0;elsif div=0 and set=1 then dv:=“01”;ad :=“00”;sb :=“00”; mu:=“00”;f:=0; elsif dent=0 and ad=“00” and sb=“00” and mu=“00”and dv=“00”then d:=nn;bi=c then d:=d-c;bi=d;else min:=0;bi=c-d;end if;elsif (c+d)10000 then sb:=“10”;bi=(c+d);else outrange=0;bi=0;end if;elsif ad=“01” and dent=1then c:=nn;if min=1then ad:=“10”;if (c+d)10000 then d:=(c+d);bi=d;else outrange=0;bi=0;end if;elsif cd then bi=d-c;ad:=“10”;else min:=1;bi=c-d;ad:=“10”;end if;elsif mu=“01” and dent=1 then c:=nn;if c=0 or d=0 then bi=0;elsif f9999 then bi=0;outrange=0;else f:=f+1;end if;else bi=g; mu:=“10”;end if;elsif dv=“01” and dent=1 then c:=nn;if c=0 then bi=0;outrange=0;elsif c=1 then bi=c then if f20000 then d:=d-c;f:=f+1;else null;end if;elsif dc/2 then bi=f;dv:=“10”;else bi=f+1;dv:=“10”;end if;else null;end if;end if;minus999 then cc:=cc+1;bb:=bb-1000;elsif bb99 then dd:=dd+1;bb:=bb-100;elsif bb9 then ee:=ee+1;bb:=bb-10;elsif ee=0 and dd=0 and cc=0 then L2=bb;LL2=10;LLL2=10;LLLL2=10;elsif dd=0 and cc=0 then L2=bb;LL2=ee;LLL2=10;LLLL2=10;elsif cc=0 then L2=bb;LL2=ee;LLL2=dd;LLLL2=10;else L2=bb;LL2=ee;LLL2=dd;LLLL2=cc;end if;end if;end process;译码显示电路process (get,chose,sec_1_10,L1,LL1,LLL1,LLLL1,choose,L2,LL2,LLL2,LLLL2)beginif chose=7 or get=3 then L=L2; LL=LL2; LLL=LLL2; LLLL=LLLL2;elsif sec_1_10=1 then L=L1; LL=LL1; LLL=LLL1; LLLL=LLLL1;elsif chose=2 then L=10; LL=LL1; LLL=LLL1; LLLL=LLLL1;elsif chose=3 then L=L1; LL=10; LLL=LLL1; LLLL=LLLL1;elsif chose=4 then L=L1; LL=LL1; LLL=10; LLLL=LLLL1;elsif chose=5 then L=L1; LL=LL1; LLL=LLL1; LLLL=10;else L=L1; LL=LL1; LLL=LLL1; LLLL=LLLL1;end if;end process;led_1:process(L)beginif L=0 then led1=“0000001”;elsif L=1 then led1=“1001111”;elsif L=2 then led1=“0010010”;elsif L=3 then led1=“0000110”;elsif L=4 then led1=“1001100”;elsif L=5 then led1=“0100100”;elsif L=6 then led1=“0100000”;elsif L=7 then led1=“0001111”;elsif L=8 then led1=“0000000”;elsif L=9 then led1=“0000100”;else led1=“1111111”;end if;end process;led_21:process(LL)beginif LL=0 then led2=“0000001”;elsif LL=1 then led2=“1001111”;elsif LL=2 then led2=“0010010”;elsif LL=3 then led2=“0000110”;elsif LL=4 then led2=“1001100”;elsif LL=5 then led2=“0100100”;elsif LL=6 then led2=“0100000”;elsif LL=7 then led1=“0001111”;elsif LL=8 then led2=“0000000”;elsif LL=9 then led2=“0000100”;else led2=“1111111”;end if;end process;led_3:process(LLL)beginif LLL=0 then led3=“0000001”;elsif LLL=1 then led3=“1001111”;elsif LLL=2 then led3=“0010010”;elsif LLL=3 then led3=“0000110”;elsif LLL=4 then led3=
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 宁波卫生职业技术学院《服务营销实务》2023-2024学年第二学期期末试卷
- 四川省成都市双流区双流棠湖中学2025年高考模拟信息考试数学试题(四)含解析
- 辽宁省沈阳市实验中学2024-2025学年高三五月模拟考试物理试题试卷含解析
- 乌海职业技术学院《缅甸国情资料收集与分析中缅双语》2023-2024学年第二学期期末试卷
- 新疆轻工职业技术学院《东方管理学》2023-2024学年第二学期期末试卷
- 上海市嘉定区封浜高级中学2025届高三下期初考试英语试题含解析
- 武汉地区十一校2025届初三月考(一)英语试题含答案
- 咸阳市武功县2024-2025学年数学三下期末学业质量监测模拟试题含解析
- 江苏省盐城市大丰区第一共同体达标名校2025届初三第一次适应性测试自选模块试题含解析
- 凯里学院《理论力学》2023-2024学年第二学期期末试卷
- Unit 3 Section A 3a-3c【 核心精讲+备课精研+高效课堂 】八年级英语下册单元 课件(人教版)
- 美术《印象主义-莫奈》教学课件
- 知识图谱课件
- Taboo and Euphemism 禁忌语和委婉语课件
- 内科体检操作课件
- 薪酬管理第6版第9章课件
- 高中历史选修二 第12课 水陆交通的变迁 课件(51张)
- JJF(纺织)062-2010 电子式织物强力机校准规范-(高清现行)
- 最新北师大版小学六年级数学下册第二次月考(3~4单元)检测试卷附答案
- 非计划再次手术管理制及流程
- 《口腔检查》PPT课件(人卫版)
评论
0/150
提交评论