【问题标题】:bidirectional tri-state buffer双向三态缓冲器
【发布时间】:2017-09-13 20:29:01
【问题描述】:

我正在做一个需要双向三态缓冲区的项目。 我根据我在这个社区和其他一些网站上的搜索开发了一个 VHDL 代码。但它不能正常工作。下面是VHDL代码。

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity Inter_Con_Mod is
    generic(WL: integer := 8);
    port(In1: in signed(WL-1 downto 0);
          RW: in std_logic;
          Data_IO1: inout signed(WL-1 downto 0);
          Out1: out signed(WL-1 downto 0));

end Inter_Con_Mod;

architecture Behav of Inter_Con_Mod is

begin

Data_IO1 <= In1 when RW = '1' else
                (others => 'Z');

Out1 <= Data_IO1;


end Behav;

这是测试台代码:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;

USE ieee.numeric_std.ALL;

ENTITY InterCon_test IS
END InterCon_test;

ARCHITECTURE behavior OF InterCon_test IS 

     -- Component Declaration for the Unit Under Test (UUT)

     COMPONENT Inter_Con_Mod
     PORT(
            In1 : IN  signed(7 downto 0);


            RW : IN  std_logic;
            Data_IO1 : INOUT  signed(7 downto 0);

            Out1 : OUT  signed(7 downto 0)

          );
     END COMPONENT;


    --Inputs
    signal In1 : signed(7 downto 0) := (others => '0');


    signal RW : std_logic := '0';

    --BiDirs
    signal Data_IO1 : signed(7 downto 0);


    --Outputs
    signal Out1 : signed(7 downto 0);

    -- No clocks detected in port list. Replace <clock> below with 
    -- appropriate port name 

    --constant <clock>_period : time := 10 ns;

BEGIN

    -- Instantiate the Unit Under Test (UUT)
    uut: Inter_Con_Mod PORT MAP (
             In1 => In1,


             RW => RW,
             Data_IO1 => Data_IO1,

             Out1 => Out1

          );

    -- Clock process definitions
-- Stimulus process
    stim_proc: process
    begin       
        -- hold reset state for 100 ns.
        wait for 5 ns;  
        In1 <= "01111111";
        wait for 5 ns;
        RW <= '1';
        wait for 5 ns;

        RW <= '0';
        wait for 20 ns;
        Data_IO1 <= "00101010";



        wait;
    end process;

END;

但是看看模拟结果中发生了什么:

我不明白为什么它会忽略我在将 RW 设置为 0 之前提供的测试台刺激。

提前致谢。

【问题讨论】:

  • 事实是当我删除 Data_IO1
  • 如果您在一根线上有两个驱动器以防止争用,则一次只能驱动其中一个,而另一个必须是高阻抗 ('Z')。您需要在测试平台中适当时分配“Z”。您还可以使用基于对“Z”的不同控制和对行驶时间的控制的单个控制线进行争用。
  • 哇。谢谢!我不知道。不幸的是,我找不到像你那样讨论这个问题的任何东西。我用你的评论解决了。
  • 期待硬件思维似乎很常见。发布答案。
  • 是的。我会发布一个答案。还有一件事。当我想合成这样一个模块时,实际上“Z”分配是自动推断的(因为它意味着高阻抗),但是在测试台中我需要手动完成,是吗?

标签: io vhdl bidirectional inout tri-state-logic


【解决方案1】:

感谢@user1155120,问题得以解决。我已将整个代码更改为以下内容。

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity Inter_Con_Mod is
    generic(WL: integer := 8);
    port(PortL,PortR: inout signed(WL-1 downto 0);
          RW: in std_logic);

end Inter_Con_Mod;

architecture Behav of Inter_Con_Mod is

begin


 PortR <= PortL when RW = '0' else
            (others => 'Z');

 PortL <= PortR when RW = '1' else
            (others => 'Z');

end Behav;

所以我有 2 个输入端口和一个选择输入端口。问题不在模块的代码中。它在测试台上。我必须驱动我需要充当输出的输入端口,以免线路上的数据受到干扰。下面是Testbench代码:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;

ENTITY Test IS
END Test;

ARCHITECTURE behavior OF Test IS 

    -- Component Declaration for the Unit Under Test (UUT)

    COMPONENT Inter_Con_Mod
    PORT(
         PortL : INOUT  signed(7 downto 0);
         PortR : INOUT  signed(7 downto 0);
         RW : IN  std_logic
        );
    END COMPONENT;


   --Inputs
   signal RW : std_logic := '0';
    --BiDirs
   signal PortL : signed(7 downto 0);
   signal PortR : signed(7 downto 0);
   -- No clocks detected in port list. Replace <clock> below with 
   -- appropriate port name 



BEGIN

    -- Instantiate the Unit Under Test (UUT)
   uut: Inter_Con_Mod PORT MAP (
          PortL => PortL,
          PortR => PortR,
          RW => RW
        );




   -- Stimulus process
   stim_proc: process
   begin        

            PortL <= "01111111";
            PortR <= (others => 'Z');

            wait for 5 ns;
            RW <= '1';
            wait for 5 ns;
            PortR <= "01111100";
            PortL <= (others => 'Z');

            wait for 20 ns;



            wait;


      wait;
   end process;

END;

我希望这可以帮助那些像我一样刚接触硬件的人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-24
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 2013-08-14
    • 1970-01-01
    • 2011-03-05
    • 2011-08-20
    相关资源
    最近更新 更多