ALU Error

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

ALU Error

Mike2345
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: ALU Error

WBahn
Administrator
What error are you getting?

We are not mind readers.
Reply | Threaded
Open this post in threaded view
|

Re: ALU Error

Mike2345
Hello again

Yes of course. Sorry about that. I thought u would run it that's y I didn't mentioned about the error. When I comment the ng and zr implementation the implementation of the output seems to be okay when I load the hell file but when I start running it. It come up with an error called(Comparison failure at line 2). Especially the implementation for the output seems to be okay with me and I tried my best to figure it out but I can't. But when we decomment the ng and zr implementation the hdl file can not even be loaded to the hardware simulator

Thank you

Michale Rezene 

On Sun, Oct 6, 2019, 12:36 AM WBahn [via Nand2Tetris Questions and Answers Forum] <[hidden email]> wrote:
What error are you getting?

We are not mind readers.



If you reply to this email, your message will be added to the discussion below:
http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/ALU-Error-tp4033715p4033719.html
To unsubscribe from ALU Error, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: ALU Error

WBahn
Administrator
I don't see any mention of ng or zr in the code you posted, so even if I went to the effort of taking your code, creating a file for it and putting it together it would shed no light as to what the problem might be with your implementation of these two signals.

As for why your ALU is failing the comparison checks when you don't have ng and zr implemented, that one's pretty simple. Your ALU is supposed to generate these two signals and the comparison file is comparing what your ALU is generating for them to what it is supposed to be generating for them. If you have them commented out, it's not too surprising that it fails the comparison.
Reply | Threaded
Open this post in threaded view
|

Re: ALU Error

Mike2345
Okay I get it 
maybe the attached screenshot can be a clear view

On Sun, Oct 6, 2019, 1:24 AM WBahn [via Nand2Tetris Questions and Answers Forum] <[hidden email]> wrote:
I don't see any mention of ng or zr in the code you posted, so even if I went to the effort of taking your code, creating a file for it and putting it together it would shed no light as to what the problem might be with your implementation of these two signals.

As for why your ALU is failing the comparison checks when you don't have ng and zr implemented, that one's pretty simple. Your ALU is supposed to generate these two signals and the comparison file is comparing what your ALU is generating for them to what it is supposed to be generating for them. If you have them commented out, it's not too surprising that it fails the comparison.


If you reply to this email, your message will be added to the discussion below:
http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/ALU-Error-tp4033715p4033725.html
To unsubscribe from ALU Error, click here.
NAML

Screenshot 2019-10-05 22.28.05.png (199K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ALU Error

WBahn
Administrator
I think your problem is that you are using the output signal as an internal signal and then trying to subscript it, which is not allowed.

If I am building a chip named Fred that has an output signal fredsOutput that is an 8-bit wide bus and generate fredsOutput by combining two 4-bit outputs from two instances of Sue chips, then I can do that by

Sue (in = whatever, suesOutput = fredsOutput[0..3]);
Sue (in = whatever, suesOutput = fredsOutput[4..7]);

Now, if I want to also use the top two bits of the output as a two-bit input to chip Bob, it might be tempting to go

Bob (in = fredsOutput[6..7), out = whatever);

but this won't work because fredsOutput is an output port, not an input port. But what I can do is define a separate two-bit internal signal and use that.

Sue (in = whatever, suesOutput = fredsOutput[0..3]);
Sue (in = whatever, suesOutput = fredsOutput[4..7], suesOutput[2..3] = bobsInput);
Bob (in = bobsInput, out = whatever);
Reply | Threaded
Open this post in threaded view
|

Re: ALU Error

Mike2345
I Completely understand the problem and Thank you for that  but I don't get the solutions u provided

On Sun, Oct 6, 2019, 1:52 AM WBahn [via Nand2Tetris Questions and Answers Forum] <[hidden email]> wrote:
I think your problem is that you are using the output signal as an internal signal and then trying to subscript it, which is not allowed.

If I am building a chip named Fred that has an output signal fredsOutput that is an 8-bit wide bus and generate fredsOutput by combining two 4-bit outputs from two instances of Sue chips, then I can do that by

Sue (in = whatever, suesOutput = fredsOutput[0..3]);
Sue (in = whatever, suesOutput = fredsOutput[4..7]);

Now, if I want to also use the top two bits of the output as a two-bit input to chip Bob, it might be tempting to go

Bob (in = fredsOutput[6..7), out = whatever);

but this won't work because fredsOutput is an output port, not an input port. But what I can do is define a separate two-bit internal signal and use that.

Sue (in = whatever, suesOutput = fredsOutput[0..3]);
Sue (in = whatever, suesOutput = fredsOutput[4..7], suesOutput[2..3] = bobsInput);
Bob (in = bobsInput, out = whatever);



If you reply to this email, your message will be added to the discussion below:
http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/ALU-Error-tp4033715p4033728.html
To unsubscribe from ALU Error, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: ALU Error

WBahn
Administrator
The HDL simulator provided by the authors has some strange limitations. One of them is that you can't use sub-buses of internal signals. You also can't use an output signal as an internal signal. Most "real" HDLs don't have this restriction -- but most real HDL simulators are enormously more complicated and hard to use overall. I'm not privy to why the authors imposed these restrictions, but I can well imagine that it made implementing their toy HDL simulator significantly easier.

To compensate, the authors provided a mechanism to achieve the same effect as subbusing internal signals by allowing you to use the output pins of a part used in a design multiple times to drive different internal signals. This is also something that most real HDLs do not support, so in this sense the authors' toy HDL is more flexible than most real ones.

Mark Armbrust put together an indepth post that he christened the Survival Kit for the hardware side of the N2T project.

http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/Hardware-Construction-Survival-Kit-td3385741.html

It does have a few minor errors in it, but overall is very useful.