16bit syntax problems

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

16bit syntax problems

TurdFurgusand
Hello everyone. Yes, I did read the Appendix a few times. For some reason, I can't get the syntax right with multi-bit bus input and outputs, I always get an error. I'm editing the .hdl files for Chapter 1, to implement them in the Hardware Simulator. I drew all of the Chapter 1 implementations out on paper. I know how to do all of them, so no one will take away from my learning if they show me how it's coded.

Here is some example code that doesn't work.

    IN  in[16];
    OUT out[16];

    PARTS: Foo(a[0..15] = in[0..15], b[0..15] = in[0..15], out = out[0..15]);


Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: 16bit syntax problems

cadet1620
Administrator
TurdFurgusand wrote
Hello everyone. Yes, I did read the Appendix a few times. For some reason, I can't get the syntax right with multi-bit bus input and outputs, I always get an error. I'm editing the .hdl files for Chapter 1, to implement them in the Hardware Simulator. I drew all of the Chapter 1 implementations out on paper. I know how to do all of them, so no one will take away from my learning if they show me how it's coded.

Here is some example code that doesn't work.

    IN  in[16];
    OUT out[16];

    PARTS: Foo(a[0..15] = in[0..15], b[0..15] = in[0..15], out = out[0..15]);
This only works if Foo has 16-bit a, b and out. To build the Xxx16 chips you need to do each bit with its own Xxx chip, selecting one bit of the 16-bit I/O signals at a time.
    Xxx(a=a[0], b=b[0], out=out[0]);
    etc.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: 16bit syntax problems

TurdFurgusand
This post was updated on .
Thanks Mark!

That works, but for some of the more complex chips I am running into really long code. Is there any way to loop internal pins, or create an array of internal pins without doing it all in an external program and copying and pasting the lines? Below I have shown an example. Is there any way syntax-wise to make this program smaller?

Thanks again,

    IN  a[16], b[16], tofu;
    OUT out[16];

    PARTS:
        Foo(in = tofu, out = n0);
        Foo(in = tofu, out = n1);
        Foo(in = tofu, out = n2);
        Foo(in = tofu, out = n3);
        Foo(in = tofu, out = n4);
        Foo(in = tofu, out = n5);
        Foo(in = tofu, out = n6);
        Foo(in = tofu, out = n7);
        Foo(in = tofu, out = n8);
        Foo(in = tofu, out = n9);
        Foo(in = tofu, out = n10);
        Foo(in = tofu, out = n11);
        Foo(in = tofu, out = n12);
        Foo(in = tofu, out = n13);
        Foo(in = tofu, out = n14);
        Foo(in = tofu, out = n15);

        Moo(a = a[0], b = n0, out = x0);
        Moo(a = a[1], b = n1, out = x1);
        Moo(a = a[2], b = n2, out = x2);
        Moo(a = a[3], b = n3, out = x3);
        Moo(a = a[4], b = n4, out = x4);
        Moo(a = a[5], b = n5, out = x5);
        Moo(a = a[6], b = n6, out = x6);
        Moo(a = a[7], b = n7, out = x7);
        Moo(a = a[8], b = n8, out = x8);
        Moo(a = a[9], b = n9, out = x9);
        Moo(a = a[10], b = n10, out = x10);
        Moo(a = a[11], b = n11, out = x11);
        Moo(a = a[12], b = n12, out = x12);
        Moo(a = a[13], b = n13, out = x13);
        Moo(a = a[14], b = n14, out = x14);
        Moo(a = a[15], b = n15, out = x15);

        Moo(a = b[0], b = tofu, out = y0);
        Moo(a = b[1], b = tofu, out = y1);
        Moo(a = b[2], b = tofu, out = y2);
        Moo(a = b[3], b = tofu, out = y3);
        Moo(a = b[4], b = tofu, out = y4);
        Moo(a = b[5], b = tofu, out = y5);
        Moo(a = b[6], b = tofu, out = y6);
        Moo(a = b[7], b = tofu, out = y7);
        Moo(a = b[8], b = tofu, out = y8);
        Moo(a = b[9], b = tofu, out = y9);
        Moo(a = b[10], b = tofu, out = y10);
        Moo(a = b[11], b = tofu, out = y11);
        Moo(a = b[12], b = tofu, out = y12);
        Moo(a = b[13], b = tofu, out = y13);
        Moo(a = b[14], b = tofu, out = y14);
        Moo(a = b[15], b = tofu, out = y15);

        Sho(a = x0, b = y0, out = out[0]);
        Sho(a = x1, b = y1, out = out[1]);
        Sho(a = x2, b = y2, out = out[2]);
        Sho(a = x3, b = y3, out = out[3]);
        Sho(a = x4, b = y4, out = out[4]);
        Sho(a = x5, b = y5, out = out[5]);
        Sho(a = x6, b = y6, out = out[6]);
        Sho(a = x7, b = y7, out = out[7]);
        Sho(a = x8, b = y8, out = out[8]);
        Sho(a = x9, b = y9, out = out[9]);
        Sho(a = x10, b = y10, out = out[10]);
        Sho(a = x11, b = y11, out = out[11]);
        Sho(a = x12, b = y12, out = out[12]);
        Sho(a = x13, b = y13, out = out[13]);
        Sho(a = x14, b = y14, out = out[14]);
        Sho(a = x15, b = y15, out = out[15]);
Reply | Threaded
Open this post in threaded view
|

Re: 16bit syntax problems

cadet1620
Administrator
There are no looping or conditional structures in HDL. TECS encourages thinking about abstraction and encapsulation. For instance, build Mux16 with Muxes, and build Mux4Way16 with Mux16s.

--Mark