Author Topic: multi-bit full adder, need help debugging! :O  (Read 7726 times)

0 Members and 1 Guest are viewing this topic.

Offline miotatsu

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 332
  • Rating: +11/-1
    • View Profile
multi-bit full adder, need help debugging! :O
« on: May 07, 2010, 10:20:47 pm »
http://pastie.org/951047
^Its a 3-bit full adder but it doesn't work D:
So i need help debugging it and stuffs
if you dont know what a full adder is (and i do have a working 1-bit full adder)
it is:
http://en.wikipedia.org/wiki/Full_adder
if someone knows about full adders i would appreciate it if they could help me debug it
I Can't figure out what is exactly wrong with it, but i know it properly overflows when you give it 111+111 and it gives the correct answer when you give it 000+000
nothing else seems to be working quite right
« Last Edit: May 07, 2010, 10:24:01 pm by miotatsu »

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: multi-bit full adder, need help debugging! :O
« Reply #1 on: May 07, 2010, 10:52:10 pm »
Well in the version you pasted, you seem to be missing an end somewhere...  I couldn't really test anything but the logic (which is fine like you said) without knowing where it goes :P
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline miotatsu

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 332
  • Rating: +11/-1
    • View Profile
Re: multi-bit full adder, need help debugging! :O
« Reply #2 on: May 07, 2010, 10:53:34 pm »
oh i will check that :O

okay im pretty sure its supposed to go after line 28, the idea is take two sets of input, each set taking 3 bits, so that should be right i think, however its throwing a syntax error now

Edit: cleaned up my own double post
« Last Edit: May 07, 2010, 11:17:56 pm by miotatsu »

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: multi-bit full adder, need help debugging! :O
« Reply #3 on: May 07, 2010, 11:31:17 pm »
Well, after adding a couple simple things you missed (don't know if it was just in the pastebin or what) and changing the output format a bit, and removing a lot of excess parenthesis, it seems to work fine:
Code: [Select]
:ClrHome
:Delvar L132->Dim(L1
:1->P :1->O
:24->M
:For(N,0,1
:0->L:1->I
:While L<M
:Repeat A
:getkey->B
:(B=92)+(B=102->A
:(B=92->L1(P+L
:End
:Output(N,I,Ans
:I+1->I
:L+8->L
:End
:End
:ClrHome
:For(N,0,2
:L1(P) xor L1(P+1->L1(P+3
:L1(P+3) xor L1(P+2->L1(P+6
:L1(P+2) and L1(P+3->L1(P+4
:L1(P) and L1(P+1->L1(P+5
:L1(P+4) or L1(P+5->L1(P+8
:Output(N+1,1,L1(P+6
:Output(N+1,3,Ans
:1+O->O
:P+8->P
:End
You do realize that it's reading the bits --> that way, not <-- like normal, right?...
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: multi-bit full adder, need help debugging! :O
« Reply #4 on: May 08, 2010, 12:00:53 am »
Mhmm even after reading the Wiki page I still don't get it x.x

What is the main use of this? I just don't get anything.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: multi-bit full adder, need help debugging! :O
« Reply #5 on: May 08, 2010, 12:03:58 am »
It's a simulation of how electronics internally add numbers
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: multi-bit full adder, need help debugging! :O
« Reply #6 on: May 08, 2010, 12:10:53 am »
aaah ok I see. I thought it was some sort of programming routine or something like that.

Offline miotatsu

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 332
  • Rating: +11/-1
    • View Profile
Re: multi-bit full adder, need help debugging! :O
« Reply #7 on: May 08, 2010, 12:16:28 am »
Cooliojazz:eh it still is not working for me (it runs but does not give correct output), also i didn't think about the order at the time of programming, i suppose that would make the resulting output backwards wouldn't it? (If you mean what i think you mean) that shouldn't affect the result other than reading order though right?

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: multi-bit full adder, need help debugging! :O
« Reply #8 on: May 08, 2010, 12:28:07 am »
No, it would do more than that.  Any numbers you put in backwards will work, otherwise...  Well, in 110+100 if you add 1+1 then 1(c)+0+1 then 1(c)+0+0 and get 001, that's different than if you add 0+0 then 1+0 then 1+1 and get 1010, right?
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline miotatsu

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 332
  • Rating: +11/-1
    • View Profile
Re: multi-bit full adder, need help debugging! :O
« Reply #9 on: May 08, 2010, 12:47:33 am »
ah, i see now. I think that is why the output is wrong too then, it looks like it is right but just messed up because of that ordering, i will switch that quick and see if it gives the output i originally expected heh

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: multi-bit full adder, need help debugging! :O
« Reply #10 on: May 08, 2010, 05:22:03 am »
If someone is interested in electronics, the Electronics For Dummies is a great one for absolute beginners.

Do not start to joke about being for dummies because it is not really for dummies, it is definitely for absolute beginners.
A little more off-topic but they have good cheat sheets about a lot of stuff in their website. If you are starting some new hobby check it out.
Hobbing in calculator projects.

Offline miotatsu

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 332
  • Rating: +11/-1
    • View Profile
Re: multi-bit full adder, need help debugging! :O
« Reply #11 on: May 08, 2010, 10:51:04 am »
okay i found some small errors and tweaked a few things internally and now it works, i am going to change the input and output methods and then i will post the working source in case anyone is interested
also if you are wondering why i was working on a full adder in ti-basic, its because i am planning a little virtual-calculator-on-a-calculator
I started with a flip-flop and then a 1-bit full adder, now the 3-bit full adder, my next plan is to increase the size of this full adder to probably 1 byte, and then i will make it into a signed adder/subtractor :D

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: multi-bit full adder, need help debugging! :O
« Reply #12 on: May 08, 2010, 12:16:44 pm »
mhmm interesting I would like to see how this goes

Offline miotatsu

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 332
  • Rating: +11/-1
    • View Profile
Re: multi-bit full adder, need help debugging! :O
« Reply #13 on: May 10, 2010, 07:50:11 pm »
increased the adder size to a nibble and finished the i/o stuffs i will post the source in a sec if anyone wants to see :D next i will be changing it into an adder/subtractor

Edit: heres the source

Code: [Select]
:ClrHome
:1->O
:Lbl 1
:Delvar MDelvar L131->dim(L1
:1->P
:1->I
:28->L
:For(N,0,1
:While L>M
:Repeat A
:getkey->B
:(B=92)+(B=102->A
:(B=92->L1(P+L-7
:End
:Output(O,I,Ans
:I+1->I
:L-7->L
:End
:29->L
:M+1->M
:Output(O,I,"+
:I+1->I
:End
:Output(O,I-1,"=
:For(N,0,3
:L1(P) xor L1(P+1->L1(P+3
:Ans xor L1(P+2->L1(P+6
:L1(P+2) and L1(P+3->L1(P+4
:L1(P) and L1(P+1->L1(P+5
:Ans or L1(P+4->L1(P+9
:P+7->P
:End
:28->L
:For(I,11,14
:Output(O,I,L1(L
:L-7->L
:End
:O+1->O
:Goto 1

also to be clear, that delvar line is
:Delvar M
:Delvar L1
:31->dim(L1
not
:Delvar M
:Delvar L
:131->dim(L1
« Last Edit: May 10, 2010, 08:16:06 pm by miotatsu »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: multi-bit full adder, need help debugging! :O
« Reply #14 on: May 10, 2010, 10:50:15 pm »
So is it like a simulation of how assembly works?