The Naked Scientists
  • Login
  • Register
  • Podcasts
      • The Naked Scientists
      • eLife
      • Naked Genetics
      • Naked Astronomy
      • In short
      • Naked Neuroscience
      • Ask! The Naked Scientists
      • Question of the Week
      • Archive
      • Video
      • SUBSCRIBE to our Podcasts
  • Articles
      • Science News
      • Features
      • Interviews
      • Answers to Science Questions
  • Get Naked
      • Donate
      • Do an Experiment
      • Science Forum
      • Ask a Question
  • About
      • Meet the team
      • Our Sponsors
      • Site Map
      • Contact us

User menu

  • Login
  • Register
  • Home
  • Help
  • Search
  • Tags
  • Recent Topics
  • Login
  • Register
  1. Naked Science Forum
  2. General Discussion & Feedback
  3. Just Chat!
  4. What is inside a computer's processor chip?
« previous next »
  • Print
Pages: [1] 2   Go Down

What is inside a computer's processor chip?

  • 32 Replies
  • 7136 Views
  • 0 Tags

0 Members and 1 Guest are viewing this topic.

Offline NTYNUT (OP)

  • Sr. Member
  • ****
  • 240
  • Activity:
    0%
  • Naked Science Forum Newbie
What is inside a computer's processor chip?
« on: 23/08/2018 16:55:05 »
hello
what is inside processor how does mosfet inside it do calculation
« Last Edit: 24/08/2018 09:46:41 by chris »
Logged
 



Offline alancalverd

  • Global Moderator
  • Naked Science Forum GOD!
  • ********
  • 21160
  • Activity:
    64%
  • Thanked: 60 times
  • Life is too short for instant coffee
Re: What is inside a computer's processor chip?
« Reply #1 on: 23/08/2018 17:34:51 »
By lots of binary arithmetic, Boolean logic and bistable memory.

The cunning bit is that a mosfet can be switched on or off by applying an appropriate voltage to one or more gate electrodes, and crosscoupling two mosfets can make a circuit that remains in a set binary state until reset. Now repeat the process with between a million and a billion mosfets, and you have a device capable of manipulating an input bitstream  in response to a program.
Logged
Helping stem the tide of ignorance
 

Offline NTYNUT (OP)

  • Sr. Member
  • ****
  • 240
  • Activity:
    0%
  • Naked Science Forum Newbie
Re: What is inside a computer's processor chip?
« Reply #2 on: 23/08/2018 17:38:05 »
hello
how the bjt mosfet make arthmetic like factorial cos tignometry in it
Logged
 

guest45734

  • Guest
Re: What is inside a computer's processor chip?
« Reply #3 on: 23/08/2018 17:43:07 »
Quote from: NTYNUT on 23/08/2018 16:55:05
what is inside processor how does mosfet inside it do calculation

Like Alan writes above its binary logic your mosfet has two swtiched states True and False, or 1's and 0's, connect 16 of them together in parallel and you can represent numbers up to 2^16 = 65536
https://www.tutorialspoint.com/computer_logical_organization/binary_arithmetic.htm
Logged
 

Offline alancalverd

  • Global Moderator
  • Naked Science Forum GOD!
  • ********
  • 21160
  • Activity:
    64%
  • Thanked: 60 times
  • Life is too short for instant coffee
Re: What is inside a computer's processor chip?
« Reply #4 on: 23/08/2018 17:45:51 »
Break down the equation to a series of binary commands, and away you go.

I have spent many happy years designing very basic hardware to perform one or two operations very quickly, and using high-level programs to handle lots of data, but the bit in between is an enormous industry full of very clever chaps (and some fabulous machinery that pushes photography and chemistry to the quantum limit) whose work we take for granted!
Logged
Helping stem the tide of ignorance
 



Offline NTYNUT (OP)

  • Sr. Member
  • ****
  • 240
  • Activity:
    0%
  • Naked Science Forum Newbie
Re: What is inside a computer's processor chip?
« Reply #5 on: 23/08/2018 17:51:30 »
hello
how to make equation
Logged
 

