On Friday 16 June 2006 06:35, Tom Cook wrote:
> On 6/16/06, Timothy Miller <[EMAIL PROTECTED]> wrote:
> > I'm making this up as I go along, so I'm not sure if I'm skipping
> > over something or not. Before we go further, I figure we should
> > have a short quiz.
> >
> > Explain this code in detail:
> >
> > module whatsit(a, b, d, c);
> > input [3:0] a, b;
> > input d;
> > output [3:0] c;
> > wire [3:0] e, f;
> > assign e = a & b;
> > assign f = a + b;
> > assign c = d ? e : f;
> > endmodule
>
> To shift this into C:
>
> char whatsit( char a, char b, bool d )
> {
> if( d ) return a & b;
> else return (a + b) & 0x0F;
> }
Coming from a C++ background I immediately associated a wire with an
rvalue and a const type, and a reg with an lvalue and a non-const type.
So, using pass-by-reference in C++:
void whatsit(const char & a, const char & b, const bool & d, char & c) {
c = d ? (a & b) : (a + b);
}
Assuming that we want 8-bit in- and outputs rather than 4-bit ones, but
that wasn't the point...
Lourens
pgp016YnzK80M.pgp
Description: PGP signature
_______________________________________________ Open-graphics mailing list [email protected] http://lists.duskglow.com/mailman/listinfo/open-graphics List service provided by Duskglow Consulting, LLC (www.duskglow.com)
