📄 communication.vhd
字号:
-------------------------------------------------------------------------------------------------------------
-- Dieses Teil ist fuer die Kommunikation zwieschen "master and sja1000", d.h. geht es von dem master
--also unsere Spartan-3 aus. So setze ich alle Ausgabeschnittstellen als output.
-------------------------------------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity communication is
Port ( clk : out std_logic;
reset : in std_logic;
CS : out std_logic;
ALE : out std_logic;
RD : out std_logic;
WR : out std_logic;
AD : inout std_logic_vector(7 downto 0);
sensor1: in std_logic_vecotr(7 downto 0);
sensor2: in std_logic_vecotr(7 downto 0);
sensor3: in std_logic_vecotr(7 downto 0);
sensor4: in std_logic_vecotr(7 downto 0);
);
end communication;
-- 50 MHz ist gleich 1 Takt pro 20 ns, d.h. die Periode dauert 20 ns.
architecture Behavioral of communication is
constant half_period : time := 10 ns; -- Halbe Periode
signal commclk : std_logic := '1';
type state_c is (cread, cwrite);
signal data : std_logic_vector(7 downto 0);
signal crd, cwr, cale : std_logic;
begin
commclk <= not commclk after half_period;
clk <= commclk after 1 ns; -- Das Delay ist nur fuer ein stabile Signal zu erhalen.
comb: process (commclk)
begin
if commclk = '1' and cale = '0' then
RD <= crd;
WR <= cwr;
if crd = '0' then data <= AD;
crd <= '1' ;
cwr <= '0' ;
end if;
if cwr = '0' then AD <= (others => '0');
cwr <= '1';
crd <= '0';
end if;
end if;
end process comb;
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -