2

I have a concurrent loop which has two errors. This is the only code in the file: I am receiving the following errors. I would be grateful for your help. How would I fix this?

Signal Output1 in unit filter(4) is connected to following multiple drivers:

Signal flag in unit filter(4) is connected to following multiple drivers:


Minimal Complete and Verifiable Example created from OP's EDAPlayground link

library ieee;
use ieee.std_logic_1164.all;
-- use IEEE.STD_LOGIC_ARITH.ALL;
-- use IEEE.std_logic_unsigned.ALL ;

entity ex_case is
    port ( output: out std_ulogic_vector(3 downto 0) );
end entity ex_case;
    -- signal flag1: boolean := '0'; -- this declaration does not belong here
architecture a1 of ex_case is
    signal flag1: std_ulogic := '0';  -- was erroneously type boolean
begin

loop1: 
    for j in 0 to 3 generate -- for loop outputting data
        flag1 <= '0';        -- reset the flag, same as output_ready
loop2: 
        for i in 0 to 3 generate 
            output(j) <= '1' when  i >= j and flag1 = '0' else 
                         '0' when flag1 = '0';
            flag1 <=     '1' when  i >= j and flag1 = '0'; -- output when valid data is available
        end generate loop2;
    end generate loop1;   
end architecture a1;

NOTE: the types of both flag1 and output are changed to unresolved types to allow both algorithm errors to be revealed.


This is the error message: enter image description here enter image description here

enter image description here

enter image description here

12
  • You have n concurrent signal assignments to Output(j) and n x n concurrent signal assignments to flag. See IEEE Std 1076-2008 11.8 Generate statements, 14.5.3 Generate statements, 14.5.2 Block statements, 14.5.5 Other concurrent statements Elaboration of all concurrent signal assignment statements and concurrent assertion statements consists of the construction of the equivalent process statement followed by the elaboration of the equivalent process statement. You have multiple processes driving Output(j) and flag. Provide an MCVE.
    – user1155120
    Dec 4, 2016 at 19:27
  • n=4 in this test case
    – Hamoudy
    Dec 4, 2016 at 19:27
  • No, really, provide a Minimum, Complete and Verifiable Example and please don't delete your question this time (VHDL: Signal is connected to following multiple drivers:), a deleted question can be resurrected within 60 days and questions can be edited. Show complete error statements.
    – user1155120
    Dec 4, 2016 at 19:45
  • Tiny pictures of error messages are hard to read and the two statements at the bottom are incomplete. And your example isn't complete.
    – user1155120
    Dec 4, 2016 at 19:47
  • @user1155120 Thank you very much for your help and guidance. Well remembered on my post yesterday!
    – Hamoudy
    Dec 4, 2016 at 19:50

1 Answer 1

1

There's an issue of inferred latches on Output. This is caused by the conditions present in the concurrent signal assignment, and are reported in synthesis. We want to avoid latches.

So with an Minimal, Complete and Verifiable Example we can modify the example to provide a combinatorial OR for all the flag1 drivers in all the processes produced by the nested for generate statements (14.5.5 Other concurrent statements Elaboration of all concurrent signal assignment statements and concurrent assertion statements consists of the construction of the equivalent process statement followed by the elaboration of the equivalent process statement.).

We also want to provide a selector to specify which outer and inner for generate loop statement specified output(j) contributes to output:

library ieee;
use ieee.std_logic_1164.all;

entity ex_case is
    port ( output: out std_ulogic_vector(3 downto 0) );
end entity ex_case;
architecture foo of ex_case is
    signal flag1: std_ulogic := '0';
    constant n: natural := 4;
    function reduce_or (input: std_logic_vector) return std_logic is
        variable retval: std_logic;
    begin  -- MAY BE replace by "or" -2008, or by different reduction function
        retval := '0';
        for i in input'range loop
            retval := retval or input(i);
        end loop;
        return retval;
    end function;
    function firstflag (iflag: std_logic_vector) return integer is
    begin
        for i in iflag'range loop
            if To_bit(iflag(i)) = '1' then
                return i;
            end if;
        end loop;
        return iflag'LEFT; -- This will park on iflag' when no flag is set
    end function;
    signal iflag: std_logic_vector(0 to n - 1);
    subtype iflag_subtype is std_logic_vector(iflag'range);
begin

loop1: 
    for j in 0 to n - 1 generate 
        type output_array is array (0 to n - 1) of std_logic;
        signal ioutput: output_array;
        signal jselect: natural range 0 to n - 1;
    begin
        -- flag1 <= '0'; -- REMOVED  -- reset the flag, same as output_ready
loop2: 
        for i in 0 to n - 1 generate 
            signal iflag: std_logic_vector (0 to n - 1);
        begin
            ioutput(j) <= '1' when  i >= j and iflag(j) = '0' else 
                          '0';
            iflag(i) <=  '1' when  i >= j else 
                         '0'; -- output when valid data is available
            iflag(j) <= reduce_or(iflag);
        end generate loop2;
        output(j) <= ioutput(firstflag(iflag)); -- A Multiplexer
    end generate loop1;  

    flag1 <= '1' when iflag /= iflag_subtype'(others => '0') else
             '0'; 
end architecture foo;

This analyzes, elaborates and simulates (while doing nothing impressive but demonstrating there's only one source for any particular output).

Note you can switch output back to type std_logic_vector, along with adding your address of output ports of your n x n switch as a condition for assigning flag and output to a '1'.

You might imagine depending on the packages you have available or the revision of the VHDL standard your tool chain supports it might be possible to eliminate function reduce_or instead using a pre-existing function or the unary "or" operator (-2008).

Without also having the address of the output port as a condition this example can't be thoroughly tested.

1
  • 1
    Persistent, anyway. If you had the address in your example I would have simulated it.
    – user1155120
    Dec 5, 2016 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.