On 1/31/2013 12:05 PM, Rob Gaddi wrote:
> On Thu, 31 Jan 2013 08:25:56 -0800 (PST)
> wrote:
>
>> Hi all ,
>>
>> I have a question
>> I would like the equivalent of this code : A<=B(0) or B(1) or B(2) or ... B(N). with loop generate.
>>
>> I tired this code :
>> CevRec: for Ilink in 0 to NB_FLT-1 generate
>> A<= A or B(Ilink);
>> end generate CevRec;
>> result<= A ;
>> remark A is an signal.
>> At the compilation I have an error :
>> Multiple non-tristate drivers for net ...
>>
>> Thank for yor help .
>>
>> Oliver
>>
>>
>
> Can't do that with a signal, and therefore you can't do it with a
> for..generate loop. If your synthesis tool supports VHDL-2008, there's
> a unary OR operator. If not, bring in the std_logic_misc library, and
> use the OR_REDUCE function. Or you could write your own OR_REDUCE with
> a for..loop, using a variable instead of a signal, which will work. But
> either way, you want:
>
> result<= or B; (VHDL-200
> result<= OR_REDUCE(B); (earlier)
The loop should work just fine if a variable is added, then assigned to
the signal at the end of the loop. No need for the generate statement,
but it would need to be in a process or a function. In fact, this would
make a good function... which is what has been done in VHDL-2008 with
the uniary operators.
variable temp : std_logic;
TestCode: for Ilink in 0 to NB_FLT-1 loop
temp := temp or B(Ilink);
end loop;
A <= temp;
I've been using VHDL-2008 on my latest project and it is working well.
My only issue is finding good documentation I can use offline. I would
buy an e-book if I knew any given one was a good one.
--
Rick