[an error occurred while processing this directive]
|
--Написано на VHDL
--Код полностью синтезируемый
--Сигналы read и write - активный уровень 0
--Изменением N можно менять ширину шины
library IEEE;
use IEEE.STD_LOGIC_1164.all;
USE ieee.numeric_std.all;
entity test_bus is
generic (CONSTANT N : integer := 16);
port
(
data : INOUT std_logic_vector(N-1 downto 0);
read : IN std_logic;
write : IN std_logic
);
end test_bus;
architecture test_bus_body of test_bus is
signal out_bus : std_logic_vector(N-1 downto 0);
signal reg_data : std_logic_vector(N-1 downto 0);
begin
--запись входных данных в регистр
--защелкивается по заднему (нарастающему) фронту сигнала записи
write_reg : process(write) is
begin
if write'event and write = '1' then
reg_data <= data;
end if;
end process;
--Меняем порядок бит в выходном слове
gen1 : for i in N-1 downto 0 generate
out_bus((N-1) - i) <= reg_data(i);
end generate;
--Выдаем выходное слово на шину в случае чтения
data <= out_bus when read = '0' else (others=>'Z');
end test_bus_body;
E-mail: info@telesys.ru