Offline Bored chemist

  • Naked Science Forum GOD!
  • *******
  • 31101
  • Activity:
    10.5%
  • Thanked: 1291 times
Re: What is inside a computer's processor chip?
« Reply #6 on: 23/08/2018 19:49:35 »
Well, the processor can add two numbers together

https://en.wikipedia.org/wiki/Adder_(electronics)

And you can use that  addition repeatedly to do multiplication

https://www.atarimagazines.com/compute/issue56/157_1_MACHINE_LANGUAGE.php

and there are whole books written about where you go from there. It is far too big a subject to cover on a web site like this.

Logged
Please disregard all previous signatures.
 

guest45734

  • Guest
Re: What is inside a computer's processor chip?
« Reply #7 on: 23/08/2018 20:43:41 »
Here is a link showing you some basic circuits to create logic gates. These logic gates are the circuits you connect together to perform the maths. Thousands of these are connected together on silicon chips to perform all kindsof operations https://www.cs.bu.edu/~best/courses/modules/Transistors2Gates/
Logged
 

Offline NTYNUT (OP)

  • Sr. Member
  • ****
  • 240
  • Activity:
    0%
  • Naked Science Forum Newbie
Re: What is inside a computer's processor chip?
« Reply #8 on: 24/08/2018 07:38:33 »
Hello
I have done addition subtraction multiplication and division in it
but i dont understand how to do decimal multiplication and division
Logged
 



guest45734

  • Guest
Re: What is inside a computer's processor chip?
« Reply #9 on: 24/08/2018 09:56:12 »
Quote from: NTYNUT on 24/08/2018 07:38:33
Hello
I have done addition subtraction multiplication and division in it
but i dont understand how to do decimal multiplication and division
try shifting the decimal place :) or googling exponent and mantissa and hexadecimal floating point numbers, you will find lot of hit at varying level off undertanding.
Logged
 

Offline NTYNUT (OP)

  • Sr. Member
  • ****
  • 240
  • Activity:
    0%
  • Naked Science Forum Newbie
Re: What is inside a computer's processor chip?
« Reply #10 on: 24/08/2018 10:10:21 »
Hello
How to do factorial in processor how mosfet are arrange that factorial can do
Logged
 

Offline evan_au

  • Global Moderator
  • Naked Science Forum GOD!
  • ********
  • 11035
  • Activity:
    9%
  • Thanked: 1486 times
Re: What is inside a computer's processor chip?
« Reply #11 on: 24/08/2018 12:31:35 »
Quote from: NTYNUT
but i dont understand how to do decimal multiplication and division
Some schools still teach this to kids before they reach the age of 12.

In the 1950s & 1960s there were computers that could do decimal arithmetic in hardware.
But most computers these days convert the decimal numbers to binary, do the arithmetic in binary, and convert it back to decimal for display.

The first microprocessors were 4-bit computers that were used in calculators and cash registers. Cheap 4-function calculators probably still do their calculations in decimal, using pretty much the same method taught in primary school. More powerful "scientific" calculators probably use birnary internally.

Quote
how does the bjt mosfet make trigonometry in it?
Most complex problems in this world are broken up by "levels of abstraction". Solving an entire problem takes the combined skills of many people.

For this example:
1. Some people are experts at designing a faster MOSFET, or a smaller memory cell
2. Some people are experts at using these transistors to produce a cache memory, or a multiplier circuit
3. Some people are experts at using these circuit blocks to produce a complete computer chip - but they can ignore the design of the MOSFETS.
4. Some people are experts at writing compilers for a new computer chip - it is useful to know the size of the cache memory, and the speed of the multiplier circuit, but they don't need to know how it is arranged on the chip
5. Some people are experts at writing mathematical library modules (like sine, cos and factorial). Today, with standardised floating point, they can almost ignore which processor it is running on. In the old days (eg with decimal computers), the mathematical library needed a major rewrite for every different processor model.
6. Some people are experts at writing software in high-level languages, which may include triigonometry - but they can ignore the architecture of the processor chip and the algorithm used in the mathematics library

