Login  Register

whats wrong with my hdl - inc16

classic Classic list List threaded Threaded
5 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

whats wrong with my hdl - inc16

pwolf
32 posts
CHIP Inc16 {
    IN in[16];
    OUT out[16];

    PARTS:
   // Put you code here:
   Add16(a[0] = in[0], b[0] = true, out[0]= out[0]);
   Add16(a[1] = in[1], b[1] = false, out[1]= out[1]);
   Add16(a[2] = in[2], b[2] = false, out[2]= out[2]);
   Add16(a[3] = in[3], b[3] = false, out[3]= out[3]);
   Add16(a[4] = in[4], b[4] = false, out[4]= out[4]);
   Add16(a[5] = in[5], b[5] = false, out[5]= out[5]);
   Add16(a[6] = in[6], b[6] = false, out[6]= out[6]);
   Add16(a[7] = in[7], b[7] = false, out[7]= out[7]);
   Add16(a[8] = in[8], b[8] = false, out[8]= out[8]);
   Add16(a[9] = in[9], b[9] = false, out[9]= out[9]);
   Add16(a[10] = in[10], b[10] = false, out[10]= out[10]);
   Add16(a[11] = in[11], b[11] = false, out[11]= out[11]);
   Add16(a[12] = in[12], b[12] = false, out[12]= out[12]);
   Add16(a[13] = in[13], b[13] = false, out[13]= out[13]);
   Add16(a[14] = in[14], b[14] = false, out[14]= out[14]);
   Add16(a[15] = in[15], b[15] = false, out[15]= out[15]);






i dont know wht im doing wrong, i dont think my thought of setting the first value to true and the rest to false is wrong, so im sure its the hdl..  help is appreciated. and if by some chance im a moron and i've done this totally wrong, can you let me know !
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: whats wrong with my hdl - inc16

cadet1620
Administrator
2607 posts
pwolf wrote
   Add16(a[0] = in[0], b[0] = true, out[0]= out[0]);
   Add16(a[1] = in[1], b[1] = false, out[1]= out[1]);
   Add16(a[2] = in[2], b[2] = false, out[2]= out[2]);
...
Each Add16 in your circuit is an independent 16-bit adder. The first line adds 1 to in[0] and assigns it to out[0]. The carry from this addition is discarded because there is no connection to this adder's out[1].

The second line is another adder that adds 0 to in[1] and assigns it to out[1]. Since this adder's a[0] and b[0] are not connected, they default to 0 so there is never a carry generated by a[0]+b[0], so out[1] always equals in[1].

Your Inc16 needs to have exactly one Adder16 in it so that carry propagates correctly. The adder's "a" input needs to be "in" and the "b" input needs to be 1. The trick is to figure out how to set "b" = 1.

--Mark
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: whats wrong with my hdl - inc16

pwolf
32 posts
of course! what was I thinking..  I changed it now and it works, I'm such a moron after all! haha

help much appreciated, think I should try do my thinking earlier in the day in future.
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: whats wrong with my hdl - inc16

Salla
3 posts
In reply to this post by cadet1620
Well, I don't figure it out... And reading appendix A 5.3 again and again and again doesn't help me at all
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: whats wrong with my hdl - inc16

cadet1620
Administrator
2607 posts
Salla wrote
Well, I don't figure it out... And reading appendix A 5.3 again and again and again doesn't help me at all
Without knowing more about your HDL I can't guess what's wrong.

Email me your HDL and I'll give you some help.

--Mark