Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

A simple problem with bidirectional bus in VHDL

The situation is: I have one bidirectional bus and two registers and two buffers tri-state. Just as you can see at this link: @@@@dl.dropbox.com/u/288645/Drawing1.png@@@@

But when I open the simulation in modelsim, I receive a warning message: "Warning: (vsim-8683) Uninitialized inout port /unity/registerA/data(7) has no driver." And the same to all the 8 bits of the bus. I tried a lot of things but I couldn't solve it. Then every time I simulate, the bus stays as "U" uninitialized state. If someone can help me, I'll be very grateful!!

P.S.: Whe I tried with only one register and one buffer tristate, it worked fine.


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity unity is
    port(data: inout std_logic_vector(7 downto 0);
         loadA,loadB,enA,enB: in bit;
         clk: in std_logic);
end entity;
architecture behavioral of unity is
component tristate
  port(data: out std_logic_vector(7 downto 0);
         data_in: in std_logic_vector(7 downto 0);
         enable: in bit);
end component;
component registrador
  port(lx: in bit;
         clk: in std_logic;
         data: inout std_logic_vector(7 downto 0);
         x: out std_logic_vector(7 downto 0));
end component;
signal out_a,out_b: std_logic_vector(7 downto 0);
begin
  registerA: registrador port map(loadA,clk,data,out_a);
  registerB: registrador port map(loadB,clk,data,out_b);
  bufferA: tristate port map(data,out_a,enA);
  bufferB: tristate port map(data,out_b,enB);
end architecture;

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;
entity registrador is
    generic(
        MAX_COUNT: in natural := 8);
    port(lx: in bit;
          clk: in std_logic;
          data: inout std_logic_vector(MAX_COUNT-1 downto 0);
          x: out std_logic_vector(MAX_COUNT-1 downto 0));
end entity;
architecture behavioral of registrador is
begin
    process(clk)
    begin
        if rising_edge(clk) then
            if lx = '1' then
                x <= data;
            end if;
        end if;
    end process;
end architecture;

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity tristate is
    port(data: out std_logic_vector(7 downto 0);
           data_in: in std_logic_vector(7 downto 0);
           enable: in bit);
end entity;
architecture behavioral of tristate is
  begin
    process(enable)
    begin
        if enable = '1' then
            data <= data_in;
        else
            data <= (others => 'Z');
        end if;
    end process;
end architecture;

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I think you're lacking a "data <= (others => 'Z');" in the registrador module.

    Thus, "registrador" is driving "U", not "Z" into that signal.

    That said... avoid using tri-state for anything but the top level modules.

    FPGA's don't have tri-state buffers in the internal logic (only in the I/O cells) and thus the tool will simply emulate tri-state behaviour with multiplexers.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Ok, it worked great! (Just put the enable/disable commands inside the register and the HiZ treatment too).

    But I've got another problem. When I simulate it, obviously, I do an assignment from the bus to the register (both 8bits-width), and sometimes the value received has some correct bits, but the others are "Uninitialized". Somebody knows how to fix this issue?