A person who is an expert at one level of abstraction will probably have a fair idea of what happens at an "adjacent" level (with people that they often interact with), but possibly little idea of what is happening at more remote levels of abstraction.

In asking this question, you are spanning about 5 levels of abstraction, which is beyond what any individual human can expect to become an expert in a lifetime.
But the idea of a university course is to expose you to many levels of abstraction, at a shallow depth, so you know how the different levels of abstraction fit together.

Quote
how does the (computer chip) make arithmetic like factorial?
This is quite easy, since it is possible to calculate the exact answer in a finite number of steps - provided you have enough bits in your computer. To calculate n! just takes n multiplications (plus usually a counter from n down to 0):
n! = 1 x 2 x 3 x 4 x..... x (n-1) x n

Quote
how does the (computer chip) make arithmetic like cos in trigonometry?
This is more complicated, because you can never calculate the exact answer on a finite computer, even with infinite time.

If you could calculate the diameter of the observable universe to around 40 decimal places, that will give you the answer to within the width of a proton, which is accurate enough for any practical purpose!

So in practice, computers do trigonometry calculations with 32 or 64 bit floating-point numbers (and sometimes keep intermediate calculations with 80 bit accuracy).

You can never calculate the exact answer, but you can get "close enough" in a finite number of steps by using a Taylor-series expansion of the function you are interested in. Sine, and Cosine functions converge quite quickly, especially if you take advantage of the fact that they repeat. Replace Sine(large number) by Sine(smaller number between ±π/4).

Some other functions like ArcTan are much more difficult - computer scientists often use ArcTan in a competition to calculate π to an enormous number of digits.

See: https://en.wikipedia.org/wiki/Taylor_series
Logged
 

Offline NTYNUT (OP)

  • Sr. Member
  • ****
  • 240
  • Activity:
    0%
  • Naked Science Forum Newbie
Re: What is inside a computer's processor chip?
« Reply #12 on: 24/08/2018 12:39:41 »
Hello
Quote
Some people are experts at writing mathematical library modules (like sine, cos and factorial). Today, with standardised floating point, they can almost ignore which processor it is running on. In the old days (eg with decimal computers), the mathematical library needed a major rewrite for every different processor model.
How does computer calculate sine cos and factorial in it
Logged
 



Offline Bored chemist

  • Naked Science Forum GOD!
  • *******
  • 31101
  • Activity:
    10.5%
  • Thanked: 1291 times
Re: What is inside a computer's processor chip?
« Reply #13 on: 24/08/2018 19:09:45 »
Like this
https://en.wikipedia.org/wiki/Taylor_series#Trigonometric_functions

Is there some reason you can't search google for this sort of thing?
Logged
Please disregard all previous signatures.
 

Offline evan_au

  • Global Moderator
  • Naked Science Forum GOD!
  • ********
  • 11035
  • Activity:
    9%
  • Thanked: 1486 times
Re: What is inside a computer's processor chip?
« Reply #14 on: 25/08/2018 01:45:26 »
Quote from: NTYNUT
How does computer calculate sine cos and factorial in it
These days, computer memory is fast and cheap, so the easiest way is to use a lookup table of values of sine and cosine.
- When I went to school, computation was expensive, and paper was cheap, so they used paper books with lookup tables
- deja vu!

For you, choose the most appropriate level of abstraction, which is probably a spreadsheet
- You don't need to know about the MOSFETs, the computer chip or the algorithm
- For one popular spreadsheet, you just type into a cell: "=sin(x)" or "=cos(x)", where "x" is defined as another cell with a numeric value
- You can do the same in a high-level programming language

If you want to get more adventurous, you could type into a spreadsheet  something like:
=x-x^3/fact(3)+x^5/fact(5)-x^7/fact(7)+.....    but it soon gets pretty boring, because it never ends!
- This is the Taylor series for sin(x) - or more specifically, the Maclaurin series for sin(x)
- For small values of x, this will give you something close to sin(x)
- For large values of x, it will look nothing like sin(x)
- And it's not really very accurate, because hidden in the "^" operator is a logarithm and exponential operator, both of which are executed with a Taylor series!
- So you are using a Taylor series to calculate another Taylor series - not very efficient!

