⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 controler.vhd

📁 VHDL 在MAXPLUS环境下运行
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity controler is
  port(
	clk,clk1KHZ,reset:	in std_logic;
	Key:in 		integer range 0 to 255;
	Q:		inout std_logic_vector(7 downto 0);
	KeySec:		out integer range 0 to 255;
    Act,RAM_Wr,RAM_Rd:	out std_logic);
  end controler;

  architecture arch of controler is
  SIGNAL Read,Write,Finish,SecData:std_logic;
  BEGIN

	main:PROCESS(clk1KHZ,clk,reset)
	VARIABLE i:INTEGER RANGE 0 TO 4;
	VARIABLE preclk:std_logic;
	BEGIN
	  if(reset = '0') then
		Write <= '0';
		Read <= '0';
	  elsif(clk1KHZ'event and clk1KHZ='0') then
        if(clk = '1') then
		  if(i<4) then
 	  	    if(SecData = '1') then
		       Write <= '1';
	        else
		       Read <= '1';
		    end if;
			i := i + 1;
		  else
		 	Write <= '0';
 		    Read <= '0';
		  end if;
		else
		  i := 0;
	    end if;
      end if;
	END PROCESS main;

	RW:PROCESS(clk,reset)
	BEGIN
	  if(reset = '0') then
		SecData <= '0';
	  elsif(clk'event and clk = '1') then
		SecData <= NOT(SecData);
	  end if;
	END PROCESS RW;

    daopera:PROCESS(clk1KHZ,reset,clk)
    VARIABLE opera:INTEGER RANGE 0 TO 7;
    BEGIN
      if(reset = '0') then
		RAM_Wr <= '1';
	    RAM_Rd <= '1';
		opera := 0;
		Act <= '0';
--		Finish <= '0';
	  elsif(clk1KHZ'event and clk1KHZ='1') then
		if(Write = '1') then
		   opera := opera + 1;
		   CASE opera IS 
			  WHEN 1 =>
						RAM_Wr <= '0';
			  WHEN 2 =>
						Q <= CONV_STD_LOGIC_VECTOR(Key,8);
			  WHEN 3 =>
						RAM_Wr <= '1';
			  WHEN OTHERS =>
						RAM_Wr <= '1';
						opera := 0;
		   END CASE;
	    elsif(Read = '1') then
		   opera := opera + 1;
		   CASE opera IS
			  WHEN 1 =>
						RAM_Rd <= '0';
						Act <= '0';
			  WHEN 2 =>
						KeySec <= Key;
			  WHEN 3 =>
		  				Act <= '1';
			  WHEN OTHERS =>
						RAM_Rd <= '1';
						opera := 0;
		   END CASE;
		end if;
--	    Finish <= '0';
   	  end if;
	end process daopera;
  END arch;

⌨️ 快捷键说明

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