On 5/31/05, Patrick McNamara <[EMAIL PROTECTED]> wrote:
> >For 16 bit, you can have 565 or 555. Expanding to 888 is just a matter of
> >adding zeroes, or again, just wiring.
> >
> >
> >
> It's actually a multiply by 8 scaling factor for 555 mode, but are
> correct, you can simply move all the bits over in the hardware.
>
Not entirely accurate. If you just shift, then 'b11111 becomes
'b11111000, which isn't right, because you really want 'b11111111.
Let's consider a simple case. You have 15 shades of gray, and you
want to get 255. 15 evenly divides into 255, giving you 17, so you
can multiply your 4-bit number by 17. That's the same as just
concatenating.
wire [3:0] old_red;
wire [7:0] new_red = {old_red, old_red};
Now, following that, you'd like to do something similar when going
from 5 to 8. Unfortunately, it's not so easy to multiply by
8.225806452. :) However, if you do the same concatenation, you get a
similar result.
wire [4:0] old_red;
wire [7:0] new_red = {old_red, old_red[4:2]};
Run the program below. The first column is the 5-bit number, the
second column is the "exact" converstion, and the third is the
concatenation version. Notice that you only get a handful that are
off by one.
#include <stdio.h>
#define _GNU_SOURCE
#include <math.h>
double round(double);
main()
{
int i;
for (i=0; i<32; i++) {
printf("%5d %5d %5d\n", i, (int)round(i*255.0/31.0), (i<<3) | (i>>2));
}
}
_______________________________________________
Open-graphics mailing list
[email protected]
http://lists.duskglow.com/mailman/listinfo/open-graphics
List service provided by Duskglow Consulting, LLC (www.duskglow.com)