So, in reality, computers calculate the Taylor series without using the exponentiation operator, and without using the factorial operator. They just use multiplication, division and addition.

I can illustrate this in a rough way as follows (without having tried to execute it!)

y=x   #The first term in the series
term=x #term calculates each successive number in the series
n=3   #The exponent of the next term to be calculated
x2=x*x  #Calculate x squared only once, instead of many times
repeat
   term=-term*x2/(n*(n-1))   #Calculate the next term, with no exponentiation or factorials!
   n=n+2         #This is the exponent of the next term
   y=y+term     #Add up all the terms
until abs(term) < 1e-10   #Stop when the extra terms get too small

So you really don't need a factorial function to calculate sin(x) - you just generate it incrementally, one term at a time.
- The "abs" function is "absolute value"; it is a quicker way of saying  (-1e-10 < term) and (term < 1e-10)

This simple approach is only accurate to about 9 decimal places, and could take a lot of iterations to stop for large positive or negative values of x.
- Back when microprocessors were fairly new, I used an algorithm like this to calculate Taylor series to 100 decimal places on an 8-bit microprocessor (plus, it had no multiplication or division operation - that is another level of abstraction you should ignore for now!).

Professional math libraries:
- convert large values of x into smaller values of x with the same answer
- don't use the exact Taylor series coefficients, but tweak them so that it gives the same number of decimal places with fewer terms
- don't calculate the coefficients for each term, but use a lookup table in the code
- eliminate the loop, and just execute the same set of instructions every time
- do use the floating-point hardware that exists on most larger computer chips today
- are delivered with every high-level language compiler, so you don't have to do it yourself!
Logged
 

Offline NTYNUT (OP)

  • Sr. Member
  • ****
  • 240
  • Activity:
    0%
  • Naked Science Forum Newbie
Re: What is inside a computer's processor chip?
« Reply #15 on: 25/08/2018 03:50:01 »
hello
if look up table is used then how it find all close value
Logged
 

Offline evan_au

  • Global Moderator
  • Naked Science Forum GOD!
  • ********
  • 11035
  • Activity:
    9%
  • Thanked: 1486 times
Re: What is inside a computer's processor chip?
« Reply #16 on: 25/08/2018 08:14:54 »
By the way, while walking the dog, I realised that it is possible to calculate the Taylor series for both sin(x) and cos(x) with pretty much the same number of multiplications as the above Taylor series does for sin(x) alone.

sinx=x   #The first terms in the series
cosx=1
term=x #term calculates each successive number in the series
n=2   #The exponent of the next term to be calculated
repeat
   term=-term*x/(n)   #Calculate the next term, needed for cos(x)
   cosx=cosx+term
   term=term*x/(n+1)   #Calculate the next term, needed for sin(x)
   sinx=sinx+term
   n=n+2         #This is the exponent of the next term
until abs(term) < 1e-10   #Stop when the extra terms get too small

Quote
How does computer calculate sine, cos?
One thing I should mention is that in High School, they teach trigonometry in terms of angles in degrees, where a full circle = 360.
However, in university, you discover that the "natural units" of sin(x) and cos(x) are in radians, where a full circle = 2π radians.
The Taylor series assumes that x is in radians.
You have to adapt the Taylor series if x is in degrees. Often by converting to radians, as in x=2*pi/360.

Scientific calculators often have a button to switch between radians and degrees.

Quote
if look up table is used then how it find all close value
The first questions to ask yourself are:
1. What range of values x does the input take? If it is some sensor, then it will have a limited range of values, like 0-90°, or -180° to +179°; or maybe device-specific units like 0-255? Or can it have a wide range of values like -3600° to +3600°?
2. What is the resolution of x? Is it accurate to 0.1° or 0.01°? This determines the number of separate input values you expect.
3. What accuracy do I require for the sin(x) and cos(x) output? If it is to control a stepper motor, 0.1% accuracy is usually fine.
4. Do I have this much memory free? If it requires accuracy < 1 part in 1 million, and I have restricted memory (eg a microcontroller) then a lookup table will not be the most compact form!

