3

I have been trying to get an array type as an entity port signal. I have simplified it as much as possible.

Package Types is
  Subtype Segment            is std_logic_vector(15 downto 0);
  Type    DataSegment        is array (natural range <>) of Segment;
  Type    DataSegmentType    is array (0 to 4) of Segment;
End Types;

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

library MyLibrary;
use MyLibrary.Types.all;

Entity MyPort is
  Port (
    pi_clk: in std_logic;
    pi_reset: in std_logic;
    po_myport_data: out std_logic_vector(15 downto 0)
);
End MyPort;

architecture Behavioral of MyPort is

Component UiPort is
  Port (
    pi_clk: in std_logic;
    pi_reset: in std_logic;
    pi_uiport_data: in DataSegment(0 to 2);
    po_uiport_data: out std_logic_vector(15 downto 0)
  );
End Component;

Component UiGoal is
  Port (
    pi_clk: in std_logic;
    pi_reset: in std_logic;
    po_uigoal_data: out std_logic_vector(15 downto 0)
  );
End Component;

--  There are potentially more ui entities here

**signal ls_dataSegment: DataSegment(0 to 2);**

-- The data segment array is the input
-- The process for this entity maps the array inputs to the data output
My_UiPort: UiPort
  Port Map(
    pi_clk => pi_clk, --: in std_logic;
    pi_reset => pi_reset, --: in std_logic;
    pi_uiport_data => ls_dataSegment, --: in DataSegment(0 to 2);
    po_uiport_data => po_myport_data--: out std_logic_vector(15 downto 0)
  );

-- Assign the out port to an element of the array
My_UiGoal: UiGoal
  Port Map(
    pi_clk => pi_clk, --: in std_logic;
    pi_reset => pi_reset, --: in std_logic;
    po_uigoal_data => ls_dataSegment(0) --: out std_logic_vector(15 downto 0)
  );

more instances map other elements of the array

This all seems to synthesize and build, the issue is when UiGoal writes a vector with a '1'in any position the simulator shows the signal as red with x's where the '1's are.

The library is used in all entities.

2 Answers 2

2

Based on the comment:

... the issue is when UiGoal writes a vector with a '1' in any position the simulator shows the signal as red with 'X''s where the '1''s are.

It sounds like there are multiple drivers for a std_logic_vector based on some unrevealed code parts, where one of the drivers applies '0' for a std_logic elements, and the other driver then applies '1' for the same std_logic element. The resolution function used for the std_logic will then make a result of 'X' as the value for the std_logic elements with "conflicting" drivers. VHDL-2008 resolution function (RESOLVED) is covered in IEEE Std 1076-2008 section 16.8.2.2 "The STD_LOGIC_1164 values".

However, based on the comment:

This all seems to synthesize and build ...

It contradicts the assumption of multiple drivers, since multiple drivers for the same signal are usually caught and reported as an error by the synthesis tool.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply. It actually was a case where a process was initializing the array in reset and another process writing to the array. It is odd that the synthesizer didn't catch it. All I could see was the red boundary and the x's where the '1's should have been. I removed the initialization and it works great, thank you.
2

Try changing the declaration of your Segment subtype from:

Subtype Segment is std_logic_vector(15 downto 0);

to:

Subtype Segment is std_ulogic_vector(15 downto 0);

This way, if you try to connect more than one output to the same net, your compiler will give you an error message like:

** Error: Nonresolved signal 'ls_dataSegment' has multiple sources.

This could give you new insights on where to fix your code.

1 Comment

I found the problem was because two processes were writing to the array, one in reset and the other to set the signals during operation. I thank you for your help, I am new to vhdl and will look into std_ulogic_vector. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.