已阅读5页,还剩20页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
可编程逻辑器件及EDA技术实验报告一、组合逻辑电路设计 数字逻辑电路按照逻辑功能的特点分为两类,一类是组合逻辑电路,简称为组合电路;另一类是时序逻辑电路,简称为时序电路。组合电路的特点是电路任意时刻输出状态只取决该时刻的输入状态,而与该时刻钱的电路状态无关。1、逻辑门电路设计实验原理:逻辑门电路包括基本逻辑门电路和符合逻辑门电路。VHDL语言可以直接支持的逻辑运算符共有七种逻辑运算,它们是: NOT 逻辑非 AND 逻辑与 NAND 逻辑与非 OR 逻辑或 NOR 或非 XOR 异或 XNOR 异或非实验内容:例3-2的参考程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee. std_logic_unsigned.all;entity example3_2 is port(a,b,c,d:in std_logic; f:out std_logic_vector(3 downto 0);end example3_2;architecture behavioral of example3_2 isbeginf(0)=(a and b)or(b and c)or(not b and not c);f(1)=(a and b and c)or not(not a or not b or not c);f(2)=(a xor b xor c)or(not(d)and(a or c);f(3)=not (a and b)xor (c and d)or(a and b and d)xor(b and c and d);end behavioral;实验分析:用逻辑运算符是实现了相对较为复杂的逻辑运算。参考程序中使用括号来强制控制逻辑运算的优先级,对于用VHDL设计,这种写法是必修的。用这种方法可以简单、快捷地完成逻辑电路设计。电路结构图:实验波形仿真如下图:2、常用编码器设计编码是指用文字、符号和数码等来表示某种信息的过程。在数字系统中,由于采用二进制运算来处理数据,因此通常是将信息编成若干位二进制代码,而在逻辑电路中,信号都是以高、低电平的形式给出的。实现编码的数字电路称作编码器(encoder),编码器的逻辑功能就是把输入的每一个高低电平信号编成一组对应的二进制代码。实验原理:根据8线-3线优先编码器的真值表可得,优先编码器的编码输入、编码输出均为低电平有效,且有使能输入和使能输出功能。实验内容:例3.4试用VHDL设计一个8线-3线优先编码器,编码器输出为反码输出。它的程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity example3_4 is port(sin:in std_logic; i:in std_logic_vector(7 downto 0); a:out std_logic_vector(2 downto 0); e,s:out std_logic);end example3_4;architecture behavioral of example3_4 isbegin process(sin,i) begin if sin=1 then a=111;e=1;s=1; else if i(7)=0 then a=000;e=0;s=1; elsif i(6)=0 then a=001;e=0;s=1; elsif i(5)=0 then a=010;e=0;s=1; elsif i(4)=0 then a=011;e=0;s=1; elsif i(3)=0 then a=100;e=0;s=1; elsif i(2)=0 then a=101;e=0;s=1; elsif i(1)=0 then a=110;e=0;s=1; elsif i(0)=0 then a=111;e=0;s=1; else a=111;e=1;s segment segment segment segment segment segment segment segment segment segment segment segment segment segment segment segment NULL ; END CASE ; END PROCESS ; END ;实验分析:当共阴极数码管的某一阳极接高电平时,相应的二极管发光,若要显示某字形,则使相应几段的二极管发光即可,所以共阴极数码管需要有输出高电平有效的译码器去驱动,而共阴极数码管则需要输出低电平有效的译码器去驱动。上面程序是一个能驱动共阳极数码管的7段译码器的VHDL程序。实验波形仿真如下:4、数据选择器设计 数据选择器(multiplexer)是在地址选择信号的控制下,从多路输入数据中选择一路作为输出的逻辑电路,叫做多路开关,简称MUX。实验原理:在可编程逻辑器件的设计中经常用数据选择器来实现课编程逻辑器件内部数据总线的连接。实验内容:例3.7试用VHDL设计4选1数据选择器。参考程序:Library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_arith.all;Use ieee.std_logic_unsigned.all;Entity example3_7 is Port(d:in std_logic_vector(3 downto 0); a:in std_logic_vector(1 downto 0); e:in std_logic; f:out std_logic);end example3_7;architecture behavioral of example3_7 isbegin process(e,a,d) begin if e=0then case a is when 00 =ffff=d(3); end case; end if;end process;end behavioral;实验分析:一个4选1数据选择器,D3D0为4个数据输入,F为数据输出,A1、A0是地址选择输入。当A1、A0为不同代码时,D3D0中不同输入通道数据送至输出端F。E为使能端,当E=0时,数据选择器正常工作,否则禁止工作。实验波形仿真:5、数据分配器设计 在数字信号的传输过程中,常常需要将一路数据分配到多路通道中去。实现这种功能的逻辑电路,叫做数据分配器(Demultiplexer),简称DEMUX,其电路为单输入、多输出形式。实验内容:例3.10试用VHDL设计两总线数据分配器。它的参考程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity example3_10 is port(sel:in std_logic; a,b:in std_logic_vector(7 downto 0); mux_out: out std_logic_vector(7 downto 0);end example3_10;architecture behavioral of example3_10 isbegin process(sel,a,b) begin if sel=1 then mux_out=a; else mux_out=b; end if; end process;end behavioral;实验分析:D为被传输的数据输入,A、B是(地址)选择输入,Q0Q3为数据输出。电路结构图:实验波形仿真图:6、数值比较器设计数值比较器是用来比较两个数据之间市值关系的电路。按照比较的数据类型划分,数值比较器可分为无符号数二进制比较器和有符号数二进制比较器。实验内容:例3.12试用VHDL设计两个8位有符号数的数值比较器,比较分别输出大于、小于和相等的结果。它的程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity example3_12 is port(a,b:in std_logic_vector(7 downto 0); gt,eq,lt:out std_logic);end example3_12;architecture behavioral of example3_12 issignal sab:std_logic_vector(1 downto 0);begin sab if a(6 downto 0)b(6 downto 0) then gt=1;eq=0;lt=0; elsif a(6 downto 0)=b(6 downto 0)then gt=0;eq=1;lt=0; else gt=0;eq=0;lt gt=1;eq=0;lt gt=1;eq=0;lt if a(6 downto 0)b(6 downto 0) then gt=0;eq=0;lt=1; elsif a(6 downto 0)=b(6 downto 0)then gt=0;eq=1;lt=0; else gt=1;eq=0;lt gt=0;eq=1;lt=0; end case; end process; end behavioral;实验分析:从程序可以看到,利用并置的方法从输入数据中分离出符号位,然后用case语句将符号位的四种组态分开,分别处理。实验波形仿真图: 7、算术运算单元电路设计实验原理:算术运算单元电路是构成处理器CPU的算术逻辑单元(ALU)的一个重要组成部分。实验内容:例3.13试用VHDL设计一个8位二进制数的加法器。它的程序如下: library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity fulladder is port(ai,bi,cin:in std_logic; si,cio:out std_logic);end fulladder;architecture behavioral of fulladder isbeginsi=(ai xor bi)xor cin;cio=(ai and bi)or(cin and ai)or(cin and bi);end behavioral;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity example3_13 is port(a,b:in std_logic_vector(7 downto 0); ci:in std_logic; co:out std_logic; s:out std_logic_vector(7 downto 0);end example3_13;architecture behavioral of example3_13 is component fulladderport(ai,bi,cin:in std_logic; si,cio:out std_logic);end component;signal carry:std_logic_vector(8 downto 0);begincarry(0)=ci;coa(i), bi=b(i), cin=carry(i), si=s(i), cio=carry(i+1);end generate gen;end behavioral;实验分析:8位二进制加法器可以由8个全加器通过级联的方式构成。实验波形仿真图如下:二、时序逻辑电路设计根据逻辑电路功能,逻辑电路可分为组合逻辑电路和时序逻辑电路两大类。其特点是电路任意时刻的稳态输出仅取决于该时刻的输入信号,而与电路原来的状态无关。1、 常用触发器设计实验原理:触发器(flip-flop)是能存储一位二进制数的逻辑电路,是时序逻辑电路的基本单元电路。触发器具有两个稳定状态,用来表示逻辑状态或二进制数的0和1。实验内容:例3.14试用VHDL设计一个D触发器。它参考程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all; ENTITY example3_14 IS PORT (CLK : IN STD_LOGIC ; D : IN STD_LOGIC ; Q : OUT STD_LOGIC ); END ; ARCHITECTURE behavioral OF example3_14 IS BEGIN PROCESS (CLK) BEGIN IF CLKEVENT AND CLK = 1 THEN Q = D ; END IF; END PROCESS ; END;电路结构图:实验波形仿真图:实验原理:对于时序电路的控制,通常可以划分为同步方式和异步方式。同步方式是指控制信号只有在时钟有效时才起作用,简称同步控制;异步方式是指控制系统起作用不需要时钟信号有效,简称异步控制。实验内容:例3.15试用VHDL设计一个具有异步复位和同步置位的D触发器。它的参考程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity example3_15 is port(d: in std_logic; clk: in std_logic; clr,set: in std_logic; q: out std_logic);end example3_15;architecture behavioral of example3_15 isbegin process(clk,clr,set) begin if clr=1 then q=0; elsif rising_edge(clk) then if set=1 then q=1; else q=d; end if; end if; end process;end behavioral;电路结构图:实验波形仿真图:2、常用数码寄存器设计 数码寄存器用于寄存数据,不能进行数据移位。它被广泛地应用于各类数字计算机和数字系统中。一般来说,寄存器是借助时钟脉冲的作用把数据寄存在触发器内,寄存数据的位数和所用触发器的个数是相等的,因为一个触发器能储存1位二进制码,所以用N触发器组成的寄存器能储存一组N二进制码。按照数码寄存器的功能,可以把数码寄存器的功能划分为寄存器、锁存器和移位寄存器等。实验内容:例3.17试用VHDL设计一个8位锁存器。它的参考程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity example3_17 is port(d: in std_logic_vector(7 downto 0); le: in std_logic; q: out std_logic_vector(7 downto 0);end example3_17;architecture behavioral of example3_17 issignal qin: std_logic_vector(7 downto 0);begin p1: process(d) begin if le=1then qin=d; end if; end process p1; p2: process(le) begin if falling_edge(le) then q= qin; end if; end process p2;end behavioral;实验波形仿真图:3、常用计数器设计 计数的功能就是累计输入脉冲的个数。实现计数功能的数字电路就称为计数器(counter)。被计数的脉冲(简称计数脉冲)可以是周期性脉冲,也可以是非周期性脉冲,它通常加载计数器的时钟输入端,作为计数器的时钟脉冲。 计数器在循环中的状态个数叫做计数器的模(modulus)。在循环中有m个状态的计数器称为模m计数器,或称m分频计数器。 实验内容:例3.21试用VHDL设计一个十进制计数器。它的参考程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity example3_21 is port(en,clk: in std_logic; q: out std_logic_vector(3 downto 0); qcc: out std_logic);end example3_21;architecture behavioral of example3_21 issignal qtemp: std_logic_vector(3 downto 0);begin process(clk,en) begin if clkevent and clk=1then if en=1then if qtemp=1001then qtemp=0000; else qtemp=qtemp+1; end if; end if; end if; end process;q=qtemp;qcc=qtemp(3) and qtemp(2) and qtemp(0) and qtemp(0);end behavioral;电路结构图:实验波形仿真图:三、有限状态机(finite state machine)是由寄存器和组合逻辑构成的硬件时序电路。同步有限状态机的状态只能在同一时钟跳变沿的情况下才能从一个状态转向另一个状态。有限状态机按照结构划分为mealy型和moore型。1、 Mealy型状态机设计实验原理:Mealy型状态机的输出信号是当前状态和所有输入信号的函数。Mealy型状态机的输出是在输入变化后立即发生变化,且输入变化可能出现在时钟周期内的任何时候,因而mealy型状态机队输入的响应比Moore型状态机对输入的响应早一个时钟周期。实验内容:例3.23试用VHDL设计实现交通灯控制器的mealy型状态机,其中T1,T2,T3分别代表三个定时器的溢出信号,三个定时器代表红灯、绿灯和黄灯点亮时间;reset信号代表复位信号。它的参考程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity example3_23 is port (reset,clk: in std_logic; t1,t2,t3: in std_logic; r,g,y: out std_logic);end example3_23;architecture behavioral of example3_23 is type state_type is (red,green,yellow); signal state,next_state:state_type;beginsync_ptoc: process(clk) begin if (clkevent and clk =1)then if(reset =1)then state = red; else state = next_state; end if; end if;end process;-mealy state machine-outputs based on state and inputsoutput_decode: process(state,t1,t2,t3)begin if(state =red and t1 =0)then r=1; g=0; y=0; elsif (state = green and t2 = 0)then r=0; g=1; y=0; elsif (state = yellow and t3 = 0)then r=0; g=0; y=1; end if;end process;next_state_decode: process(state,t1,t2,t3)begin next_state if t1 =1 then next_state if t2 =1 then next_state next_state next_state= red; end case; end process;end behavioral;实验波形仿真图:2、 Moore型状态机设计实验原理:Moore型状态机的输出只与当前状态有关,而与当前输入无关。Moore型状态机在时钟跳变后的有限个门延迟之后,输出达到稳定值。输出会在一个完整的时钟周期内保持稳定,即使在该时钟周期内输入信号有变化,输出也不会变化。输入对输出的影响要到下一个时钟周期才能反映出来。把输入和输出隔离开来是Moore型状态机的一个重要特点。 实验内容:例3.24试用VHDL设计如实现空调系统的控制器的Moore型状态机,其中high和low信号是来自室内温度传感器的输出信号,分别表示室内温度过高和过低,当两者输出均无效时代表室内温度适中。如果温度过高或者过低,则制冷控制信号cold或者制冷控制信号heat输出有效。它的程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity example3_24 is port (reset,clk: in std_logic; high,low: in std_logic; cold,heat: out std_logic);end example3_24;architecture behavioral of example3_24 istype state_type is(too_high, too_low,well_situated);signal state, next_state: state_type;beginsync_proc:process(clk) begin if(clkevent and clk=1)then if(reset=1)then state= well_situated; else state= next_state; end if; end if; end process;-moore state machineoutput_decode: process(state) begin if state = too_high then cold=1; heat=0; elsif state = too_low then cold=0; heat=1; elsif state = well_situated then cold=0; heat=0; end if ; end process;next_state_decode: process(state,high,low) begin next_state if high=1then next_state = too_high; end if; if low=1then next_state if high=1then next_state= too_high; else next_state if low=1then next_state = too_low; else next_state next_state = well_situated; end case; end process;end behavioral;电路结构图:实验波形仿真图:四、存储器设计 存储器按其类型可分为只读存储器、随机存储器和顺序存储器。用可编程逻辑器件的逻辑资源和其内部的嵌入式存储器资源可以设计实现各种类型的存储器。1、 只读存储器(ROM)的设计实验原理:只读存储器(ROM)是一个非易失的存储器。在FPGA中嵌入式存储模块的随机存储器(RAM)结构,用RAM结构实现ROM是通过FPGA的配置过程实现的。FPGA的综合系统设计的ROM中数据文件直接综合到配置数据文件中,每次FPGA在呗重新配置的同时也对FPGA内部编程为ROM的存储器资源进行初始化,这样就形成了实际意义上的ROM。实验内容:例3.25试用VHDL设计一个8*8的ROM。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;use std.textio.all;entity example3_25 is port(clk: in std_logic; rd: in std_logic; data: out std_logic_vector(7 downto 0); address: in std_logic_vector(3 downto 0);end example3_25;architecture behavioral of example3_25 is type romtype is array(0 to 15)of bit_vector(7 downto 0); impure function rom_function_name(rom_file_name: in string) return romtype is file rom_file: text is in rom_file_name; variable line_name: line; variable rom_name: romtype; begin for i in romtyperange loop readline (rom_file, line_name); read (line_name, rom_name(i); end loop; return rom_name; end function;signal rom_name: romtype:=rom_function_name(file_name.men)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 初中化学九年级全一册《第一节 食物中的有机物》《第二节 化学元素与人体健康》等(同步训练)
- 初中人工智能跨学科融合教学探索与实践
- 交叉设计在生物等效性试验的贝叶斯方法实践
- 交叉设计在生物等效性试验的bootstrap法验证
- 初中语文教学反思2
- 五官科药物临床试验的远程视力听力监查实践
- 云端化虚拟在教学中的应用
- 安徽省蚌埠市2026届高三生物上学期8月开学调研性监测试题pdf
- 血液科教学查房
- 浅谈英语教学中不可忽视的内容
- 京东预算管理制度
- 单片机智能鞋柜控制系统的设计与实现
- JG/T 255-2020内置遮阳中空玻璃制品
- 工程周报月报管理制度
- 调解小三协议书
- 建筑工程质量员培训课件
- 重庆芯片项目商业计划书
- 2025年中考语文备考之非连续性文本阅读7大考点+4道中考题
- 2025天津市滨海新区辅警考试试卷真题
- 2022机动车运行安全技术条件
- 水样采集考试题及答案
评论
0/150
提交评论