VHDL知识点初学者笔记_第1页
VHDL知识点初学者笔记_第2页
VHDL知识点初学者笔记_第3页
VHDL知识点初学者笔记_第4页
VHDL知识点初学者笔记_第5页
已阅读5页,还剩31页未读 继续免费阅读

下载本文档

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

文档简介

1、此文档是笔者学习VHDL的第15天写的笔记知识点,其中不少包含了初学者容易遇到的问题,也解决了一部分遇到的问题。本次更新包含11个知识点,力求以简单通俗的语句,解释清楚那些遇到的问题。该文档知识点杂乱无章,笔者想到一点就会写一点进去;力求能够给初学者理清思路,更加坚定自己不确定的概念。知识点1:变量&信号当前态和输入决定case present_state iswhen s0 = if din =0thennext_state = s1; elsenext_state = 3. present_state状态输出l 当前状态l 输入Moore:输出组合逻辑电路,仅和当前态有关。Mealy:输出

2、组合逻辑电路,当前态+输入- Quartus Prime VHDL Template- Four-State Mealy State Machine- A Mealy machine has outputs that depend on both the state and- the inputs. When the inputs change, the outputs are updated- immediately, without waiting for a clock edge. The outputs- can be written more than once per state

3、or per clock cycle.library ieee;use ieee.std_logic_1164.all;entity four_state_mealy_state_machine is port ( clk : in std_logic; input : in std_logic; reset : in std_logic; output : out std_logic_vector(1 downto 0) );end entity;architecture rtl of four_state_mealy_state_machine is - Build an enumerat

4、ed type for the state machine type state_type is (s0, s1, s2, s3); - Register to hold the current state signal state : state_type;begin process (clk, reset) begin if reset = 1 then state if input = 1 then state = s1; else state if input = 1 then state = s2; else state if input = 1 then state = s3; e

5、lse state if input = 1 then state = s3; else state if input = 1 then output = 00; else output if input = 1 then output = 01; else output if input = 1 then output = 10; else output if input = 1 then output = 11; else output = 10; end if; end case; end process;end rtl;- Quartus Prime VHDL Template- Fo

6、ur-State Moore State Machine- A Moore machines outputs are dependent only on the current state.- The output is written only when the state changes. (State- transitions are synchronous.)library ieee;use ieee.std_logic_1164.all;entity four_state_moore_state_machine is port( clk : in std_logic; input :

7、 in std_logic; reset : in std_logic; output : out std_logic_vector(1 downto 0) );end entity;architecture rtl of four_state_moore_state_machine is - Build an enumerated type for the state machine type state_type is (s0, s1, s2, s3); - Register to hold the current state signal state : state_type;begin

8、 - Logic to advance to the next state process (clk, reset) begin if reset = 1 then state if input = 1 then state = s1; else state if input = 1 then state = s2; else state if input = 1 then state = s3; else state if input = 1 then state = s0; else state output output output output = 11; end case; end

9、 process;end rtl;知识点8:process,case顺序,敏感process内部只能有顺序语句例如 IF THEN ELSE END IF,CASECASE语句无顺序无优先级process组合逻辑电路,需要把所有输入信号写进敏感列表描述时序逻辑电路,需要包含时钟,清零,置位等顺序描述语句只能出现在process中知识点9:Generic使用方式GENERIC写的地点,注意是ENTITY和PROT之间!generic(N : integer := 4);必须是整数才能被综合知识点10:with select和case和when else1. with select 赋值的目标信号

10、必须是信号2. case 赋值信号可以是VARIABLE,也可以是SIGNAL3. case无顺序无优先级,with select也是并行4. case用于process,with select用于ARCHITECTUREARCHITECTURE内部有:并行部分书写:条件信号赋值语句q = d0when s1 = 0 and s0 = 0 elsed1when s1 = 1 and s0 = 1 elsed3when s1 = 1 and s0 = 0 elseZ;选择信号赋值语句with comb selectq=表达式1 when “00”,表达式2 when “10”,Zwhen oth

