[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [oc] Commas? Concurrent execution in standard C?





On Sun, 16 Dec 2001, Paul McFeeters wrote:

> So in equivalent VHDL your statement would interrupt to Webpack as
>
> ERROR:Xst:827 - C:/test/test.vhd (Line 22). Signal i cannot be synthesized, bad synchronous description.

Eh?

It's a legal C program.

> I have to say if any of my programming teams in the past had of coded
> that and then explained to me that its functionally equivalent to "i =
> 4" I would kick them out of the door and fired them on the spot.

The point wasn't that anyone would ever want to use that example code to
assign the value of 4 to a variable, but to illustrate what is done by the
comma operator.

> And the use of this is? "var = x" seems just so much more practical to me!

Of course.  Usually when the comma operator is used, it is the
side-effects of evaluating the expressions that interests the programmer.
It's completely legal to write the following bizarre C statement:

 i = printf("hello "), printf("world!\n"), 6;

One case where this is commonly used is where you want to update more than
one variable in a for-loop:

 for (i=0; i<6; i++, j--) { ... }

> I don't expect my translation program to be as tight (efficient) or as fast as pure HDL coding
> but I'll try to get it as close as possible. The aim is simply to aid people's developments,

I'm not convinced, but I'll postpone judgement until I see your results.

Tobin

--
To unsubscribe from cores mailing list please visit http://www.opencores.org/mailinglists.shtml