Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Vhdl syntax for generate ...

Reply
Thread Tools

Vhdl syntax for generate ...

 
 
olivier90dir@gmail.com
Guest
Posts: n/a
 
      01-31-2013
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




 
Reply With Quote
 
 
 
 
Rob Gaddi
Guest
Posts: n/a
 
      01-31-2013
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)


--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order. See above to fix.
 
Reply With Quote
 
 
 
 
rickman
Guest
Posts: n/a
 
      01-31-2013
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
 
Reply With Quote
 
1999outback@gmail.com
Guest
Posts: n/a
 
      01-31-2013
> variable temp : std_logic;
>
> TestCode: for Ilink in 0 to NB_FLT-1 loop
> temp := temp or B(Ilink);
> end loop;
> A <= temp;


Don't forget to initialize the variable!
 
Reply With Quote
 
rickman
Guest
Posts: n/a
 
      01-31-2013
On 1/31/2013 5:35 PM, wrote:
>> variable temp : std_logic;
>>
>> TestCode: for Ilink in 0 to NB_FLT-1 loop
>> temp := temp or B(Ilink);
>> end loop;
>> A<= temp;

>
> Don't forget to initialize the variable!


Very good point. Does this do it? I'm pretty sure that unlike signals
where initialization is not always supported in synthesis, variable
initialization should be ok.


variable temp : std_logic := '0';

TestCode: for Ilink in 0 to NB_FLT-1 loop
temp := temp or B(Ilink);
end loop;
A<= temp;

--

Rick
 
Reply With Quote
 
olivier90dir@gmail.com
Guest
Posts: n/a
 
      02-01-2013
Le vendredi 1 février 2013 00:44:25 UTC+1, rickman a écrit*:
> On 1/31/2013 5:35 PM, wrote:
>
> >> variable temp : std_logic;

>
> >>

>
> >> TestCode: for Ilink in 0 to NB_FLT-1 loop

>
> >> temp := temp or B(Ilink);

>
> >> end loop;

>
> >> A<= temp;

>
> >

>
> > Don't forget to initialize the variable!

>
>
>
> Very good point. Does this do it? I'm pretty sure that unlike signals
>
> where initialization is not always supported in synthesis, variable
>
> initialization should be ok.
>
>
>
>
>
> variable temp : std_logic := '0';
>
>
>
> TestCode: for Ilink in 0 to NB_FLT-1 loop
>
> temp := temp or B(Ilink);
>
> end loop;
>
> A<= temp;
>
>
>
> --
>
>
>
> Rick

Thank For your Help ...

olive.

 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      02-04-2013
Synthesis supports declaration initializations in subprograms (functions orprocedures). Some FPGA synthesis tools will support declaration initializations in processes for some targets, but using them is fraught with all kinds of problems (it involves the system reset, which is best handled explicitly for a variety of reasons beyond the scope of this discussion)

Whether it will do what you need, that depends...

If this code is enclosed in a subprogram that is called inside a process, then the variable gets initialized each time the subprogram is called, and it will do what you need.

However, if this code is embedded directly inside a process, the variable initialization happens only once, when the process is initialized. The process never exits, it only suspends and wakes up again, executing only the executable statements until it suspends again (declarations are not consideredexecutable statements, even if they execute a subprogram call in an initialization). Therefore, the variable is only initialized once, and will not work in this application. You would need an assignment statement prior to the loop to initialize the variable every time before the loop runs.

Andy
 
Reply With Quote
 
rickman
Guest
Posts: n/a
 
      02-06-2013
On 2/4/2013 11:50 AM, Andy wrote:
> Synthesis supports declaration initializations in subprograms (functions or procedures). Some FPGA synthesis tools will support declaration initializations in processes for some targets, but using them is fraught with all kinds of problems (it involves the system reset, which is best handled explicitly for a variety of reasons beyond the scope of this discussion)
>
> Whether it will do what you need, that depends...
>
> If this code is enclosed in a subprogram that is called inside a process, then the variable gets initialized each time the subprogram is called, and it will do what you need.
>
> However, if this code is embedded directly inside a process, the variable initialization happens only once, when the process is initialized. The process never exits, it only suspends and wakes up again, executing only the executable statements until it suspends again (declarations are not considered executable statements, even if they execute a subprogram call in an initialization). Therefore, the variable is only initialized once, and will not work in this application. You would need an assignment statement prior to the loop to initialize the variable every time before the loop runs.
>
> Andy


Yep, I gave the process a test and you are absolutely right, the
variable only gets initialized once when the process is initialized.

--

Rick
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Failed to generate a user instance of SQL Server. Only an integratedconnection can generate a user instance. Harlan Messinger ASP .Net 2 03-28-2010 06:51 PM
VHDL-2002 vs VHDL-93 vs VHDL-87? afd VHDL 1 03-23-2007 09:33 AM
How to generate warnings when How generate a warning when int is converted to bool or vice versa? PengYu.UT@gmail.com C++ 3 04-06-2006 11:24 PM
How to generate variable labels for same component within a generate loop Weng Tianxiang VHDL 5 02-16-2006 01:45 PM
xsl syntax to generate all caps with _ Mikael Petterson XML 3 09-11-2003 05:03 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57