11、ers;知识点11:REG,latch,FPLATCH:E=0保持,E=1,输出Q随输入D变化,Q=D;FP:,输出Q随着输入D变化, Q=D;REG:就是由FP组成,多个FP级联,数据位D0D1D2D3,再时刻,同时置入各个FP,然后输出。library ieee;use ieee.std_logic_1164.all;-entity latchfp is-port(- D : in bit;- Q : out bit;- en : in bit- );-end;-architecture bhv of latchfp is-signal Qreg : bit;-begin- process

12、(D,en)- begin- if en =1 then- Qreg=D;- else- Qreg=Qreg;- end if;- end process;- - Q=Qreg;-end;entity latchfp isport( D : in bit; Q : out bit; clk : in std_logic );end;architecture bhv of latchfp issignal Qreg : bit;begin process(clk) begin if rising_edge(clk) then Qreg=D; else Qreg=Qreg; end if; end

13、 process; Q=Qreg;end;知识点12:VHDL 顺序语句和并行语句u 并行语句:1. 进程语句PROCESS2. 并行信号赋值语句l 简单信号赋值语句:目标信号 比如说cnt是std_logic_vector(7 downto 0);那么cnt1,others=0);就表示给cnt的第1位赋1,其他位的全部都赋0,结果cnt=“”;cnt 0)把cnt的所有位置0;知识点17:滤波器的一些性质l 滤波器对于信号滤波,不同的滤波器种类(贝塞尔,切比雪夫,巴特沃斯等等)在表现在:1. 设计的滤波器的截止频率处衰减是否快速2.是否在滤波设计的通带内是否是平坦的(上述滤波器有一些在滤波

14、器比如设置的Fp=3khz前某个区间(通带内)就已经开始出现了衰减3.对阶跃信号的表现。l 众所周知,理想的LPF幅频特性为在截止频率处是垂直的,认为高于Fp的信号频率全部被衰减,实际上高阶的滤波器也很难做的特别陡峭。l 信号的群时延,不同种类的滤波器的群时延是不同的。群时延的概念:不同频率的信号同一时刻进去,出来的时候是否还是同一时刻出来。如果某种信滤波器的群时延很差,即使是通带边缘做的非常陡峭,也是无用的。l 滤波器对阶跃信号的响应,有的会出现非常大的过冲,这也是一种滤波器的性能指标。注:滤波器的阶数越高,通常其截止频率处的衰减的特性也越好。知识点18:结构体说明语句结构体说明语句是指在放

15、在ARCHITECTURE和BEGIN之间的语句结构体和begin内部主要是定义:信号,常数,数据类型和函数等-还能例化在entity内部的architecture定义的信号只能在该architecture内使用,如entity内部有多个architecture,结构体A中定义的信号不能在在结构体B内使用。library ieee;use ieee.std_logic_1164.all;entity lihua isport( clk : in std_logic; sel : in std_logic_vector(1 downto 0); clkout : out std_logic);e

16、nd;architecture behave of lihua is component fredevider2 isport( clock : in std_logic; clkout : out std_logic );end component fredevider2;component mux2 isport( data0,data1,data2,data3 : in std_logic; sel : in std_logic_vector(1 downto 0); dout : out std_logic );end component mux2;signal clk1,clk2 :

17、 std_logic;begin u1 : fredevider2 port map(clock = clk,clkout = clk1); u2 : fredevider2 port map(clock = clk1,clkout = clk2); u3 : mux2 port map(sel =sel,data0 = clk1,data1 = clk2, data2 =0,data3 = 0,dout =clkout);end;知识点19:子程序子程序:主程序调用它以后能将处理结果返回给主程序:过程PROCEDURE和函数FUNCTION过程:定义一个算法,具有多个返回值或者不产生返回值,形式参数可以是:IN OUT INOUT,可以使用wait语句或者顺序赋值语句。函数:函数往往只有一个返回值,形式参数只有IN,函数中不能使用wait和顺序赋值语句。知识点20:例化和打包例化元器件的打包library ieee;use ieee.std_logic_1164.all;package pac is component fredevider is generic (N : integer); -普通元器件没有generic这一行 port( clkin : in std_logic; clkout : out std_logic

温馨提示

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

评论

0/150

提交评论