The simplest case is if the input is a number from 0-359°, and an output error of < 0.1% is fine.
In this case, you could define a table with 360 floating-point entries, and each entry is precomputed as round(sin(x*2*pi/360)). You then just look up a specific table entry based on the input.
A similar table delivers cos(x). Very compact, very fast, very simple.
In this case, the error in input angle x exceeds the error in the sin(x) and cos(x) table.

A more complex case is if the input is in the range 0-359°, but with a resolution of 0.01°, for 36000 possible input values. You have enough memory for a table with 3600 floating-point entries, but not 36000 entries.
In this case, you can multiply x by 10.
Take the integer part, yielding a number between 0-3600 to look up the table. Call this a.
Also look up the next entry in the table. Call this b. (entry 0 has to be replicated as entry 3601)
You can now interpolate between these entries by looking at the fractional part of x (with a range of 0-0.9, call this c)

An improved result for sin(x) = a*(1-c) + b*c

If you have a microcontroller with no floating point unit, things get more complex, since simple integer arithmetic can represent -1, 0 and +1, but nothing in-between. Unfortunately, sine and cosine have numerical values that fall between these integer values.
In such cases, you would usually use scaled integers to represent numbers between -1, 0  and +1. For example, with an input of 0-259°, you can have a table of 360 16-bit numbers, precomputed as round(sin(x*2*pi/360)*10000).
Now the integer 10000 represents +1, and -10000 represents -1, and you can use this in calculations.
Remember that:
- The answers are scaled by a factor of 10,000
- intermediate values in calculations can often overflow the maximum range of a 16-bit integer (space rockets have been lost due to this error!).

Floating point takes care of a lot of these issues... And using a floating-point library takes care of even more issues!
Logged
 



Offline NTYNUT (OP)

  • Sr. Member
  • ****
  • 240
  • Activity:
    0%
  • Naked Science Forum Newbie
Re: What is inside a computer's processor chip?
« Reply #17 on: 25/08/2018 08:21:37 »
hello
how does taylor series calculate in it there is long procedure how procedure do
Logged
 

Offline evan_au

  • Global Moderator
  • Naked Science Forum GOD!
  • ********
  • 11035
  • Activity:
    9%
  • Thanked: 1486 times
Re: What is inside a computer's processor chip?
« Reply #18 on: 25/08/2018 09:39:03 »
Quote from: NTYNUT
How does the taylor series calculate? There is a long procedure
The short snippet of code I provided implements a Taylor series for both sin(x) and cos(x) in 11 lines of code.

Realistic programs created by professionals consist of thousands or millions of lines of code.

This is where the clear advice is to do a course in computer programming.
You could start here: https://hourofcode.com
Logged
 

Offline NTYNUT (OP)

  • Sr. Member
  • ****
  • 240
  • Activity:
    0%
  • Naked Science Forum Newbie
Re: What is inside a computer's processor chip?
« Reply #19 on: 25/08/2018 09:41:21 »
hello
how to do it
Logged
 



  • Print
Pages: [1] 2   Go Up
« previous next »
Tags:
 
There was an error while thanking
Thanking...
  • SMF 2.0.15 | SMF © 2017, Simple Machines
    Privacy Policy
    SMFAds for Free Forums
  • Naked Science Forum ©

Page created in 1.937 seconds with 70 queries.

  • Podcasts
  • Articles
  • Get Naked
  • About
  • Contact us
  • Advertise
  • Privacy Policy
  • Subscribe to newsletter
  • We love feedback

Follow us

cambridge_logo_footer.png

©The Naked Scientists® 2000–2017 | The Naked Scientists® and Naked Science® are registered trademarks created by Dr Chris Smith. Information presented on this website is the opinion of the individual contributors and does not reflect the general views of the administrators, editors, moderators, sponsors, Cambridge University or the public at large.