Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Boolean gates. Part 2

Boolean gates. Part 2

Scheduled Pinned Locked Moved C / C++ / MFC
question
11 Posts 7 Posters 21 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Calin Negru

    Roughly speaking adding two 32 bit numbers requires 32 Boolean gates. Why do you need millions of transistors? I know there is also substraction, division, multiplying, comparison etc. Some operations probably require way more Boolean gates than the number of bits the numbers involved in the operation are made of. Also my guess is there is a comparison based mathematical operation type selector that directs the bits to the correct area on the processor pill. Still it’s difficult to imagine where millions of transistors go. If I think about it more I get it, this is just Alu. There is also non mathematical stuff that needs to be taken care of as well.

    Mircea NeacsuM Offline
    Mircea NeacsuM Offline
    Mircea Neacsu
    wrote on last edited by
    #2

    Calin Negru wrote:

    If I think about it more I get it, this is just Alu. There is also non mathematical stuff that needs to be taken care of as well.

    Not to mention the floating point stuff, memory cache, multiple cores, and so on, and so on... The distance between a modern day CPU and a schoolbook design is larger than the distance between a Ford T and a Formula 1 car.

    Mircea

    J 1 Reply Last reply
    0
    • Mircea NeacsuM Mircea Neacsu

      Calin Negru wrote:

      If I think about it more I get it, this is just Alu. There is also non mathematical stuff that needs to be taken care of as well.

      Not to mention the floating point stuff, memory cache, multiple cores, and so on, and so on... The distance between a modern day CPU and a schoolbook design is larger than the distance between a Ford T and a Formula 1 car.

      Mircea

      J Offline
      J Offline
      jeron1
      wrote on last edited by
      #3

      Indeed, and all the peripheral systems, ADC, Timers, UARTs, I2C, SPI, DMA, PWM, DAC, to name but a few.

      "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

      1 Reply Last reply
      0
      • C Calin Negru

        Roughly speaking adding two 32 bit numbers requires 32 Boolean gates. Why do you need millions of transistors? I know there is also substraction, division, multiplying, comparison etc. Some operations probably require way more Boolean gates than the number of bits the numbers involved in the operation are made of. Also my guess is there is a comparison based mathematical operation type selector that directs the bits to the correct area on the processor pill. Still it’s difficult to imagine where millions of transistors go. If I think about it more I get it, this is just Alu. There is also non mathematical stuff that needs to be taken care of as well.

        T Offline
        T Offline
        trønderen
        wrote on last edited by
        #4

        A large part of the silicon real estate is occupied by large/huge caches, in some chips 3 levels deep.

        1 Reply Last reply
        0
        • C Calin Negru

          Roughly speaking adding two 32 bit numbers requires 32 Boolean gates. Why do you need millions of transistors? I know there is also substraction, division, multiplying, comparison etc. Some operations probably require way more Boolean gates than the number of bits the numbers involved in the operation are made of. Also my guess is there is a comparison based mathematical operation type selector that directs the bits to the correct area on the processor pill. Still it’s difficult to imagine where millions of transistors go. If I think about it more I get it, this is just Alu. There is also non mathematical stuff that needs to be taken care of as well.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #5

          Well, a little more than 32 (unless you count a full adder as one gate? but I wouldn't). Especially if you use any type of [fast adder](https://en.wikipedia.org/wiki/Carry-lookahead\_adder) which is often mandatory to hit frequency targets. Subtraction doesn't cost much extra, you can reuse your adder by turning it into an adder-subtractor. Comparisons don't cost extra, comparison is subtraction. [Multipliers](https://en.wikipedia.org/wiki/Dadda\_multiplier) are bigger. So it costs a few more gates than you estimated, but also there are far more transistors: billions, these days. (Scalar) ALUs are not a big part of a modern high-performance CPU, even after accounting for there being a handful of them (I mean multiple per core, of course there are usually multiple cores too). Here's a fun article showing how big various parts of a CPU actually are, keep in mind it's showing a super obsolete Pentium 4: [Intel’s Netburst: Failure is a Foundation for Success – Chips and Cheese](https://chipsandcheese.com/2022/06/17/intels-netburst-failure-is-a-foundation-for-success/)

          C 1 Reply Last reply
          0
          • C Calin Negru

            Roughly speaking adding two 32 bit numbers requires 32 Boolean gates. Why do you need millions of transistors? I know there is also substraction, division, multiplying, comparison etc. Some operations probably require way more Boolean gates than the number of bits the numbers involved in the operation are made of. Also my guess is there is a comparison based mathematical operation type selector that directs the bits to the correct area on the processor pill. Still it’s difficult to imagine where millions of transistors go. If I think about it more I get it, this is just Alu. There is also non mathematical stuff that needs to be taken care of as well.

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #6

            PIEBALD pulls his copy of Code by Charles Petzold off the shelf behind him. Chapter Twelve describes implementing A Binary Adding Machine from simple logic gates. His descriptions of logic gates use relays rather than transistors. I haven't counted, but it looks like a simple 32-bit adder built according to his diagrams might require a bit more than a hundred relays? I can't comprehend a full modern ALU though.

            1 Reply Last reply
            0
            • L Lost User

              Well, a little more than 32 (unless you count a full adder as one gate? but I wouldn't). Especially if you use any type of [fast adder](https://en.wikipedia.org/wiki/Carry-lookahead\_adder) which is often mandatory to hit frequency targets. Subtraction doesn't cost much extra, you can reuse your adder by turning it into an adder-subtractor. Comparisons don't cost extra, comparison is subtraction. [Multipliers](https://en.wikipedia.org/wiki/Dadda\_multiplier) are bigger. So it costs a few more gates than you estimated, but also there are far more transistors: billions, these days. (Scalar) ALUs are not a big part of a modern high-performance CPU, even after accounting for there being a handful of them (I mean multiple per core, of course there are usually multiple cores too). Here's a fun article showing how big various parts of a CPU actually are, keep in mind it's showing a super obsolete Pentium 4: [Intel’s Netburst: Failure is a Foundation for Success – Chips and Cheese](https://chipsandcheese.com/2022/06/17/intels-netburst-failure-is-a-foundation-for-success/)

              C Offline
              C Offline
              Calin Negru
              wrote on last edited by
              #7

              Thank you guys for sharing > harold “fast adder” That must be a recent improvement ( I have no clue, just a wild guess ) I’m just starting to understand what is probably the classical model. > tronderen “real estate” I like to think in somewhat similar terms

              L 1 Reply Last reply
              0
              • C Calin Negru

                Thank you guys for sharing > harold “fast adder” That must be a recent improvement ( I have no clue, just a wild guess ) I’m just starting to understand what is probably the classical model. > tronderen “real estate” I like to think in somewhat similar terms

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #8

                Not that recent. The 8008 used carry lookahead for example. And several 74181 (a 4-bit ALU chip which you can use multiple of in a group to build a wider ALU) could be combined with the 74182 (lookahead carry generator) to build an ALU with carry lookahead. These things are ancient (70's era tech). That does not mean that carry lookahead addition was always used everywhere, some chips were really trying to save on transistors and didn't use it. But anything modern, probably has some sort of fast adder. Ripple carry adders do not scale well (imagine a 64-bit ripple carry adder, yikes) and transistors are significantly cheaper than a dime a dozen.

                C 1 Reply Last reply
                0
                • C Calin Negru

                  Roughly speaking adding two 32 bit numbers requires 32 Boolean gates. Why do you need millions of transistors? I know there is also substraction, division, multiplying, comparison etc. Some operations probably require way more Boolean gates than the number of bits the numbers involved in the operation are made of. Also my guess is there is a comparison based mathematical operation type selector that directs the bits to the correct area on the processor pill. Still it’s difficult to imagine where millions of transistors go. If I think about it more I get it, this is just Alu. There is also non mathematical stuff that needs to be taken care of as well.

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #9

                  My (14 years old) son designed and implemented a 4-bit adder. For all but the LSB he used three XOR and two AND gates.

                  "In testa che avete, Signor di Ceprano?" -- Rigoletto

                  In testa che avete, signor di Ceprano?

                  C 1 Reply Last reply
                  0
                  • L Lost User

                    Not that recent. The 8008 used carry lookahead for example. And several 74181 (a 4-bit ALU chip which you can use multiple of in a group to build a wider ALU) could be combined with the 74182 (lookahead carry generator) to build an ALU with carry lookahead. These things are ancient (70's era tech). That does not mean that carry lookahead addition was always used everywhere, some chips were really trying to save on transistors and didn't use it. But anything modern, probably has some sort of fast adder. Ripple carry adders do not scale well (imagine a 64-bit ripple carry adder, yikes) and transistors are significantly cheaper than a dime a dozen.

                    C Offline
                    C Offline
                    Calin Negru
                    wrote on last edited by
                    #10

                    If you take a look at multicore procesors that’s probably a lot more things going on and not suited as an entry level lesson. If you want to learn anything you need to strip down all the fancy things.

                    1 Reply Last reply
                    0
                    • CPalliniC CPallini

                      My (14 years old) son designed and implemented a 4-bit adder. For all but the LSB he used three XOR and two AND gates.

                      "In testa che avete, Signor di Ceprano?" -- Rigoletto

                      C Offline
                      C Offline
                      Calin Negru
                      wrote on last edited by
                      #11

                      Interesting

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups