VHDL可编程期末复习

可编程器件设计数字系统优势

①减少系统的硬件规模。单片PLD器件所能实现的逻辑功能大约是SSI/MSI逻辑器件的4~20倍,因此使用PLD器件能大大节省空间,减小系统的规模,降低功耗,提高系统可靠性。
②增强逻辑设计的灵活性。使用PLD器件可不受标准系列器件在逻辑功能上的限制,修改逻辑可在系统设计和使用过程的任一阶段中进行,并且只需通过对所用的某些PLD器件进行重新编程即可完成,给系统设计者提供了很大的灵活性。
③缩短系统设计周期,由于PLD用户的可编程特性和灵活性,用它来设计一个系统所需时间比传统方法大大缩短。同时,在样机设计过程中,对其逻辑功能修改也十分简便迅速,无需重新布线和生产印制板。
④简化系统设计;提高系统速度。利用PLD的“与或”两级结构来实现任何逻辑功能,比用SSI/MSI器件所需逻辑级数少,这不仅简化了系统设计,而且减少了级延迟,提高了系统速度。
⑤降低系统成本。使用PLD器件设计系统,由于所用器件少,系统规模小,器件的测试及装配工作量大大减少;可靠性得到提高,加上避免了修改逻辑带来的重新设计和生产等一系列问题,所以有效地降低了系统的成本。

信号和变量的区别
  • 定义:变量定义在process,function,procedure中,是局部量。作为进程中局部数据存储单元

    ​ 信号定义在结构体,实体,程序包中,用于电路中的信号连接

  • 作用范围:变量只能够在一个进程和子程序内定义使用

    ​ 信号量可以在进程之间(进程中/外)互相调用

  • 赋值:变量的赋值是理想化的数据传输,立即发生,不存在延迟。:=

    ​ 信号的赋值可以设置延时量,即使是零延时,也要经历一个特定的延时,即 延时,与实际器件的传播延迟特性相吻合,在进程的最后才对信号赋值 <=

VHDL工程设计步骤、作用

1、文本编辑(电路设计与输入):用任何文本编译器都可以进行,也可以用专用的HDL编辑环境(原理图输入、HDL编程、其他输入方式)。通常VHDL文件保存为.vhd文件,verilog文件保存为.v文件

2、使用编译工具编译源文件
3、功能仿真:将文件调入HDL仿真软件进行功能仿真,检查逻辑功能是否正确,也叫前仿真,对简单的设计可以跳过这一步,只在布线完成以后,进行时序仿真)

4、逻辑综合:将源文件调入逻辑综合软件进行综合,即把语言综合成最简单的布尔表达式。逻辑综合软件会生成.edf或.edif的EDA工业标准文件

5、布局布线:将.edf文件调入PLD厂家提供的软件中进行布线,即把设计好的逻辑安放PLD/FPGA内。

6、时序仿真:需要利用在布局布线中获得的精确参数,用仿真软件验证电路的时序。(也叫后仿真)
7、烧写器件

VHDL的优点
  • 功能强大、灵活性强、设计方式多样

  • 具有强大的硬件描述能力

  • 不依赖于器件设计

  • 支持广泛、易于修改

  • 具有很强的移植能力

  • 易于共享和复用

  • 上市时间快,成本低

  • 可提前进行性能评估

缺点

  1. 电路采用高级的简明结构VHDL描述,意味着放弃了对电路门级实现定义的控制
  2. 由综合工具生成的逻辑实现效果有时不优化
  3. 采用工具的不同导致综合质量不一样
端口MODE有几种,比较不同:

5种:in,out,inout,buffer,linkage

in:输入端口。定义的通道为单向只读模式,即规定数据只能由此端口被读入实体中。

out:输出端口。定义的通道为单向输出模式,即规定数据只能通过此端口从实体向外流出,或者说可以将实体中的数据向此端口赋值。

inout:双向端口,有两个寄存器。定义的通道确定为输入输出双向端口,即从端口的内部看,可以对此端口进行赋值,或通过此端口读入外部的数据信息;而从端口的外部看,信号既可由此端口流出,也可向此端口输入信号,如RAM的数据口、单片机的I/O口等。模块能从inout端口读到外面传进来的值,但buffer不能

buffer:缓冲端口,只有一个寄存器,其功能与INOUT类似,区别在于当需要输入数据时,只允许内部回读输出的信号,即允许反馈。(读入的却是上次从该口输出的值。作为输入,则是把上一次结果作为输入)
四选一多路选择器
在这里插入图片描述

with select

library ieee;
use ieee.std_logic_1164.all;
entity mux is
	port(a,b,c,d:in std_logic;
	     s:in std_logic_vector(1 downto 0);
	     y:out std_logic);
end mux;
architecture mux1 of mux is
begin
	with s select
	y<=a when "00",
	   b when "01",
	   c when "10",
	   d when "11",
	   'X' when others;
end mux1;

带三态特性的结构

library ieee;
use ieee.std_logic_1164.all;
entity mux is
	port(a,b,c,d:in std_logic;
	     s:in std_logic_vector(1 downto 0);
	     y:out std_logic);
end mux;
architecture mux1 of mux is
begin
	y<=a when s="00" else 'Z';
	   b when s="01" else 'Z';
	   c when s="10" else 'Z';
	   d when s="11" else 'Z';
