1
\$\begingroup\$

I am a software developer (using high level languages like .NET,C,C++ etc) trying to understand how computers work at a lower level.

I asked this question a few days ago: Lower level system development. I have setup my arduino and I have written a few programs in C and assembly language.

However, please see the following diagram: here. This diagram suggests that the microcontroller is simply a component with a few AND gates. Surely I am missing something here? What happens if your program has an OR operation or a NOT operation? I realise this is a big topic with lots of different areas. However, I have a good GCSE level of electronics and I studied the basics of this at university whilst studying computing. I just struggle to piece it all together. What is inside a Microcontroller (physically)?

\$\endgroup\$
  • 3
    \$\begingroup\$ "a few" is the understatement of this week \$\endgroup\$ – PlasmaHH Nov 30 '14 at 15:31
  • \$\begingroup\$ "What is inside a Microcontroller (physically)?" Probably a million interconnected AND / OR / NAND / NOR gates and some other stuff like RAM/ROM/EEPROM, .... Did you compare the datasheet for an 4018 and an AVR as used on Arduino (or at least its number of pages)? \$\endgroup\$ – jippie Nov 30 '14 at 15:31
  • \$\begingroup\$ That first picture is not a micro controller. They are much more complex and contain all of the components an entire computer does. That is, they contain a complete processor, memory and memory controller, a form of permanent memory for program storage, and most of the time a combination of digital and analog I/O ports. \$\endgroup\$ – Jarrod Christman Nov 30 '14 at 15:32
  • 6
    \$\begingroup\$ If a microcontroller is the Empire State Building, then that 4081 is like a single brick. \$\endgroup\$ – Majenko Nov 30 '14 at 15:50
  • 2
    \$\begingroup\$ Why do you think that diagram suggests a microcontroller is a few AND gates? Why do you think that diagram is a microcontroller? Your fundamental problem doesn't seem to be electrical, but that you believe google image search gives you pictures of exactly what you search for. See here, which suggests that a watermelon is just red cake with green frosting. \$\endgroup\$ – Phil Frost Nov 30 '14 at 17:58
5
\$\begingroup\$

Pretty much just transistors. Lots of them. Starting with a couple of thousand for the 4004 (the first commercially successful microprocessor) in 1971, to billions in the latest chips. Transistors are used to create logic gates, which in turn are used to create the basic building blocks of the processor:

Instruction decoder
ALU (arithmetic logic unit)
Registers
Multiplexors/buffers to route signals between the above sections and the outside

Microcontrollers in addition have program and data memory, which is also constructed from transistors, along with analog circuitry and I/O ports.

High-level language languages are compiled or interpreted, in the first case eventually translated into machine instructions which are decoded by the instruction decoder. Opcodes in the instruction dictate which operation takes place. Arithmetic (add subtract and so forth) and logic operations like AND, OR etc. are handled by the ALU. So yes there are gates buried within the ALU that perform AND and OR operations, corresponding to AND and OR operations in your program.

However such operations need not actually be done by AND or OR gates Any logic function can be performed using either all NAND gates (AND followed by and inverter) or all NOR gates (OR gates followed by and inverter) so no other type of gate would be needed. The guidance computer for the Apollo 11 spacecraft which landed on the moon in 1969, consisted entirely of 2800 IC's with dual three-input NOR gates.

Here is the transistor count for a selected number of microprocessors over the years:

Intel 4004           (1971)          2,300
MOS Tech 6502        (1975)          3,510
Motorola 6800        (1974)          4,100
Intel 8080           (1974)          4,500
Intel 8086 & 8088    (1974)         29,000
Motorola 68000       (1979)         68,000
Intel 80386          (1985)        275,000
ARM 1                (1985)         25,000
Intel 80486          (1989)      1,180,235
Intel Pentium        (1993)      3,100,000
AMD K7               (1999)     22,000,000
Intel Pentium 4      (2000)     42,000,000
Intel Core 2 Duo     (2006)    291,000,000
ARM Cortex-A9        (2007)     26,000,000
AMD K10 quad-core    (2008)    758,000,000
Intel 6-core i7      (2010)  1,170,000,000
Intel 8-core Itanium (2012)  3,100,000,000 

It's astonishing that the number of transistors has increased by more than six orders of magnitude in 41 years (1971-2012). This increase has almost exactly matched Moore's Law:

$$ 2300(2^{41/2}) = 3,410,693,920 $$

which states the number of transistors in an integrated circuit doubles every two years.

Some notes about the table:

  1. The number of transistors in the 8088 (used in the first PC) and the 8086 were the same because internally, the chips were essentially identical. It was only the bus interface (8 for the 8088 vs 16 bits for the 8086) that were different.
  2. The number of transistors for the Motorola 68000 were 68,000 give or take. This was used in marketing materials.
  3. Note the striking difference between CISC (Complex instruction set computing) and RISC (Reduced instruction set computing) architectures: the Intel 80386, released in 1985 had 275,000 transistors, while the ARM 1, released the same year, had 25,000, a ratio of 11 to 1. And the Intel Core 2 Duo, released in 2006, had 291,000,000 transistors, whereas the ARM Cortex-A9, introduced a year later, had 22,000,000, a similar ratio of 13 to 1.

