From: truhlik_fredy on
Hi
Perhaps this is just newbie question, but I'm looking for tool helping me
with bits. The point is that I can't find it and I don't know if there is
something out there or the usage is so trivial for everybody used to
hardware design thinking so nobody bothered to create something like that.

If there is nothing then perhaps I will make one because I have sometimes
troubles to imagine it and I cought myself many times just putting
estimated number & synthesizing + praying it was right (time consuming +
very stupid method) or I just write on paper to understand and in no time I
run out of notebooks :)

But I found couple of little tools like DCM calculator to calculate divider
and multiplier factors to get desired frequency. Or Linear feedback shift
register tool etc....

But this one should be to better imagine bits (I don't know how better
describe that). For example I want counter capable counting to 6000dec and
I don't know how big register I should create, OK it's 2 powers 13 so the
register is

reg [12:0]counter;

But later I want to be able to take value of counter, divide it by 4 (so
shift >> 2) and use it somewhere with maximum number of 256. So i will take
the counter from bit 2 and should be 8 bit long, so 2+8=10, but sometimes i
forget that it's counted from zero so I forget to decrement 1 from the 10,
and then the final maximal number is 512, and when the destination is wide
enough it won't overflow and I end up with wrong design instead of:

wire [16:0] new_counter = counter[9:2];

For example I'm doing PAL signal generator with text mode etc... because I
was experimenting with Color PAL generation I ended up with much higher
x_counter then normally desired. And when calculating the adders for font
8x8 ROM i needed something to generate address. The ROM has 256 characters
with 8x8 bitmap (so 8bits per line = 1 byte per line => 8 bytes of data per
character) so the size is 2048 and it's 11 bits wide;

wire [10:0] adr;

and I have to take first 3bit of y_counter to change the lines in the font
character, soo...

y_counter[2:0]

The I need something witch will show 32 chars (so 5bit) one by one on X
axis but divided strongly because my X is running to fast

x_count[8:4] adn this should go to rom addres from bit 4 to bit 8 [7:3]

And then after line of text another set of 32 character should by show so
again y_count but divided by 8 because I want to leave enough space to
finish character before (so starting from bit 4 => from zero it's 3) and
should be showing 8 lines so 3bit, 3bit+ starting from 3 =6bit but from
zero it's 5, so i will use

y_counter[5:3]

and put everything together

adr={y_counter[5:3],x_count[8:4],y_counter[2:0]};

But I hooping to find utility to help me with this simple calculations,
it's just adding, subtracting, decreasing by 1 etc... but it's lot of it
and when I'm in 64bit large number I got easily lost and I would like to
have something to help me visualize that.

If nobody knows any tools like this, then perhaps I will do one, because
without it I'm making lot mistakes and wasting lot of time.

Thanks to everybody who could help me with that.







---------------------------------------
Posted through http://www.FPGARelated.com
From: Patrick Maupin on
On Apr 24, 8:46 pm, "truhlik_fredy" <anton.krug(a)n_o_s_p_a_m.gmail.com>
wrote:

> But I hooping to find utility to help me with this simple calculations,
> it's just adding, subtracting, decreasing by 1 etc... but it's lot of it
> and when I'm in 64bit large number I got easily lost and I would like to
> have something to help me visualize that.
>
> If nobody knows any tools like this, then perhaps I will do one, because
> without it I'm making lot mistakes and wasting lot of time.

Well, with something like Python, you can easily write little scripts
to keep track of this sort of thing. For example, at the Python
prompt, you can type:

>>> from math import log
>>> def bits_required(maxval, minval=0):
.... return int(log(maxval - minval)/log(2)) + 1
....
>>> bits_required(8191)
13
>>> bits_required(8192)
14
>>>

Regards,
Pat
From: truhlik_fredy on
>Well, with something like Python, you can easily write little scripts
>to keep track of this sort of thing. For example, at the Python
>prompt, you can type:
>
>>>> from math import log
>>>> def bits_required(maxval, minval=3D0):
>... return int(log(maxval - minval)/log(2)) + 1
>...
>>>> bits_required(8191)
>13
>>>> bits_required(8192)
>14
>>>>
>


That is almost exactly what I'm intending to do, just not in python. I
would like to make it interactive web page in php to make some
visualizations.

Bit required is just 1 thing. For example, do you know how big (I mean in
bits) it's just by looking on this?

{y_counter[5:3],x_count[8:4],y_counter[2:0]}

And when you are merging more signals into 1 bus to see things like, what
value the x_count[8:4] represents 512..32 (and in hex too), how many bits
it is, how many times it's divided what it could represent when inserted
into signal from LSB 0 so

MSB LSB
bits 4 3 2 1 0 (if it's writen from 0)
bits 8 7 6 5 4 (original)

so from bit 0 it would represent 32 .. 0

and what it represents when it's inserted to

{y_counter[5:3],x_count[8:4],y_counter[2:0]}

256..16

What is needed if i want include 300, it's needs to be up to 512, so it's
need to expand from 5bits to 6bits

{y_counter[5:3],x_count[9:4],y_counter[2:0]}

Now but the destination expandet to 11 bits and I want 10bits
so i can change y_counter[5:3] to y_counter[4:3] who is now representing
3..0

So I'm looking for something what has everything together and every change
interacting with rest, because then I will just forget to check something
and designe bigger bus etc....

So anybody any change to find something like this, or I just should start
with mine?

---------------------------------------
Posted through http://www.FPGARelated.com
From: Patrick Maupin on
On Apr 25, 2:33 am, "truhlik_fredy"
<anton.krug(a)n_o_s_p_a_m.n_o_s_p_a_m.gmail.com> wrote:

> Bit required is just 1 thing. For example, do you know how big (I mean in
> bits) it's just by looking on this?
>
> {y_counter[5:3],x_count[8:4],y_counter[2:0]}

Yes, 3 + 5 + 3 = 11. But, I will concede that, if the bus size gets
bigger, it could be harder to figure out.

> And when you are merging more signals into 1 bus to see things like, what
> value the x_count[8:4] represents 512..32 (and in hex too), how many bits

>>> [1 << x for x in range(4, 8+1)]
[16, 32, 64, 128, 256]

>>> range(0, 1<<(8+1), 1<<4)
[0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224,
240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400, 416, 432, 448,
464, 480, 496]

>>> ' '.join(hex(x) for x in range(0, 1<<(8+1), 1<<4))
'0x0 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0
0xe0 0xf0 0x100 0x110 0x120 0x130 0x140 0x150 0x160 0x170 0x180 0x190
0x1a0 0x1b0 0x1c0 0x1d0 0x1e0 0x1f0'

(stuff snipped)

> Now but the destination expandet to 11 bits and I want 10bits
> so i can change y_counter[5:3] to y_counter[4:3] who is now representing
> 3..0
>
> So I'm looking for something what has everything together and every change
> interacting with rest, because then I will just forget to check something
> and designe bigger bus etc....
>
> So anybody any change to find something like this, or I just should start
> with mine?        

I don't personally know of anything that does that, but seriously, I'd
just write a Python script with a few constants. You can have it do
all sorts of checking, and even write code for you if you want. (But
I'm not a GUI person.)

Regards,
Pat