decode2.vhd

来自「使用VHDL语言进行的数字锁相环的设计」· VHDL 代码 · 共 79 行

VHD
79
字号
  -------------------------------------------------------------
  --Copyright (C), 2004- , Huangwei.                         --
  --File name:decode2(解码器)                                --
  --Author:huangwei       Version:1.0        Date:2004/11/24 --
  --Description:                                             --
  --该程序主要完成的功能是完成对破坏点的变换以及产生最后     --
  --的数据流.                                                --
  -------------------------------------------------------------
  
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity decode2 is

port(
     datain:in std_logic;     --数据输入
     point:in std_logic;      --破坏点位置信号输入
     reset:in std_logic;      --复位
     clk: in std_logic;       --本地时钟
     
     dataout:out std_logic    --解码数据输出
    );

end decode2;

architecture decode2_arc of decode2 is

constant max:integer := 4;        --计数器最大值
signal count:integer;             --计数寄存器
signal point_v:std_logic;         --破坏点位置寄存器
signal datain_buff:std_logic;     --数据寄存器

begin

    process(reset,clk,point,count)
    
    begin
    
    if reset = '1' then
    
        count <= 0;
        point_v <= '1';
    
    elsif (clk'event and clk = '0') then
 
        datain_buff <= datain;        --数据寄存
        dataout <= (datain_buff and point_v);    --数据变换
    
        if (point = '1') then      --判断4连零破坏点位置
    
            if ((count = 0) or (count >= max)) then
                count<=0;
                point_v <= point;
            else
                count <= count + 1;            
                point_v <= '0';
            end if;

        else        --判断连续4连零破坏点位置
        
            if(count < max) then
                count <= count + 1;            
                point_v <= '0';
            else
                count <= 1;
                point_v<= '0';
            end if;

        end if;

    end if;

    end process;

end decode2_arc;
  

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?