The earliest microprocessors, such as the 6502 used in the very popular Apple ][, had low enough transistor counts that with only little magnification you can see the individual transistors. Here is a 6502 simulator that actually shows the data paths through the chip as it executes a program. Just click on the Play button on the right side. You can zoom in and get more detail. The simulator was created by exposing the die, photographing the surface and substrates at high resolution, and then creating a complete digital model of the chip.

The very first computers in the 1940's were made up of either vacuum tubes or relays, but in either case they performed the same Boolean algebra as the digital circuits today. Discrete transistor computers came along ion the late 1950's/early 1960's. They were superseded by processors using SSI (small scale integrated circuits). This was largely driven by the aerospace industry, both the space race and defense. to minimize weight. The microprocessors in the list earlier are an example of LSI (large scale integration).

\$\endgroup\$
1
\$\begingroup\$

The simplest and most primitive 4-bit microprocessors had only about 3,000 transistors, so perhaps 1000 gates in the PMOS technology. Memory could be made with gates, but it isn't as that would be horribly inefficient, and that's on top of the microprocessor requirement, since micro controllers have memory on-board.

A modern microcontroller, even an inexpensive one such as a small 32-bit ARM would be orders of magnitude more complex. Here is a die photo from Wikipedia of such a processor, which happens to be a ARM Cortex M3 from ST:

http://upload.wikimedia.org/wikipedia/commons/thumb/8/89/STM32F103VGT6-HD.jpg/440px-STM32F103VGT6-HD.jpg

A chip this complex would require high-end automated tools and a team of developers to create, and would be somewhat similar to a large-ish software project in terms of design processes. In fact, they're so complex that manufacturers often buy (license) the designs from a firm like ARM and adapt the core to their requirements. Printing out a transistor-level or even gate-level schematic for such a chip would be as impractical as printing out the source code to Microsoft Windows.

In contrast, here is what the die layout of a quad gate chip looks like (from a TI datasheet):

enter image description here

The art for these simple gate chips could be made by people working with X-Acto(tm) knives and Rubylith.

\$\endgroup\$
1
\$\begingroup\$

Your initial google image search terms microcontroller logic gates diagram gives misleading results. Omit the word "microcontroller" and you get roughly the same results: generic logic gates and nothing about microcontrollers. What you're really asking about is not what are logic gates, but rather what is the logic found inside a microcontroller.

The reason you won't find a scheamtic diagram of the internal logic of a modern, proprietary microcontroller (like Atmel AVR or Microchip PIC), is because that is actually trade secret information. (Also, even the simplest of these will be quite complex.) However, there are plenty of older, industry-standard microcontrollers that are no longer considered secret.

The good news is, both microcontrollers and FPGA have been around long enough, that there are now plenty of free, open-source examples that retrocomputing enthusiasts have lovingly reverse-engineered from classic microcontroller designs. http://opencores.org/projects under the Processor tab, has several free, open-source microcontroller cores, based on widely-used older designs that are no longer defended as proprietary. These are written in a Hardware Description Language such as Verilog or VHDL.

I recommend starting with some of the older (and therefore simpler architecture) classic microcontrollers, such as:

  • 4004
  • 6502
  • 8080
  • 8051
  • Z80

One of the reasons the enthusiasts like to reuse these older microcontroller architectures (especially 8051 or Z80), is because there are freely available toolchains such as SDCC. This makes it actually useful for solving real problems, without the expense of a 32-bit system.

If you really prefer to view these as schematics rather than HDL code, it's possible, but will require installing some FPGA development software tools. Both Xilinx.com and Altera.com offer a suite of free development tools (Xilinx's software is called ISE and Altera's software is called Quartus). The larger FPGA targets require a paid license, but there is a range of smaller FPGA targets that can be built using a free "webpack" license (i.e. registration only but no money). Using these tools does require investing some of your time to learn, but can be a worthwhile project if you want to drill down into the lower levels of digital hardware design.

Anyway, assuming you have Xilinx ISE set up and have loaded one of these opencores microcontroller projects, you would select RTL Schematic to view a hierarchical schematic... although in truth, when you get to the level of a small or medium-sized microcontroller, schematics really become inefficient.

One last thing worth studying: Xilinx has a free, 8-bit soft microcontroller called picoblaze, which can be synthesized on Xilinx FPGAs. This design was handcrafted by Xilinx's Ken Chapman using FPGA gate-level primitives, so it's at least comprehensible at the low level yet still useful for real tasks. It does suffer from not having a C compiler or other cushy toolchain support, but it does work well for small jobs needing more than a state machine, but less than a full industrial-strength C compiler.

\$\endgroup\$
0
\$\begingroup\$

The short answer is: "Yes", but in order to get just a tiny inkling of the complexity of a microcontroller, it might be instructive for you to work out, in hardware, how to load a 16 bit binary number into any one of, say, 65536 memory locations, another 16 bit number somewhere else in the memory array, then to multiply them and store the product at the two addresses the multiplicand and multiplier formerly occupied.

\$\endgroup\$
0
\$\begingroup\$

The image you linked in your question is not one of a microcontroller but of an integrated circuit consisting of four logic ANDs. A microncontroller has millions of them.

Also, note that using only NAND gates you can perform any logic operation you may need.

\$\endgroup\$
  • \$\begingroup\$ Using only NORs will also work. \$\endgroup\$ – EM Fields Nov 30 '14 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.