Привет всем!
У меня есть задание, реализовать на VHDL универсальный 4-х битный регистр. Нашел в интернете схемку через мультиплексоры и D-тригеры.
Сделал на VHDL, всё по отдельности работает (mux, d-тригер). Но когда я кобинирую их, они не работают вместе, а точнее. не проходит сигнал на выход, может я не так использую INOUT, но если выходы сделать OUT, то выдает ошибку что я использую выходной сигнал для входного, по этому решил взять INOUT. Приклепляю код Мультиплексора и Д-тригера, а так же сгенерированый код Active-HDL через Block Diagram, а так же скриншоты симуляции и самой схемы. Буду благодарен за ответы, Спасибо!
mux.vhd
Код:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity mux is
port(
D3 : in STD_LOGIC;
D2 : in STD_LOGIC;
D1 : in STD_LOGIC;
D0 : in STD_LOGIC;
CS1 : in STD_LOGIC;
CS2 : in STD_LOGIC;
A : out STD_LOGIC;
Clk : in STD_LOGIC
);
end mux;
architecture mux of mux is
begin
A <= 'Z';
process (Clk)
begin
if (Clk'event and Clk = '1') then
if (CS1 = '0' and CS2 = '0') then --keep
A <= D0;
elsif (CS1 = '0' and CS2 = '1') then --right shift
A <= D1;
elsif (CS1 = '1' and CS2 = '0') then --left shift
A <= D2;
elsif (CS1 = '1' and CS2 = '1') then --write
A <= D3;
end if;
end if;
end process;
end mux;
d_trig.vhd
Код:
Library IEEE;
USE IEEE.Std_logic_1164.all;
entity RisingEdge_DFlipFlop is
port(
Q : out std_logic;
Clk :in std_logic;
D :in std_logic
);
end RisingEdge_DFlipFlop;
architecture Behavioral of RisingEdge_DFlipFlop is
begin
process(Clk, D)
begin
Q <= 'Z';
if(rising_edge(Clk)) then
Q <= D;
end if;
end process;
end Behavioral;
register.vhd
Код:
library IEEE;
use IEEE.std_logic_1164.all;
entity \register\ is
port(
B0 : in STD_LOGIC;
B1 : in STD_LOGIC;
B2 : in STD_LOGIC;
B3 : in STD_LOGIC;
C : in STD_LOGIC;
CS1 : in STD_LOGIC;
CS2 : in STD_LOGIC;
DSL : in STD_LOGIC;
DSR : in STD_LOGIC;
Q0 : inout STD_LOGIC;
Q1 : inout STD_LOGIC;
Q2 : inout STD_LOGIC;
Q3 : inout STD_LOGIC
);
end \register\;
architecture \register\ of \register\ is
---- Component declarations -----
component mux
port (
CS1 : in STD_LOGIC;
CS2 : in STD_LOGIC;
Clk : in STD_LOGIC;
D0 : in STD_LOGIC;
D1 : in STD_LOGIC;
D2 : in STD_LOGIC;
D3 : in STD_LOGIC;
A : out STD_LOGIC
);
end component;
component RisingEdge_DFlipFlop
port (
Clk : in STD_LOGIC;
D : in STD_LOGIC;
Q : out STD_LOGIC
);
end component;
---- Signal declarations used on the diagram ----
signal NET215 : STD_LOGIC;
signal NET226 : STD_LOGIC;
signal NET237 : STD_LOGIC;
signal NET248 : STD_LOGIC;
begin
---- Component instantiations ----
U10 : mux
port map(
A => NET226,
CS1 => CS1,
CS2 => CS2,
Clk => C,
D0 => Q1,
D1 => Q0,
D2 => Q2,
D3 => B1
);
U11 : mux
port map(
A => NET237,
CS1 => CS1,
CS2 => CS2,
Clk => C,
D0 => Q2,
D1 => Q1,
D2 => Q3,
D3 => B2
);
U12 : mux
port map(
A => NET248,
CS1 => CS1,
CS2 => CS2,
Clk => C,
D0 => Q3,
D1 => Q2,
D2 => DSL,
D3 => B3
);
U5 : RisingEdge_DFlipFlop
port map(
Clk => C,
D => NET215,
Q => Q0
);
U6 : RisingEdge_DFlipFlop
port map(
Clk => C,
D => NET226,
Q => Q1
);
U7 : RisingEdge_DFlipFlop
port map(
Clk => C,
D => NET237,
Q => Q2
);
U8 : RisingEdge_DFlipFlop
port map(
Clk => C,
D => NET248,
Q => Q3
);
U9 : mux
port map(
A => NET215,
CS1 => CS1,
CS2 => CS2,
Clk => C,
D0 => Q0,
D1 => DSR,
D2 => Q1,
D3 => B0
);
end \register\;