1

宿題の仕方をきちんと理解していないので、大きな問題を抱えています。さて、私はこのようなものを作る必要があります:
http://tomaszewicz.zpt.tele.pw.edu.pl/files/u1/zad4.gif
私は b1 を作成するコードを持っていますが、2 番目のものを作成して作成する方法を知りません。 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 は同じように見えますが、書き込み方法が異なります。

4

2 に答える 2

3

これらのマルチプレクサをインスタンス化する必要があります。例:

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コンパイラはありません)が、少なくとも正しい方向に導くはずです。

于 2011-04-18T21:20:18.923 に答える
1

はい、先生は同じマルチプレクサを実装する2つの異なる方法を提供しました。これはおそらく教育目的でのみ行われます。このmuxをb1とb2に対してインスタンス化する必要があります。

@bmkが指摘しているようにb3、1つのトップレベルで3つのMuxの実装を提供し、インスタンス化する必要があります。

于 2011-04-19T10:06:55.327 に答える