|
|
This post was updated on .
Hello,
I have a problem with internal bus :
Between two Multi-Bit gates, we don't need to write the whidth of the bus ?
I mean that we should write it like that ? :
CHIP test {
IN a[16], b[16];
OUT out[16];
PARTS:
Add16(a=a, b=b, out=addab);
Not16(in=addab, out=notaddab);
}
And then, between one 16-bits gate and 16 one-bit gate, how do i have to write it ?
CHIP test {
IN a[16], b[16];
OUT out[16];
PARTS:
Add16(a=a, b=b, out=addab);
Not16(in=addab, out=notaddab);
Not(in=?, out=out[0]);
Not(in=?, out=out[1]);
Not(in=?, out=out[2]);
Not(in=?, out=out[3]);
Not(in=?, out=out[4]);
Not(in=?, out=out[5]);
Not(in=?, out=out[6]);
Not(in=?, out=out[7]);
Not(in=?, out=out[8]);
Not(in=?, out=out[9]);
Not(in=?, out=out[10]);
Not(in=?, out=out[11]);
Not(in=?, out=out[12]);
Not(in=?, out=out[13]);
Not(in=?, out=out[14]);
Not(in=?, out=out[15]);
}
And finally, if I want to implement a 16-bit Adder after 32 1-bit gates (just an example) :
CHIP test {
IN a[16], b[16];
OUT out[16];
PARTS:
Not(in=a[0], out=?);
Not(in=a[1], out=?);
Not(in=a[2], out=?);
Not(in=a[3], out=?);
Not(in=a[4], out=?);
Not(in=a[5], out=?);
Not(in=a[6], out=?);
Not(in=a[7], out=?);
Not(in=a[8], out=?);
Not(in=a[9], out=?);
Not(in=a[10], out=?);
Not(in=a[11], out=?);
Not(in=a[12], out=?);
Not(in=a[13], out=?);
Not(in=a[14], out=?);
Not(in=a[15], out=?);
Not(in=b[0], out=?);
Not(in=b[1], out=?);
Not(in=b[2], out=?);
Not(in=b[3], out=?);
Not(in=b[4], out=?);
Not(in=b[5], out=?);
Not(in=b[6], out=?);
Not(in=b[7], out=?);
Not(in=b[8], out=?);
Not(in=b[9], out=?);
Not(in=b[10], out=?);
Not(in=b[11], out=?);
Not(in=b[12], out=?);
Not(in=b[13], out=?);
Not(in=b[14], out=?);
Not(in=b[15], out=?);
Add16(a=?, b=?, out=out[16]);
}
Hope you will understand what is my problem (i'm french, and not really bilingual )
|
|
"Between two Multi-Bit gates, we don't need to write the whidth of the bus ? "
That is correct.
"And then, between one 16-bits gate and 16 one-bit gate, how do i have to write it ? "
Be sure to read the appendix. But to answer your question, given:
IN a[16], b[16];
OUT out[16];
PARTS:
Add16(a=a, b=b, out=addab);
Not16(in=addab, out=notaddab);
Not(in=?, out=out[0]);
Not(in=?, out=out[1]);
...
You can access a single bit of a bus using the same array-like notation you used for out.
Not(in=a[0], ...)
|
|
Ok thanks,
you mean .... like that :
CHIP test {
IN a[16], b[16];
OUT out[16];
PARTS:
Add16(a=a, b=b, out=addab);
Not16(in=addab, out=notaddab);
Not(in=notaddab[0], out=out[0]);
Not(in=notaddab[1], out=out[1]);
Not(in=notaddab[2], out=out[2]);
Not(in=notaddab[3], out=out[3]);
Not(in=notaddab[4], out=out[4]);
Not(in=notaddab[5], out=out[5]);
Not(in=notaddab[6], out=out[6]);
Not(in=notaddab[7], out=out[7]);
Not(in=notaddab[8], out=out[8]);
Not(in=notaddab[9], out=out[9]);
Not(in=notaddab[10], out=out[10]);
Not(in=notaddab[11], out=out[11]);
Not(in=notaddab[12], out=out[12]);
Not(in=notaddab[13], out=out[13]);
Not(in=notaddab[14], out=out[14]);
Not(in=notaddab[15], out=out[15]);
}
When i write this and try to load it in the Hardware simulator, the software load the following error message : "sub bus of an internal node may not be used"
|
|
It is saying that notaddab is an internal bus, so you can not sub-bus its pins via notaddab[0].
To get around this, you can:
Not16(in=addab, out[0]=notaddab0, out[1]=notaddab1, ...);
And then
Not(in=notaddab0, out=out[0]);
But, what chip are you trying to build? This seems like an overly complicated implementation.
|
|
I'm building the ALU, and the implementation of the 16-bit Adder cause me some problems, he is just next two 16-bit DMux, which I implement from 16 DMux. I want to know how to make two bus with the outputs of these DMux to plug them into the 16-bits Adder, and then be able to use each bit separatly.
The pieces of code was just examples.
|
Administrator
|
The example in A.5.3.1shows that you can have more than one "out=" connection for a part's output pin. This is analogous to soldering more than one wire to an output pin in the physical world.
If you need to use every bit of an internal bus individually, you can do something like:
SomePart16 (..., out=thing, // 16-bit bus
out[0]=thing0,
out[1]=thing1,
...
out[15]=thing15);
Here's a hint for the ALU. Why did the book have you make an Or8Way? Multiple out= connections make it easy to use.
--Mark
|
|
You helped me a lot ybakos and cadet1620 I think i have all the informations I need to start writing the code of my ALU.
|
|