создать два элемента, соединяющих один мультиплексор 41 и 21 - PullRequest
1 голос
/ 17 апреля 2011

У меня большая проблема, потому что я не понимаю, как правильно делать домашнее задание.Ну, я должен сделать что-то вроде этого:http://tomaszewicz.zpt.tele.pw.edu.pl/files/u1/zad4.gif
У меня есть код, который создает b1, но я не знаю, как создать второй и подключить его к b3.

Мой код:

library ieee;
use ieee.std_logic_1164.all;

entity test is
generic(
n : integer := 4
);
port(
a, b, c, d : in std_logic_vector(n-1 downto 0);
s : in std_logic_vector(1 downto 0);
y : out std_logic_vector(n-1 downto 0)
);
end test;



-- przypisanie sekwencyjne - case
architecture arch_mux5 of test is
begin
pr_case: process(a,b,c,d,s)
begin
case s is
when "00" => y <= a;
when "01" => y <= b;
when "10" => y <= c;
when others => y <= d;
end case;
end process;
end arch_mux5;

architecture arch_mux6 of test is
begin
pr_if: process(a,b,c,d,s)
begin
y <= (others => '0'); -- latch jesli zakomentujemy, dlaczego?
if s = "00" then
y <= a;
end if;
if s = "01" then
y <= b;
end if;
if s = "10" then
y <= c;
end if;
if s = "11" then
y <= d;
end if;
end process;
end arch_mux6;

configuration cfg of test is
for arch_mux5
end for;
end cfg;

mux5 и mux6 выглядят одинаково, но в разных методах записи.

Ответы [ 2 ]

3 голосов
/ 19 апреля 2011

Вы должны создать экземпляры этих мультиплексоров, например ::10000

entity top is
  generic (
    n: integer:=4
  );
  port (
    a, b, c, d, e, f, g, h: in std_logic_vector(n-1 downto 0);
    s: in std_logic_vector(2 downto 0);
    y: out std_logic_vector(n-1 downto 0)
  );
end entity top;

architecture struct of top is
  signal t1, t2: std_logic_vector(n-1 downto 0);
  component test is
    generic(
      n : integer := 4
    );
    port (
      a, b, c, d : in std_logic_vector(n-1 downto 0);
      s : in std_logic_vector(1 downto 0);
      y : out std_logic_vector(n-1 downto 0)
    );
  end component test;
  component mux2 is
    generic(
      n : integer := 4
    );
    port (
      a, b : in std_logic_vector(n-1 downto 0);
      s : in std_logic;
      y : out std_logic_vector(n-1 downto 0)
    );
  end component test;
begin
  b1: test
    generic_map (
      n => n
    );
    port map (
      a => a,
      b => b,
      c => c,
      d => d,
      s => s(1 downto 0),
      y => t1
    );
  b2: test
    generic_map (
      n => n
    );
    port map (
      e => a,
      f => b,
      g => c,
      h => d,
      s => s(1 downto 0),
      y => t2
    );
  b3: mux2
    generic_map (
      n => n
    );
    port map (
      a => t1,
      b => t2,
      s => s(2),
      y => y
    );
end architecture struct;

Конечно, вы все равно должны написать сущность + архитектура для mux2. Я не тестировал этот код (здесь у меня нет компилятора VHDL), но это должно, по крайней мере, привести вас в правильном направлении.

1 голос
/ 19 апреля 2011

Да, ваш учитель предоставил два разных способа реализации одного и того же мультиплексора. Это, вероятно, сделано только в образовательных целях. Вам нужно будет создать экземпляр этого мультиплексора для b1 и b2.

Как указывает @bmk, вам все еще нужно предоставить реализацию для b3 и создать три мукса на одном верхнем уровне.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...