简单的VHDL 4对1 MUX测试台已挂

发布于 2024-10-21 23:27:28 字数 2497 浏览 1 评论 0原文

  -----------begin part1.vhdl---------------------


library ieee;
use ieee.std_logic_1164.all;

entity part1 is
    generic ( width : integer :=7);
    PORT( a, b, c, d: IN std_logic_vector(width downto 0);
        sel: IN std_logic_vector(1 downto 0);
        result: OUT std_logic_vector(width downto 0)
    );
end part1;

architecture muxbehav of part1 is

BEGIN

    result <=       a after 5 ns when sel="00" else
                    b after 5 ns when sel="01" else
                    c after 5 ns when sel="10" else
                    d after 5 ns;
end muxbehav;

-----------end part1.vhdl---------------------

    -----------begin part1_tb.vhdl------------------

library ieee;
use ieee.std_logic_1164.all;


entity part1_tb is
    generic( width : integer := 7);
end part1_tb;

architecture tb of part1_tb is

    signal t_a: std_logic_vector(width downto 0):="00000000";
    signal t_b: std_logic_vector(width downto 0):="00000000";
    signal t_c: std_logic_vector(width downto 0):="00000000";
    signal t_d: std_logic_vector(width downto 0):="00000000";
    signal t_s: std_logic_vector(1 downto 0);
    signal t_o: std_logic_vector(width downto 0);

component part1
    generic(width : integer);
    PORT( a, b, c, d: IN std_logic_vector(width downto 0);
        sel: IN std_logic_vector(1 downto 0);
        result: OUT std_logic_vector(width downto 0)
    );
    end component;

    begin

    U_part1: part1 generic map(width) port map(a=>t_a, b=>t_b, c=>t_c, d=>t_d, sel=>t_s, result=>t_o);

    process

        begin

        t_a <= "11111111";
        t_b <= "00000001";
        t_c <= "10101010";
        t_d <= "01010101";

        wait for 10 ns;
        t_s <= "00";
        wait for 6 ns;
        assert (t_o="11111111") report "Error input a" severity error;

        wait for 10 ns;
        t_s <= "01";
        wait for 6 ns;
        assert (t_o="00000001") report "Error input b" severity error;

        wait for 10 ns;
        t_s <= "10";
        wait for 6 ns;
        assert (t_o="10101010") report "Error input c" severity error;

        wait for 10 ns;
        t_s <= "11";
        wait for 6 ns;
        assert (t_o="01010101") report "Error input d" severity error;

        wait;

    end process;
end tb;

-----------end part1_tb.vhdl------------------

您好,这是我用 VHDL 编写的第一个代码。它是一个简单的 4 比 1 多路复用器,可以接收任意宽度的向量。然而,当我尝试运行我的测试平台时,GHDL 只是挂起。我看过与我的类似的测试平台,但我仍然找不到我的测试平台挂起的原因。有什么想法吗?

  -----------begin part1.vhdl---------------------


library ieee;
use ieee.std_logic_1164.all;

entity part1 is
    generic ( width : integer :=7);
    PORT( a, b, c, d: IN std_logic_vector(width downto 0);
        sel: IN std_logic_vector(1 downto 0);
        result: OUT std_logic_vector(width downto 0)
    );
end part1;

architecture muxbehav of part1 is

BEGIN

    result <=       a after 5 ns when sel="00" else
                    b after 5 ns when sel="01" else
                    c after 5 ns when sel="10" else
                    d after 5 ns;
end muxbehav;

-----------end part1.vhdl---------------------

    -----------begin part1_tb.vhdl------------------

library ieee;
use ieee.std_logic_1164.all;


entity part1_tb is
    generic( width : integer := 7);
end part1_tb;

architecture tb of part1_tb is

    signal t_a: std_logic_vector(width downto 0):="00000000";
    signal t_b: std_logic_vector(width downto 0):="00000000";
    signal t_c: std_logic_vector(width downto 0):="00000000";
    signal t_d: std_logic_vector(width downto 0):="00000000";
    signal t_s: std_logic_vector(1 downto 0);
    signal t_o: std_logic_vector(width downto 0);

component part1
    generic(width : integer);
    PORT( a, b, c, d: IN std_logic_vector(width downto 0);
        sel: IN std_logic_vector(1 downto 0);
        result: OUT std_logic_vector(width downto 0)
    );
    end component;

    begin

    U_part1: part1 generic map(width) port map(a=>t_a, b=>t_b, c=>t_c, d=>t_d, sel=>t_s, result=>t_o);

    process

        begin

        t_a <= "11111111";
        t_b <= "00000001";
        t_c <= "10101010";
        t_d <= "01010101";

        wait for 10 ns;
        t_s <= "00";
        wait for 6 ns;
        assert (t_o="11111111") report "Error input a" severity error;

        wait for 10 ns;
        t_s <= "01";
        wait for 6 ns;
        assert (t_o="00000001") report "Error input b" severity error;

        wait for 10 ns;
        t_s <= "10";
        wait for 6 ns;
        assert (t_o="10101010") report "Error input c" severity error;

        wait for 10 ns;
        t_s <= "11";
        wait for 6 ns;
        assert (t_o="01010101") report "Error input d" severity error;

        wait;

    end process;
end tb;

-----------end part1_tb.vhdl------------------

Hello, this is my first code I've written in VHDL. It's a simple 4 to 1 MUX that can take in a vector of any width. However, when I try running my testbench, GHDL just hangs. I've looked at testbenches similar to mine, but I still cannot find why mine is hanging. Any ideas?

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

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

发布评论

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

评论(1

长伴 2024-10-28 23:27:28

嗯。我看不出有什么理由让它挂起。

我刚刚在 Ubuntu 10.04 上的 ghdl0.29 中尝试了你的代码 - 对我来说工作得很好(因为它退出时没有打印任何消息,所以看起来你的代码有效:) gtkwave 中的波浪看起来也很有说服力。

您可以尝试删除您的 work 文件夹和可执行文件并重新编译吗?

抱歉,这并不是真正能让您前进的答案!

Hmmm. I can't see any reason for it to hang.

I just tried your code in ghdl0.29 on Ubuntu 10.04 - works fine for me (in that it exits without printing any messages, so it seems your code works :) The waves look convincing in gtkwave also.

Can you try deleting your work folder and the executable and recompile?

Sorry, that's not really an answer that gets you forward!

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