Can anyone give a short example of a full-adder - Please

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

Can anyone give a short example of a full-adder - Please

cybermailer
Hi everybody!

We had a short course about and, or, nor, ... and now our teacher said we should make a homework with this program. But never seen this programm never made.

Our homework:
Make a 4-bit adder with one half and 3 full adder + testing script

Now, i have testet a little bit but the time is running..

Can anyone - please - give a short example of a .hdl + testing file - > like only with a full adder?
I want to see how that works an how should be fine script for this.

Thx guys!
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone give a short example of a full-adder - Please

cadet1620
Administrator
I'd suggest starting by looking at the Add16.hdl skeleton file in projects/02. Change all the [16]s to [4]s.

Then look at the Add16.tst file and change it all to 4-bits. You can comment out the compare-to line while developing your HDL and test script.

If you are looking for info for how to make half-adders, full-adders and N-bit adders, read Chapter 2. It's available from the Nand2Tetris course page.

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

Re: Can anyone give a short example of a full-adder - Please

cybermailer
Thx for your answer - That helps me very much!
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone give a short example of a full-adder - Please

cybermailer
Everythings works as it should - fine!

I have one short questions left - maybe you can help me
- in my testing file
   -> if have this line output-list a%B1.4.1 b%B1.4.1 out%B1.4.1;
       WHAT describes this line.

- or how do i know how to make the comparison lines (like spaces, like |, ..)
like
|  a   |  b   | out  |
| 1100 | 0011 | 1111 |

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

Re: Can anyone give a short example of a full-adder - Please

cadet1620
Administrator
cybermailer wrote
- in my testing file
   -> if have this line output-list a%B1.4.1 b%B1.4.1 out%B1.4.1;
       WHAT describes this line.

- or how do i know how to make the comparison lines (like spaces, like |, ..)
like
|  a   |  b   | out  |
| 1100 | 0011 | 1111 |
The testing language is described in Appendix B of the book, which is not available on-line.

The easiest way to make the compare file is simply to run your test script with the compare-to line commented out. After verifying that the circuit is working correctly by examining the output file, rename the .out file to .cmp and uncomment the compare-to line.

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

Re: Can anyone give a short example of a full-adder - Please

cybermailer
In reply to this post by cybermailer
Oh. ok the colums with a/b/out are depending on the bits OK... only first question left.
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone give a short example of a full-adder - Please

cybermailer
Thx! Now it's clear!
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone give a short example of a full-adder - Please

cybermailer
This post was updated on .
And what if i have to define Halfadder and Fulladder by myself? (Not use the embeded function)

I have to make the 4bit Adder by myself...

I know Halfadder and Fulladder.


And how to combine both?
Or ist it possible do define the halfadder and fulladder function by myself and than to use it?
(like a half/full adder modul and to use in the program)
What is the best way to do this?

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

Re: Can anyone give a short example of a full-adder - Please

cadet1620
Administrator
Please don't include complete solutions in your posts. Please edit your post to remove the solutions to HalfAdder and FullAdder.

Once you have written and tested your HalfAdder.hdl and FullAdder.hdl you use them just like the built-in versions. As long as all three HDL files are in the same directory this happens automatically.

There is no way to embed the definition of HalfAdder and FullAdder within your Add4. You could include copies of their definitions as comments in your Add4.hdl:
    /** Add4.hdl -- Four bit adder

    Uses HalfAdder and FullAdder defined as follows:

    [Cut and paste source for HalfAdder.hdl and FullAdder.hdl here.]
    */

    [Remainder of Add4.hdl.]

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

Re: Can anyone give a short example of a full-adder - Please

cybermailer
oh. thx - now i understand how it should work!

- ps -> why no posting of code ? copyright? or?
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone give a short example of a full-adder - Please

ybakos
To reduce the temptation to simply copy code without understanding it in order to get a test to pass.

Struggling with the problems and discovering your own solution is a key part of reaching understanding.
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone give a short example of a full-adder - Please

cybermailer
Your right! But now it had made click in my brain - and i understand everything!

Thx for helping!