seltime.vhd

来自「几个VHDL实现的源程序及其代码」· VHDL 代码 · 共 41 行

VHD
41
字号
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity seltime is
port(
     clk : in std_logic;
     rst : in std_logic;
     din : in std_logic_vector(7 downto 0);
     daout : out std_logic_vector(7 downto 0);     
     sel : out std_logic_vector(2 downto 0));
end seltime;

architecture behav of seltime is
signal sec : std_logic_vector(2 downto 0);
begin
process(rst,clk)
begin
if(rst='0') then
sec<="000";
elsif(clk'event and clk='1') then  
if(sec="011") then
   sec<="000";
else
   sec<=sec+1;
end if;
end if;
end process;
process(sec,din(7 downto 0))
begin
case sec is
when "000"=>daout<=din(7 downto 0);
when "001"=>daout<=din(7 downto 0);
when "010"=>daout<=din(7 downto 0);
when "011"=>daout<=din(7 downto 0);
when others=>daout<="XXXXXXXX";
end case;
end process;
sel<=sec;
end behav;

⌨️ 快捷键说明

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