基于vhdl16位cpu设计说明书.doc_第1页
基于vhdl16位cpu设计说明书.doc_第2页
基于vhdl16位cpu设计说明书.doc_第3页
基于vhdl16位cpu设计说明书.doc_第4页
基于vhdl16位cpu设计说明书.doc_第5页
已阅读5页,还剩39页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

基于VHDL的16位CPU设计一设计要求:完成一个16位CPU的顶层系统设计;完成其指令系统的规划。完成所有模块的VHDL设计。采用QuartusII完成所有模块及顶层的仿真。采用DE2FPGA系统完成整体CPU系统的验证。二CPU的概念CPU 即中央处理单元的英文缩写,它是计算机的核心部件。计算机进行信息处理可分为两个步骤:1) 将数据和程序(即指令序列)输入到计算机的存储器中。 2) 从第一条指令的地址起开始执行该程序,得到所需结果,结束运行。CPU的作用是协调并控制计算机的各个部件执行程序的指令序列,使其有条不紊地进行。因此它必须具有以下基本功能: a)取指令:当程序已在存储器中时,首先根据程序入口地址取出一条程序,为此要发出指令地址及控制信号。 b)分析指令:即指令译码。是对当前取得的指令进行分析,指出它要求什么操作,并产生相应的操作控制命令。 c)执行指令:根据分析指令时产生的“操作命令”形成相应的操作控制信号序列,通过运算器,存储器及输入/输出设备的执行,实现每条指令的功能,其中包括对运算结果的处理以及下条指令地址的形成。三16位CPU结构框图 16位cpu结构由8个16 位的寄存器 reg0 reg7、 一个运算器 ALU、一个移位寄存Shifter、一个程序计数器 PortCnt、 一个指令寄存器 InstrReg、一个工作寄存器OpReg,一个比较器 Comp、一个地址寄存器 Addreg、和一个控制单元 Control组成。这些模块共用一组 16 位的三台数据总线。 系统采用自顶向下的方法进行设计。 顶层设计由微处理器和存储器通过一组双向数据总线连接,它们由一组地址总线和一些控制总线组成。处理器从外存储器中读取指令,并通过执行这些指令来运行程序。这些指令存储在指令寄存器中,并由控制单元译码。控制单元使得相应的信号互相作用,并使处理单元执行这些指令。四各模块的设计分析和设计思路4.1 算术逻辑单元 ALU算术逻辑运算单元根据输入不同操作码分别实现相应的加、与、异或、跳转等基本操作运算。代码:library IEEE;use IEEE.std_logic_1164.all;USE ieee.std_logic_unsigned.all;use work.cpu_lib.all;entity alu isport (a, b: in bit16; sel: in t_alu; c: out bit16);end alu;architecture rtl of alu isbegin aluproc: process (a, b, sel) begincase sel iswhen alupass = c c c c c c c c c c c if a=b then compout = 1 after 1ns; -000: eg else compout if a/=b then compout = 1 after 1ns; -001: neg else compout if ab then compout = 1 after 1ns; -010: gt else compout if a=b then compout = 1 after 1ns; -011: gte else compout if ab then compout = 1 after 1ns; -100: lt else compout if a=b then compout = 1 after 1ns; -101: lte else compout compout = 0;end case;波形图:4.3 寄存器阵列 AYRREGAR在执行指令时,寄存器中存储指令所处理的立即数,可对寄存器进行读或写操作。寄存器组相当于一个 8 x 16 位的 RAM。当向 REGARRAY 的一个单元写数据时,首先输入 sel 作为单元地址,但 clk 上升沿到来时,输入数据就被写入到该单元中。 当从 REGARRAY 的一个地址单元中读出数据时,首先输入 sel 作为读单元的地址,然后使输出允许控制信号 en16 位 CPU 设计为 1,这时数据就会在端口 Q 输出。代码:library IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_unsigned.all;use work.cpu_lib.all;entity regarray is port (data: in bit16; sel: in t_reg; en, clk: in std_logic; q: out bit16);end regarray;architecture rtl of regarray istype t_ram is array (0 to 7) of bit16;signal temp_data: bit16;begin process(clk, sel)variable ramdata : t_ram;begin if clkevent and clk = 1 then ramdata(conv_integer(sel) := data; end if; temp_data = ramdata(conv_integer(sel) ;end process;process (en, temp_data)begin if en = 1 then q = temp_data ; else q = ZZZZZZZZZZZZZZZZ ; end if;end process;end rtl;波形图:4.4 控制器CONTROL控制器提供必要的信号连线,使得数据流完全通过 CPU,达到预期的功能。结构体包含一个状态机,这个状态机根据当前的状态和输入的信号值,输出更新后的状态。之中,输入信号有: 指令信号 instrReg15.0 、比较器输出状态、存储器就绪信号 ready 和 CPU复位信号 reset。输出信号时对指令 instrReg15.0译码以后,对 CPU 所有组成部件按指令要求进行操作所需的控制信号。代码:library IEEE;use IEEE.std_logic_1164.all;use work.cpu_lib.all;entity control isport( clock : in std_logic;reset : in std_logic;instrReg : in bit16;compout : in std_logic;ready : in std_logic;progCntrWr : out std_logic;progCntrRd : out std_logic;addrRegWr : out std_logic;addrRegRd : out std_logic;outRegWr : out std_logic;outRegRd : out std_logic;shiftSel : out t_shift;aluSel : out t_alu;compSel : out t_comp;opRegRd : out std_logic;opRegWr : out std_logic;instrWr : out std_logic;regSel : out t_reg;regRd : out std_logic;regWr : out std_logic;rw : out std_logic;vma : out std_logic);end control;architecture rtl of control issignal current_state, next_state : state;beginnxtstateproc: process( current_state, instrReg, compout, ready)beginprogCntrWr = 0;progCntrRd = 0;addrRegWr = 0;outRegWr = 0;outRegRd = 0;shiftSel = shftpass;aluSel = alupass;compSel = eq;opRegRd = 0;opRegWr = 0;instrWr = 0;regSel = 000;regRd = 0;regWr = 0;rw = 0;vma aluSel = zero after 1 ns ;shiftSel = shftpass;next_state aluSel = zero;shiftSel = shftpass;outRegWr = 1;next_state outRegRd = 1; next_state outRegRd = 1;addrRegRD= 1;progCntrWr = 1;addrRegWr = 1;next_state vma = 1; rw = 0; next_state vma = 1; rw = 0; if ready = 1 then instrWr = 1; next_state = execute; else next_state case instrReg(15 downto 11) iswhen 00000 = - nopnext_state - loadregSel = instrReg(5 downto 3);regRd = 1;next_state - storeregSel = instrReg(2 downto 0);regRd = 1;next_state - moveregSel = instrReg(5 downto 3);regRd = 1;aluSel = alupass;shiftSel = shftpass;next_state - loadIprogcntrRd = 1;alusel = inc;shiftsel = shftpass;next_state - BranchImmprogcntrRd = 1;alusel = inc;shiftsel = shftpass;next_state - BranchGTImmregSel = instrReg(5 downto 3);regRd = 1;next_state - incregSel = instrReg(2 downto 0);regRd = 1;alusel = inc;shiftsel = shftpass;next_state -add regSel = instrReg(5 downto 3); regRd =1; next_state -rotl regSel = instrReg(2 downto 0); regRd =1; next_state next_state regSel = instrReg(2 downto 0); regRd = 1; alusel = alupass; shiftsel = rotl; outregWr = 1; next_state outregRd = 1; next_state outregRd = 1; regsel = instrReg(2 downto 0); regWr = 1; next_state regSel = instrReg(5 downto 3); regRd = 1; addrregWr = 1; next_state vma = 1; rw = 0; next_state vma = 1; rw = 0; regSel = instrReg(2 downto 0); regWr = 1; next_state regSel = instrReg(2 downto 0); regRd = 1; addrregWr = 1; next_state regSel = instrReg(5 downto 3); regRd = 1; next_state regSel = instrReg(5 downto 3); regRd = 1; vma = 1; rw = 1; next_state regSel = instrReg(5 downto 3); regRd = 1; aluSel = alupass; shiftsel = shftpass; outRegWr = 1; next_state outRegRd = 1; next_state outRegRd = 1; regSel = instrReg(2 downto 0); regWr = 1; next_state progcntrRd = 1; alusel = inc; shiftsel = shftpass; outregWr = 1; next_state outregRd = 1; next_state outregRd = 1; progcntrWr = 1; addrregWr = 1; next_state vma = 1; rw = 0; next_state vma = 1; rw = 0; if ready = 1 then-regSel = instrReg(2 downto 0); -regWr = 1;next_state = loadI7;elsenext_state regSel=instrReg(2 downto 0); regWr=1; next_stateprogcntrRd = 1;alusel = inc;shiftsel = shftpass;outregWr = 1;next_state outregRd = 1;next_state outregRd = 1;progcntrWr = 1;addrregWr = 1;next_state vma = 1;rw = 0;next_state vma = 1;rw = 0;if ready = 1 then-progcntrWr = 1;next_state = loadPc;elsenext_state regSel = instrReg(5 downto 3);regRd = 1;opRegWr = 1;next_state opRegRd = 1;regSel = instrReg(2 downto 0);regRd = 1;compsel = gt;next_state opRegRd = 1 ;regSel = instrReg(2 downto 0);regRd = 1;compsel = gt;if compout = 1 thennext_state = bgtI5;elsenext_state progcntrRd = 1;alusel = inc;shiftSel = shftpass;next_state progcntrRd = 1;alusel = inc;shiftsel = shftpass;outregWr = 1;next_state outregRd = 1;next_state outregRd = 1;progcntrWr = 1;addrregWr = 1;next_state vma = 1;rw = 0;next_state vma = 1;rw = 0;if ready = 1 thenprogcntrWr = 1;next_state = loadPc;elsenext_state regSel = instrReg(2 downto 0);regRd = 1;alusel = inc;shiftsel = shftpass;outregWr = 1;next_state outregRd = 1;next_state outregRd = 1;regsel = instrReg(2 downto 0);regWr = 1;next_state progcntrWr=1;-progcntrRd = 1;next_state progcntrRd = 1;addrRegWr = 1;next_state vma = 1;rw = 0;next_state vma = 1;rw = 0;if ready = 1 theninstrWr = 1;next_state = execute;elsenext_state regSel=instrReg(5 downto 3); regRd=1; opRegWr=1; next_state - opRegRd=1; regSel=instrReg(2 downto 0); next_state opRegRd=1; regSel=instrReg(2 downto 0); regRd=1; opRegRd=1; alusel = plus; shiftsel = shftpass; next_state opRegRd=1; regSel=instrReg(2 downto 0); regRd=1; alusel = plus; outRegWr=1;- opRegRd=1; - alusel = plus; shiftsel = shftpass; next_state - outRegWr=1; outRegRd=1; next_state outRegRd=1; regSel=instrReg(2 downto 0); regWr=1; next_state progcntrRd = 1; alusel = inc; shiftsel = shftpass; next_state progcntrRd = 1;alusel = inc;shiftsel = shftpass;outregWr = 1;next_state outregRd = 1;next_state outregRd = 1;progcntrWr = 1;addrregWr = 1;next_state vma = 1;rw = 0;next_state vma = 1;rw = 0;if ready = 1 theninstrWr = 1;next_state = execute;elsenext_state next_state = incPc;end case;end process;controlffProc: process(clock, reset)beginif reset = 1 thencurrent_state = reset1 ;elsif clockevent and clock = 1 thencurrent_state y y y y y y = 0000000000000000 ;end case;end process;end rtl;波形图:当sel=000时,表示直通;当sel=001时,表示无符号左移;当sel=010时,表示无符号右移;当sel=011时,表示循环左移;当sel=100时,表示循环右移;当sel为其他值时,输出为0.4.6三态寄存器TRIREG 代码:library IEEE;use IEEE.std_logic_1164.all;use ieee.std_logic_unsigned.all;use work.cpu_lib.all;entity trireg isport( a : in bit16;en : in std_logic;clk : in std_logic;q : out bit16);end trireg;architecture rtl of trireg issignal val : bit16;begintriregdata: processbeginwait until clkevent and clk = 1;val = a;end process;trireg3st: process(en, val)beginif en = 1 thenq = val ;elsif en = 0 thenq = ZZZZZZZZZZZZZZZZ ; - exemplar_translate_offelseq = XXXXXXXXXXXXXXXX ; - exemplar_translate_onend if;end process;end rtl;波形图:4.7实验总结与心得通过这次做实验,熟练地掌握了quartus的使用方法,能够很熟练的进行实验了。由于这个实验有参考的verilogHDL程序,可以直接翻译过来,所以做起来还是比较轻松的,通过做这次实验,在用VHDL写出状态控制器之外,还了解了一些verilogHDL的基本语法知识,这对于以后学习该语言有一定的作用。做这个实验的时候,出现的问题少,自己对软件的使用也比较熟练了,这验证了孰能生巧这一事实,以后还要多多的联系,实际操作,做一些课题。程序调试时,用了比较多的时间,可以说这个程序是调试出来的,而不是写出来的。 通过这次实验,对CPU的工作原理有了深入的了解,也知道了机器码的实现方法,对自己的学习有很大的帮助。39大学本科生毕业设计(论文)撰写规范本科生毕业设计(论文)是学生在毕业前提交的一份具有一定研究价值和实用价值的学术资料。它既是本科学生开始从事工程设计、科学实验和科学研究的初步尝试,也是学生在教师的指导下,对所进行研究的适当表述,还是学生毕业及学位资格认定的重要依据。毕业论文撰写是本科生培养过程中的基本训练环节之一,应符合国家及各专业部门制定的有关标准,符合汉语语法规范。指导教师应加强指导,严格把关。1、论文结构及要求论文包括题目、中文摘要、外文摘要、目录、正文、参考文献、致谢和附录等几部分。1.1 题目论文题目应恰当、准确地反映论文的主要研究内容。不应超过25字,原则上不得使用标点符号,不设副标题。1.2 摘要与关键词1.2.1 摘要本科生毕业设计(论文)的摘要均要求用中、英两种文字给出,中文在前。摘要应扼要叙述论文的研究目的、研究方法、研究内容和主要结果或结论,文字要精炼,具有一定的独立性和完整性,摘要一般应在300字左右。摘要中不宜使用公式、图表,不标注引用文献编号,避免将摘要写成目录式的内容介绍。1.2.2 关键词关键词是供检索用的主题词条,应采用能覆盖论文主要内容的通用技术词条(参照相应的技术术语标准),一般列35个,按词条的外延层次从大到小排列,应在摘要中出现。1.3 目录目录应独立成页,包括论文中全部章、节的标题及页码。1.4 论文正文论文正文包括绪论、论文主体及结论等部分。1.4.1 绪论绪论一般作为论文的首篇。绪论应说明选题的背景、目的和意义,国内外文献综述以及论文所要研究的主要内容。文管类论文的绪论是毕业论文的开头部分,一般包括说明论文写作的目的与意义,对所研究问题的认识以及提出问题。绪论只是文章的开头,不必写章号。毕业设计(论文)绪论部分字数不多于全部论文字数的1/4。1.4.2 论文主体论文主体是论文的主要部分,要求结构合理,层次清楚,重点突出,文字简练、通顺。论文主体的内容要求参照大学本科生毕业设计(论文)的规定第五章。论文主体各章后应有一节“本章小结”。1.4.3 结论结论作为单独一章排列,但不加章号。结论是对整个论文主要成果的归纳,要突出设计(论文)的创新点,以简练的文字对论文的主要工作进行评价,一般为4001 000字。1.5 参考文献参考文献是论文不可缺少的组成部分,它反映了论文的取材来源和广博程度。论文中要注重引用近期发表的与论文工作直接有关的学术期刊类文献。对理工类论文,参考文献数量一般应在15篇以上,其中学术期刊类文献不少于8篇,外文文献不少于3篇;对文科类、管理类论文,参考文献数量一般为1020篇,其中学术期刊类文献不少于8篇,外文文献不少于3篇。在论文正文中必须有参考文献的编号,参考文献的序号应按在正文中出现的顺序排列。产品说明书、各类标准、各种报纸上刊登的文章及未公开发表的研究报告(著名的内部报告如PB、AD报告及著名大公司的企业技术报告等除外)不宜做为参考文献引用。但对于工程设计类论文,各种标准、规范和手册可作为参考文献。引用网上参考文献时,应注明该文献的准确网页地址,网上参考文献不包含在上述规定的文献数量之内。1.6 致谢对导师和给予指导或协助完成论文工作的组织和个人表示感谢。内容应简洁明了、实事求是,避免俗套。1.7 附录如开题报告、文献综述、外文译文及外文文献复印件、公式的推导、程序流程图、图纸、数据表格等有些不宜放在正文中,但有参考价值的内容可编入论文的附录中。2、论文书写规定2.1 论文正文字数理工类 论文正文字数不少于20 000字。文管类 论文正文字数12 00020 000字。其中汉语言文学专业不少于7 000字。外语类 论文正文字数8 00010 000个外文单词。艺术类 论文正文字数3 0005 000字。2.2 论文书写本科生毕业论文用B5纸计算机排版、编辑与双面打印输出。论文版面设置为:毕业论文B5纸、纵向、为横排、不分栏,上下页边距分别为2.5cm和2cm,左右页边距分别为2.4cm和2cm,对称页边距、左侧装订并装订线为0cm、奇偶页不同、无网格。论文正文满页为29行,每行33个字,字号为小四号宋体,每页版面字数为957个,行间距为固定值20磅。页眉。页眉应居中置于页面上部。单数页眉的文字为“章及标题”;双数页眉的文字为“大学本科生毕业设计(论文)”。页眉的文字用五号宋体,页眉文字下面为2条横线(两条横线的长度与版芯尺寸相同,线粗0.5磅)。页眉、页脚边距分别为1.8cm和1.7cm。页码。页码用小五号字,居中标于页面底部。摘要、目录等文前部分的页码用罗马数字单独编排,正文以后的页码用阿拉伯数字编排。2.3 摘要中文摘要一般为300字左右,外文摘要应与中文摘要内容相同,在语法、用词和书写上应正确无误,摘要页勿需写出论文题目。中、外文摘要应各占一页,编排装订时放置正文前,并且中文在前,外文在后。2.4 目录目录应包括论文中全部章节的标题及页码,含中、外文摘要;正文章、节题目;参考文献;致谢;附录。正文章、节题目(理工类要求编写到第3级标题,即.。文科、管理类可视论文需要进行,编写到23级标题。)2.5 论文正文2.5.1 章节及各章标题论文正文分章、节撰写,每章应另起一页。各章标题要突出重点、简明扼要。字数一般在15字以内,不得使用标点符号。标题中尽量不用英文缩写词,对必须采用者,应使用本行业的通用缩写词。2.5.2 层次层次以少为宜,根据实际需要选择。层次代号格式见表1和表2。表1 理工类论文层次代号及说明层次名称示 例说 明章第1章 章序及章名居中排,章序用阿拉伯数字节1.1 题序顶格书写,与标题间空1字,下面阐述内容另起一段条1.1.1 款 题序顶格书写,与标题间空1字,下面阐述内容在标题后空1字接排项 (1) 题序空2字书写,以下内容接排,有标题者,阐述内容在标题后空1字 版心左边线 版心右边线表2 文管类论文层次代号及说明章节条款项一、 (一) 1. (1)居中书写空2字书写空2字书写空2字书写空2字书写 版心左边线 版心右边线各层次题序及标题不得置于页面的最后一行(孤行)。2.6 参考文献正文中引用文献标示应置于所引内容最末句的右上角,用小五号字体。所引文献编号用阿拉伯数字置于方括号“ ”中,如“二次铣削1”。当提及的参考文献为文中直接说明时,其序号应该与正文排齐,如“由文献8,1014可

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论