现代计算机组成原理(潘松,潘明编著)思维导图
- 格式:xmin
- 大小:7.94 KB
- 文档页数:1
现代计算机组成原理潘明潘松编著科学出版社第6 章16位CISC CPU设计6.1 顶层系统设计6.1.1 16位CPU的组成结构图6-1 16位CPU结构框图6.1 顶层系统设计6.1.2指令系统设计1.指令格式(1)单字指令表6-1 单字节指令格式6.1 顶层系统设计(2)双字指令表6-2 双字指令格式表6-3 双字节指令2.指令操作码表6-4 操作码功能表6.1 顶层系统设计6.1.2指令系统设计6.1 顶层系统设计6.1.2指令系统设计2.指令操作码表6-5 常用指令举例6.1 顶层系统设计6.1.3 顶层结构的VHDL设计1. CPU元件的VHDL描述【例6-1】CPU_LIB.VHDlibrary IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_arith.all;package cpu_lib istype t_shift is (shftpass,shl,shr,rotl,rotr);subtype t_alu is unsigned(3downto0);(接下页)6.1 顶层系统设计6.1.3 顶层结构的VHDL设计1. CPU元件的VHDL描述constant alupass : unsigned(3downto 0) := "0000";constant andOp : unsigned(3downto 0) := "0001";constant orOp : unsigned(3downto 0) := "0010";constant notOp : unsigned(3downto 0) := "0011";constant xorOp : unsigned(3downto 0) := "0100";constant plus : unsigned(3downto 0) := "0101";constant alusub : unsigned(3downto 0) := "0110";constant inc : unsigned(3downto 0) := "0111";constant dec : unsigned(3downto 0) := "1000";constant zero : unsigned(3downto 0) := "1001";type t_comp is (eq,neq,gt,gte,lt,lte);subtype t_reg is std_logic_vector(2downto 0);type state is (reset1, reset2, reset3, reset4, reset5,reset6, execute,nop, load, store, move,load2, load3, load4, store2, store3,store4, move2, move3, move4,incPc, incPc2,incPc3, incPc4, incPc5, incPc6,loadPc,loadPc2,loadPc3, loadPc4, bgtI2, bgtI3,bgtI4, bgtI5, bgtI6, bgtI7,bgtI8, bgtI9,bgtI10, braI2, braI3, braI4, braI5, braI6,loadI2,loadI3, loadI4, loadI5, loadI6,inc2, inc3, inc4);subtype bit16 is std_logic_vector(15downto 0);end cpu_lib;6.1 顶层系统设计6.1.3 顶层结构的VHDL设计1. CPU元件的VHDL描述【例6-2】top.vhdlibrary IEEE;use IEEE.std_logic_1164.all;use work.cpu_lib.all;entity top isend top;architecture behave of top iscomponent mem port (addr : in bit16;sel,rw : in std_logic ;ready : out std_logic ;data :inout bit16);end component;component cpuport(clock, reset, ready : in std_logic ;addr : out bit16;rw,vma : out std_logic ;data :inout bit16);end component;signal addr, data : bit16 ;signal vma,rw, ready : std_logic ;signal clock, reset : std_logic := '0';beginclock <= not clock after 50 ns ;reset <= '1', '0' after 100 ns ;m1 :mem port map (addr,vma,rw, ready, data);u1 :cpu port map(clock, reset, ready,addr,rw,vma,data);end behave;2. 顶层文件的原理图设计6.1 顶层系统设计6.1.3 顶层结构的VHDL设计(接下页)图6-2CPU顶层结构图6.1 顶层系统设计6.1.3 顶层结构的VHDL设计3.CPU与LCD显示模块的接口图6-3 显示模块dsp的实体结构图6.1 顶层系统设计6.1.3 顶层结构的VHDL设计3.CPU与LCD显示模块的接口图6-4 LCD显示屏的数据显示6.1 顶层系统设计6.1.4 软件设计实例表6-6 示例程序6.2.1 运算器ALU6.2 CPU基本部件设计6.2.1 运算器ALU图6-5 运算器ALU 结构图【例6-3】alu.vhd library IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_unsigned.all;use work.cpu_lib.all;entity alu is port( a, b : in bit16;sel : in t_alu; c : out bit16 );end alu;architecture rtl of alu is beginaluproc: process(a, b,sel)begin case sel iswhen alupass=> c<=a after 1 ns; when andOp => c<=a and b after 1 ns;when orOp => c<= a or b after 1 ns; when xorOp => c<= a xor b after 1 ns;when notOp => c<= not a after 1 ns; when plus => c<= a + b after 1 ns;when alusub => c<= a -b after 1 ns;when inc => c<= a + "0000000000000001" after 1 ns;when dec => c<= a -"0000000000000001" after 1 ns;when zero => c<= "0000000000000000" after 1 ns;when others => c<= "0000000000000000" after 1 ns;end case;end process;end rtl;6.2.1 运算器ALU6.2.1 运算器ALUC=00006.2.2 比较器COMP6.2.2 比较器COMP6.2 CPU基本部件设计6.2.2 比较器COMP【例6-4】COMP.VHD library IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_arith.all;use IEEE.std_logic_unsigned.all;use work.cpu_lib.all;entity comp isport( a, b : in bit16;sel : in t_comp ;compout : out std_logic);end comp;architecture rtl of comp is begincompproc: process(a, b,sel)begin case sel iswhen eq => if a = b then compout <= '1' after 1 ns ;else compout <='0' after 1 ns ;end if ;when neq => if a /= b then compout <= '1' after 1 ns;else compout <= '0' after 1 ns ;end if ;when gt => if a > b then compout <= '1' after 1 ns;else compout <= '0' after 1 ns ;end if ;when gte => if a >= b then compout <= '1'after 1 ns ;else compout <= '0' after 1 ns ;end if;when lt => if a < b then compout <= '1' after 1 ns ;else compout <= '0' after 1 ns ;end if;when lte => if a <= b then compout <= '1' after 1 ns ;else compout <= '0' after 1 ns ;end if;end case ;end process ;end rtl ;6.2.2 比较器COMP6.2 CPU基本部件设计6.2.3 控制器CONTROL图6-9 控制器CONTROL的实体结构图【例6-5】control.vhdlibrary IEEE;use IEEE.std_logic_1164.all;use work.cpu_lib.all;entity control isport( clock,reset ,ready,compout: in std_logic;instrReg: in bit16; progCntrWr,progCntrRd,addrRegWr,addrRegRd,outRegWr,outRegRd: out std_logic;shiftSel: out t_shift;aluSel: out t_alu;compSel: out t_comp;opRegRd,opRegWr,instrWr,regRd,regWr,rw,vma: out std_logic; regSel: out t_reg);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<= '0';case current_state iswhen reset1=>aluSel<=zero after 1 ns;shiftSel<=shftpass; next_state<=reset2; when reset2 =>aluSel<=zero;shiftSel<=shftpass;outRegWr<='1'; (接下页)next_state<=reset3;when reset3 =>outRegRd<='1'; next_state<=reset4;when reset4 =>outRegRd<='1';addrRegRd<='1';progCntrWr<='1';addrRegWr<='1'; next_state<=reset5;when reset5 =>vma<='1';rw<= '0'; next_state <= reset6;when reset6 =>vma<='1';rw<='0';if ready = '1' then instrWr<='1'; next_state<=execute;else next_state <= reset6; end if;when execute => case instrReg(15downto11) iswhen "00000" => next_state <=incPc;--nopwhen "00001" =>regSel<=instrReg(5downto3);regRd<='1'; next_state<=load2;when "00010" =>regSel<=instrReg(2downto0);regRd<='1';next_state<=store2;--storewhen "00011" =>regSel<=instrReg(5downto3);regRd<='1';aluSel<=alupass;shiftSel<=shftpass; next_state<=move2;when "00100" =>progcntrRd<='1';alusel<=inc;shiftsel<=shftpass;next_state<=loadI2;when "00101" =>progcntrRd<='1';alusel<=inc;shiftsel<=shftpass;next_state<=braI2;when "00110" =>regSel<=instrReg(5downto3);regRd<='1';next_state<=bgtI2;--BranchGTImmwhen "00111" =>regSel<=instrReg(2downto0);regRd<='1';alusel<=inc;(接下页)shiftsel<=shftpass; next_state<=inc2;when others =>next state <=incPc;end case;when load2 =>regSel<=instrReg(5downto3);regRd<= '1';addrregWr<= '1'; next_state <= load3;when load3 =>vma<= '1';rw<= '0'; next_state <= load4;when load4 =>vma<= '1';rw<= '0';regSel<=instrReg(2downto0);regWr<= '1'; next_state <=incPc;when store2 =>regSel<=instrReg(2downto0);regRd<= '1';addrregWr<= '1'; next_state <= store3;when store3 =>regSel<=instrReg(5downto3);regRd<= '1';next_state <= store4;when store4 =>regSel<=instrReg(5downto3);regRd<= '1';vma<= '1';rw<= '1'; next_state <=incPc;when move2 =>regSel<=instrReg(5downto3);regRd<= '1';aluSel<= alupass;shiftsel<=shftpass;outRegWr<= '1'; next_state <= move3;when move3 =>outRegRd<= '1'; next_state <= move4;when move4 =>outRegRd<= '1';regSel<=instrReg(2downto0);regWr<= '1'; next_state <=incPc;when loadI2 =>progcntrRd<= '1';alusel<= inc;shiftsel<=shftpass;outregWr<= '1'; next_state <= loadI3;when loadI3 =>outregRd<= '1'; next_state <= loadI4;when loadI4 =>outregRd<= '1';progcntrWr<='1';addrregWr<='1';next_state<=loadI5;(接下页)when loadI5 =>vma<= '1';rw<= '0'; next_state <= loadI6;when loadI6 =>vma<= '1';rw<= '0';if ready = '1' then regSel<=instrReg(2downto0);regWr<= '1'; next_state <=incPc;else next_state <= loadI6; end if;when braI2 =>progcntrRd<= '1';alusel<= inc;shiftsel<=shftpass; outregWr<= '1'; next_state <= braI3;when braI3 =>outregRd<= '1'; next_state <= braI4;when braI4 =>outregRd<='1';progcntrWr<='1';addrregWr<='1';next_state<=braI5;when braI5 =>vma<='1';rw<='0'; next_state <= braI6;when braI6 =>vma<= '1';rw<= '0';if ready = '1' then progcntrWr<= '1'; next_state <=loadPc;else next_state <= braI6; end if;when bgtI2 =>regSel<=instrReg(5downto3);regRd<= '1';opRegWr<= '1'; next_state <= bgtI3;when bgtI3 =>opRegRd<= '1';regSel<=instrReg(2downto0);regRd<= '1';compsel<=gt; next_state <= bgtI4;when bgtI4 =>opRegRd<= '1' after 1 ns;regSel<=instrReg(2downto0);regRd<= '1';compsel<=gt;if compout= '1' then next_state <= bgtI5;else next_state <=incPc; end if;when bgtI5 =>progcntrRd<='1';alusel<=inc;shiftSel<=shftpass;next_state<=bgtI6;when bgtI6 =>progcntrRd<= '1';alusel<= inc;shiftsel<=shftpass; outregWr<= '1'; next_state <= bgtI7;(接下页)when bgtI7 =>outregRd<= '1'; next_state <= bgtI8;when bgtI8 =>outregRd<= '1';progcntrWr<= '1';addrregWr<= '1'; next_state <= bgtI9;when bgtI9 =>vma<= '1';rw<= '0'; next_state <= bgtI10;when bgtI10 =>vma<= '1';rw<= '0';if ready = '1' then progcntrWr<= '1'; next_state <=loadPc;else next_state <= bgtI10; end if;when inc2 =>regSel<=instrReg(2downto0);regRd<= '1';alusel<= inc; shiftsel<=shftpass;outregWr<= '1'; next_state <= inc3;when inc3 =>outregRd<= '1'; next_state <= inc4;when inc4 =>outregRd<= '1';regsel<=instrReg(2downto0);regWr<= '1'; next_state <=incPc;when loadPc=>progcntrRd<= '1'; next_state <= loadPc2;when loadPc2 =>progcntrRd<= '1';addrRegWr<= '1'; next_state <= loadPc3; when loadPc3 =>vma<= '1';rw<= '0'; next_state <= loadPc4;when loadPc4 =>vma<= '1';rw<= '0';if ready = '1' then instrWr<= '1'; next_state <= execute;else next_state <= loadPc4; end if;when incPc=>progcntrRd<='1';alusel<=inc;shiftsel<=shftpass;next_state<=incPc2;when incPc2 =>progcntrRd<= '1';alusel<= inc;shiftsel<=shftpass; outregWr<= '1'; next_state <= incPc3;when incPc3 =>outregRd<= '1'; next_state <= incPc4;when incPc4 =>outregRd<='1';progcntrWr<='1';(接下页)addrregWr<='1'; next_state<=incPc5;when incPc5 =>vma<= '1';rw<= '0'; next_state <= incPc6; when incPc6 =>vma<= '1';rw<= '0';if ready = '1' then instrWr<= '1'; next_state <= execute; else next_state <= incPc6; end if;when others => next_state <=incPc;end case;end process;controlffProc:process(clock, reset)beginif reset = '1' then current_state <= reset1 after 1 ns;elsif clock'event and clock = '1'then current_state <= next_state after 1 ns; end if;end process;end rtl;6.2.4 寄存器与寄存器阵列6.2 CPU基本部件设计6.2.4 寄存器与寄存器阵列1.寄存器REG【例6-6】reg.vhdlibrary IEEE;use IEEE.std_logic_1164.all;use work.cpu_lib.all;entity reg isport( a : in bit16;clk: in std_logic; q : out bit16);end reg;architecture rtl of reg isbeginregproc: processbeginwait until clk' event and clk= '1';q <= a after 1 ns;end process;end rtl;6.2 CPU基本部件设计2.寄存器阵列RegArray 【例6-7】regarray.vhdlibrary IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_unsigned.all;use work.cpu_lib.all;entity regarray isport( 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;beginprocess(clk,sel)variable ramdata : t_ram;beginif clk'event and clk = '1' then ramdata(conv_integer(sel)) := data;end if;temp_data <=ramdata(conv_integer(sel)) after 1 ns;end process;process(en, temp_data)beginif en = '1' then q <= temp_data after 1 ns;else q <="ZZZZZZZZZZZZZZZZ" after 1 ns; end if;end process;end rtl;6.2.4 寄存器与寄存器阵列6.2.4 寄存器与寄存器阵列6.2.5 移位寄存器SHIFT【例6-8】sheft.VHDlibrary IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_arith.all;use work.cpu_lib.all;entity shift isport ( a : in bit16;sel: in t_shift ; y : out bit16);end shift;architecture rtl of shift isbeginshftproc: process(a,sel)begincase sel iswhen shftpass=>y <= a after 1 ns;when sftl=>y <= a(14downto0) & '0' after 1 ns;when sftr=>y <= '0' & a(15downto1) after 1 ns;when rotl=>y <= a(14downto0) & a(15) after 1 ns;when rotr=>y <= a(0) & a(15downto1) after 1 ns;when others =>y <= "0000000000000000" after 1 ns;end case;end process;end rtl;6.2 CPU基本部件设计6.2.5 移位寄存器SHIFT表6-12 SHIFT移位运算类型说明6.2.5 移位寄存器SHIFT6.2.5 移位寄存器SHIFT6.2.6 三态寄存器TRIREG6.2 CPU基本部件设计6.2.6 三态寄存器TRIREG 【例6-9】triReg.vhdlibrary IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_unsigned.all;use work.cpu_lib.all;entity trireg is port( a : in bit16; en ,clk : in std_logic; q : out bit16);end trireg;architecture rtl of trireg issignal val : bit16;begintriregdata: processbeginwait until clk'event and clk = '1';val <= a;end process;trireg3st: process(en,val)beginif en = '1' then q <=val after 1 ns;elsif en = '0' then q <= "ZZZZZZZZZZZZZZZZ" after 1 ns;else q <= "XXXXXXXXXXXXXXXX" after 1 ns; --exemplar_translate_on end if;end process;end rtl;6.3 CPU的时序仿真与实现6.3.1 编辑仿真波形文件1.建立仿真波形VWF文件通过仿真波形分析,可以了解CPU在执行指令过程中,各信号的工作时序是否符合设计要求。
计算机的定义与发展计算机的定义计算机的发展计算机经历了从机械计算机、电子管计算机、晶体管计算机、集成电路计算机到超大规模集成电路计算机的五个发展阶段。
包括中央处理器、存储器、输入输出设备等,是计算机的物理基础。
硬件系统包括系统软件和应用软件,是计算机的功能基础。
软件系统是计算机处理的对象,包括数字、文字、图像、音频和视频等。
数据计算机系统的组成计算机的工作原理存储程序原理01二进制原理02指令周期原理03数制与编码数制的基本概念奇偶校验编码方式逻辑代数基础逻辑变量与逻辑函数示方法。
逻辑代数的基本公式和定理逻辑运算逻辑门电路基本逻辑门电路介绍与门、或门、非门等基本逻辑门电路的工作原理及实现方法。
复合逻辑门电路讲解与非门、或非门、异或门等复合逻辑门电路的工作原理及实现方法。
逻辑门电路的应用阐述逻辑门电路在组合逻辑电路和时序逻辑电路中的应用。
数值数据的表示定点数表示法浮点数表示法原码、反码和补码非数值数据的表示ASCII码汉字编码Unicode编码数据校验方法奇偶校验通过在数据位后面添加一位校验位,使得整个数据中1的个数为偶数(偶校验)或奇数(奇校验)。
海明校验通过在数据位中插入多个校验位,利用这些校验位来检测和纠正一位或多位的错误。
循环冗余校验(CRC)通过对待发送的数据进行多项式计算,生成一个校验码附加在数据后面,接收方通过同样的多项式计算来验证数据的正确性。
定点数的表示方法定点数的加减运算定点数的乘除运算浮点数的表示方法浮点数的加减运算浮点数的乘除运算对阶、尾数加减、规格化、舍入处理阶码加减、尾数乘除、规格化与舍入处理IEEE 754标准(单精度、双精度)运算器的组成与设计运算器的基本结构运算器的设计原则运算器的实现技术运算器的性能指标01指令格式02寻址方式03指令周期指令格式与寻址方式概述指令的寻址过程与数据传送方式指令的寻址过程数据传送方式数据传送过程立即寻址操作数就在指令中,紧跟在操作码后面,作为指令一部分存放在内存的代码段中,该操作数为立即数,这种寻址方式称为立即寻址方式。
《微处理器系统结构与嵌入式系统设计》教学大纲教案课程英文名称:Microcomputer System Theory and Embedded System Design课程代码:E0130340 学时数:64 学分数:4课程类型:学科基础课程适用学科专业:工学,仪器仪表类、电气类、电子信息类、自动化类、计算机类各专业以及机械类、测绘类、航空航天类、能源动力类、交通运输类、生物医疗工程类各相关专业先修课程:数字逻辑设计及应用,高级语言程序设计,软件技术基础执笔者:编写日期:审核人:一、课程简介本课程是工学电子电气信息工程及相关专业的学科基础课程,与实践类课程《微处理器系统与嵌入式系统综合设计》(课程代码:K0175010)互为配套课程。
本课程在阐述通用微处理器系统的架构、组成及工作原理的基础上,介绍了基于ARM CPU的、现代嵌入式微系统的设计与实现技术。
课程全面涵盖了微处理器、存储器、总线及接口等计算机子系统,重点体现了嵌入式系统/片上系统中硬件电路和软件程序的协同工作原理与设计方法,具体讲述了微处理器中数据通路、控制部件及指令的实现技术、分层存储器设计技术、输入/输出接口控制技术,以及ARM微处理器程序设计技术、异常处理技术,嵌入式系统引导程序设计、接口驱动程序设计及操作系统移植等内容。
This course is a basic subject-centered course in electrical and electronic information engineering and other related specialties. It will be helpful to understand the knowledge of the co-requisite experimental course K0175010 - Microprocessor and Embedded System Laboratory.The architecture, organization and operation principles of general-purpose microprocessor systems will be elaborated, as well as the design and implementation technology for current embedded microsystems based on ARM CPU. The subsystems in a computer, including microprocessor, memories, buses, input/output interfaces and others, will be completely involved. The primary goal of this course is to studying the cooperated relationship between the hardware and software in an embedded system or a System-on-Chip, by discussing in detail on the design method for data path and the controller inside CPU, the implementation technology for hierarchy storage system, the control mode for peripherals, and the program skill for APPs, exception handlers, boot codes, drivers and operating system transplantation, and so on.二、课程目标本课程旨在培养学生深入理解微处理器芯片与嵌入式系统的架构、组成及工作原理,熟练掌握现代嵌入式微系统中硬件电路和软件程序的基本分析、设计与实现方法。