创建连接到一个多路复用器 41 和 21 的两个元件

发布于 2024-11-02 01:41:16 字数 1006 浏览 1 评论 0原文

我有一个大问题,因为我不明白如何做作业。 好吧,我必须做这样的事情:
http://tomaszewicz.zpt.tele.pw.edu。 pl/files/u1/zad4.gif
我有创建 b1 的代码,但我不知道如何创建第二个并让它们连接到 b3。

我的代码是:

IEEE 库;
使用 ieee.std_logic_1164.all;

实体测试是
通用的(
n:整数:= 4
);
港口(
a、b、c、d :在 std_logic_vector(n-1 downto 0) 中;
s :在 std_logic_vector(1 downto 0) 中;
y : 输出 std_logic_vector(n-1 降到 0)
);
结束测试;



-- przypisanie sekwencyjne - 案例
测试的架构 arch_mux5 是
开始
pr_case:过程(a,b,c,d,s)
开始
情况是
当“00”=>时y <= a;
当“01”=>时y <= b;
当“10”=>时y <= c;
当别人=> y <= d;
最终情况;
结束进程;
结束 arch_mux5;

测试的架构 arch_mux6 是
开始
pr_if:过程(a,b,c,d,s)
开始
y <=(其他 => '0'); -- 锁住jesli zakomentujemy,dlaczego?
如果 s =“00”则
y <= a;
结束如果;
如果 s =“01”则
y <= b;
结束如果;
如果 s = "10" 那么
y <= c;
结束如果;
如果 s = "11" 那么
y <= d;
结束如果;
结束进程;
结束 arch_mux6;

测试的配置cfg是
对于 arch_mux5
结束于;
结束cfg;

mux5和mux6似乎是相同的,但写入方法不同。

I have big problem because i dont uderstand properly how make my homework.
Well i have to make something like this:
http://tomaszewicz.zpt.tele.pw.edu.pl/files/u1/zad4.gif
I have code which create b1 but i dont knwo how to create the second and make them connect to b3.

My code is:

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 and mux6 seems to be the same but in different write method.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆梦 2024-11-09 01:41:16

你必须实例化这些多路复用器,例如:

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 编译器),但这至少应该引导您进入正确的方向。

You have to instantiate those multiplexers, e.g.:

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;

Of course you still have to write the entity+architecture for mux2. I didn't test this code (don't have a VHDL compiler here) but that should at least lead you into the correct direction.

初心未许 2024-11-09 01:41:16

是的,您的老师提供了两种不同的方法来实现相同的多路复用器。这样做可能仅用于教育目的。您需要为 b1 和 b2 实例化该多路复用器。

正如 @bmk 指出的,您仍然需要为 b3 提供一种实现,并在一个顶层实例化三个多路复用器。

Yes, your teacher provided two different ways of implementing the same mux. This is probably done for educational purposes only. You will need to instantiate this mux for b1 and b2.

As @bmk points out, your still need to provide an implementation for b3 and instantiate the three muxes in one top level.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文