end mux1;

case结构

library ieee;
use ieee.std_logic_1164.all;
entity mux is
	port(a,b,c,d:in std_logic;
	     S0,S1,EN:in std_logic;
	     y:out std_logic);
end mux;
architecture behave of mux is 
signal s: std_logic_vector(2 downto 0);
begin s<=S0&S1&EN; 
process(S0,S1,EN) 
begin    
	case s is    
		when"001"=>y<=A(0);    
		when"011"=>y<=A(1);    
		when"101"=>y<=A(2);    
		when"111"=>y<=A(3);    
		when others=>y<='Z'; 
	end case; 
end process; 
end behave;

10-4优先权编码器

libraby ieee; 
use ieee.std_logic_1164.all; 
entity encode10_4 is 
port(input:in std_logic_vector(9 downto 0);    
	 output:out std_logic_vector(3 downto 0)); 
end encode10_4;     
architecture behave of encode10_4 is 
begin    
	process(input)    
	begin        
		if input(9)='1' then            
			output<='1001';        
		elsif input(8)='1' then           
			output<='1000';        
		elsif input(7)='1' then            
			output<='0111';        
		elsif input(6)='1' then            
			output<='0110';        
		elsif input(5)='1' then            
			output<='0101';        
		elsif input(4)='1' then            
			output<='0100';        
		elsif input(3)='1' then            
			output<='0011';        
		elsif input(2)='1' then            
			output<='0010';        
		elsif input(1)='1' then            
			output<='0001';        
		elsif input(0)='1' then            
			output<='0000';        
		else          
			NULL;        
		end if;    
	end process; 
end behave;

一位减法器:全减、半减
在这里插入图片描述
半减器:

library ieee;
use ieee.std_logic_1164.all;
entity bansub is
port(x,y:in std_logic;
     diff,s_out:out std_logic);
end bansub;
architecture behave of bansub is
begin
	process(x,y)
	begin
		diff<=x xor y;
		s_out<=(not x) and y;
	end process;
end behave;

在这里插入图片描述
在这里插入图片描述
全减器:

library ieee;
use ieee.std_logic_1164.all;
entity quansub is
port(x,y,sub_in:in std_logic;
	 diffr,sub_out:out std_logic;)
end quansub;
architecture behave of quansub is
component bansub
port(x,y:in std_logic;
	 diff,s_out:out std_logic);
end component;
signal t0,t1,t2:std_logic;
begin
	u1:bansub port map(x=>x,y=>y,diff=>t0,s_out=>t1);
	u2:bansub port map(x=>t0,y=>sub_in,diff=>diffr,s_out=>t2);
	sub_out<=t1 or t2;
end behave;

3倍序列检测器
在这里插入图片描述
AD574
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
地址计数器:

library ieee; 
use ieee.std_logic_1164.all; 
use ieee.std_logic_unsigned.all;
entity addr_cnt is 
port(clkinc,clr:in std_logic;    
	 addr:out std_logic_vector(9 downto 0)); 
end addr_cnt;     
architecture behave of addr_cnt is 
signal tmp:std_logic_vector(9 downto 0); 
begin    
	process(clkinc,clr)    
	begin        
		if clkinc'event and clkinc='1' then            
			if clr='1' then                
				tmp<=(others=>'0');            
			else                
				tmp<=tmp+1;            
			end if;        
		end if;    
	end process;    
	addr<=tmp; 
end behave;

对整个采集控制模块进行vhdl描述(元件例化)

library ieee; 
use ieee.std_logic_1164.all; 
use ieee.std_logic_unsigned.all;
entity daco is 
port(clk,clr,status:in std_logic;    
	 addata:in std_logic_vector(11 downto 0);    
	 rdaddr:in std_logic_vector(9 downto 0);    
	 cs,ce,a0,rc,k12_8:out std_logic;    
	 rddata:out std_logic_vector(11 downto 0)); 
end daco;
architecture behave of is    
component controller is    
port(addata:in std_logic_vector(11 downto 0);        
	 status,clk:in std_logic;        
	 cs,ce,a0,rc,k12_8,clkinc:out std_logic;        
	 rddata:out std_logic_vector(11 downto 0));    
end component;           
component addr_cnt is    
port(clkinc,clr:in std_logic;        
	 addr:out std_logic_vector(9 downto 0));    
end component;            
component adram is    
port(data:in std_logic_vector(11 downto 0); --写入数据        
	 wraddress:in std_logic_vector(9 downto 0); --写入地址        
	 rdaddress:in std_logic_vector(9 downto 0); --读地址        
	 wren:in std_logic:='1'; --写使能        
	 q:out std_logic_vector(11 downto 0)); --读出数据    
end component; 
signal rds:std_logic_vector(11 downto 0); 
signal clkinc:std_logic; 
signal wraddr:std_logic_vector(9 downto 0); 
begin    
	u1:controller port map (addata,status,clk,cs,ce,a0,rc,k12_8,clkinc,rds);    
	u2:addr_cnt port map (clkinc,clr,addr);    
	u3:adram port map(rds,wraddr,rdaddr,'1',rddata); 
end behave; 
  • 2
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值