免费预览已结束,剩余5页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
简易计算器设计电信082班 (合作者:电信082班)指导教师: 2010-6-23(目录)1、 设计要求与计数指标-(1)2、 实验方案-(1)3、 系统软件设计-(1)4、 系统调试-(7)5、 附录一-(8)1 设计任务与要求(或技术指标)1.1 设计任务: 简易计算器设计1.2 技术指标: 1)实现最大输入两位十进制数字的四则运算(加减乘除) 2)能够实现多次连算(无优先级,从左到右计算结果) 3)如 12+3456-7890+9=36.75 4)最大长度以数码管最大个数为限,溢出报警 5)有正负数区分 6)除法不能除尽时小数保留2位有效数字2 方案 用基于Quartus II的CPLD,FPGA方法实现。3系统软件设计 1)输入控制器模块: library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;entity anjian isport( qiehuan,mai_s,mai_f,shu1,shu0,fuhao_in,clear,ok: in std_logic; shu_show: out unsigned(7 downto 0); fuhao_out:out unsigned(1 downto 0); fuhao_show:out unsigned(1 downto 0); shu_suan:out unsigned(7 downto 0) );end anjian;architecture behave of anjian issignal shu_1,shu_0:unsigned(3 downto 0);signal fuhao:unsigned(1 downto 0);begin process(qiehuan,mai_s,mai_f,shu1,shu0,fuhao_in,clear,ok)begin if(clear=0)then shu_1=0000;- else if(fuhao_in event and fuhao_in=1)then fuhao=fuhao+1; end if; if(shu1 event and shu1=1)then if(shu_1=9)then shu_1=shu_1-9; else shu_1=shu_1+1; end if; end if; if(shu0event and shu0=1)then if(shu_0=9)then shu_0=shu_0-9; else shu_0=shu_0+1; end if; end if; shu_show=shu_1&shu_0; fuhao_show=fuhao; if(mai_s event and mai_s=1)then shu_suan=shu_1*1010+shu_0; end if; if(mai_f event and mai_f=1)then fuhao_out=fuhao; end if; end if;end process;end behave; entity anjian2)运算器(实现加法、减法、除法)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;entity yunsuan isport( fuhao_in: in unsigned( 1 downto 0); shu_suan:in unsigned(7 downto 0); clear: in std_logic; shu_answer: out unsigned(35 downto 0); chuf_en: out std_logic; zhengf_out:out std_logic; entity yunsuan answer_in: in unsigned(35 downto 0); -error:out std_logic; ok:in std_logic; mai_s:in std_logic);end yunsuan;-architecture behave of yunsuan issignal fuhao:unsigned( 1 downto 0);signal shu :unsigned( 7 downto 0);shared variable answer: unsigned(35 downto 0);signal zhengf:std_logic:=0;shared variable shu_suan1:unsigned(14 downto 0);signal chengf:unsigned(43 downto 0);beginprocess(fuhao_in,shu_suan,mai_s)begin if(clear=0)then answer:=000000000000000000000000000000000000 ;zhengf if(zhengf=1)then -answer 为负 if(answer_inshu_suan1)then zhengf=1;answer:=answer_in-shu_suan1; else answer:=shu_suan1-answer_in; zhengf=0; end if; else answer:=shu_suan1+answer_in;zhengf=0; end if; chuf_en if(zhengf=0)then -answer 为正 if(answer_inshu_suan1)then zhengf=0;answer:=answer_in-shu_suan1; else answer:=shu_suan1-answer_in; zhengf=1; end if; else answer:=shu_suan1+answer_in;zhengf=1; end if; chuf_en chengf=answer_in*shu_suan;answer:=chengf(35 downto 0);chuf_enanswer:=answer_in;chuf_enanswer:=000000000000000000000000000000000000 ;chuf_en=0; end case; end if;end if;shu_answer=answer;zhengf_out100000000)end process;end behave;3) 调用系统中已有的除法运算模块 4)加减乘的结果或除法的运算结果选择模块 由选择得到本次运算的最终结果library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;entity chufa isport( answer_in,chuf_in:in unsigned(35 downto 0); entity chufa answer_out: out unsigned(35 downto 0); chuf_en: in std_logic; error_out:out std_logic);end chufa;architecture behave of chufa is-signal temp1,temp2,temp3:std_logic;signal answer_o: unsigned(35 downto 0);beginprocess(answer_in,chuf_in,chuf_en)begin if(chuf_en=1)then answer_o=chuf_in; else answer_o99999999)then error_out=1; else error_out=0; end if; answer_out=answer_o; -if(chuf_enevent and chuf_en=1)then - temp1=chuf_en; - temp2=temp1; - temp3=temp2; -end if; -huiz_out=(not temp1) and temp2 and temp3; -if fcevent and fc=1 then - temp1=fm; - temp2=temp1; - temp3=temp2;-end if; -sc=(not temp1) and temp2 and temp3;end process;end behave;5)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity shuma_controll isport(qiehuan:in std_logic; shu_show:in unsigned(7 downto 0); fuhao_show:in unsigned(1 downto 0); answer:in unsigned(31 downto 0); entity shuma_controll pout:out unsigned(31 downto 0);end shuma_controll;architecture behave of shuma_controll isbeginprocess(qiehuan,shu_show,fuhao_show,answer)beginif(qiehuan=1)then pout=answer; elsif(qiehuan=0)then pout=00&fuhao_show&00000000000000000000&shu_show;end if;end process;end behave;6)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity combine isport(p0,p1,p2,p3,p4,p5,p6,p7:unsigned(3 downto 0); q:out unsigned(31 downto 0); end combine;architecture behave of combine isbeginprocess(p0,p1,p2,p3,p4,p5,p6,p7) entity combinebe
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/T 5149-2026镁及镁合金粉
- GB/T 47476-2026智能计算图计算性能测试方法
- 混凝土运输业务外包合同
- 工业厂房工程施工成本控制保证措施
- 劳务人员绩效考评专项方案
- 花市人员服务外包合同
- 监控立杆基础外包合同
- 车间绿色施工方案
- 出租车驾驶员资格考试试题及答案
- 防水施工防滑安全技术交底
- 高危儿早期干预护理策略
- 2025年四川省攀枝花市初二学业水平地理生物会考考试题库(含答案)
- (2026版)市场监督管理投诉举报处理办法课件
- 2026年高考英语作文读后续写题库
- (新版!)2025版医疗器械生产质量管理规范对比自查自评表(可编辑!)
- 2026年建筑二级建造师管理冲刺押题卷
- 2026届高考语文写作押题范文5篇
- 2026工业AI赋能智能制造:从政策驱动到规模化落地
- 常见的酸和碱(第一课时)课件2025-2026学年九年级化学人教版下册
- 合同审查及签约要点提醒检查表模板
- 【答案】《当代社会中的科学与技术》(南京大学)章节期末慕课答案
评论
0/150
提交评论