Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How microprocessor works?

Status
Not open for further replies.

I14R10

Full Member level 3
Joined
May 31, 2015
Messages
185
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
2,750
Can you recommend some literature about microprocessors? I know how to program them, but I don't know about their internal works. How can they be programmed, hot the microprocessor understands that code...
 

youtube.com has hundreds of videos on this subject.
Some of them are very good.
 
  • Like
Reactions: I14R10

    I14R10

    Points: 2
    Helpful Answer Positive Rating
What about some real books (or e-books). I find videos hard to watch since they talk about some things that I wouldn't care, but I have to watch it since there is no transcript.
 

the babani book onmicrocontrollers is good.

You got
data bus
address bus
control bus

CPU
oscillator
ROM
RAM

wORKING REGISTER.

instructions are executed to the beat of the clock.
 
  • Like
Reactions: I14R10

    I14R10

    Points: 2
    Helpful Answer Positive Rating
"Microprocessor Desing & Interfacing" by Muhammad Ali Mazidi is one of the best books i would recommend.
 
  • Like
Reactions: I14R10

    I14R10

    Points: 2
    Helpful Answer Positive Rating
  • Like
Reactions: I14R10

    I14R10

    Points: 2
    Helpful Answer Positive Rating
Thanks guys, now I have tons of stuff to read.
 

After reading about this for some time I have few questions that I don't understand. Let's start with this one.

We have numbers A and B in our memory. Each is 8 bits wide. Let's say A=4 and B=5 . We program the microcontroller with this:

Code:
int A, B;
A=4;
B=5;

if(A<B){
do something
}

Now, how does it check if the number A is smaller or bigger than number B?
 
Last edited by a moderator:

Now, how does it check if the number A is smaller or bigger than number B?

With VHDL/Verilog code that does something similar to this:

Code Verilog - [expand]
1
2
3
always @* begin
  if (a < b) do_something
end


which is synthesized into a large (depending on the size of the operands) cone of logic gates.
 

OK, it checks by using some combination of logic gates. What does that circuit looks like, that was my question? I assume that there are control bits that choose what operation is made - adding, substracting, logical OR, logical AND, logical IF...?
 

It depends on which particular microcontroller you are using. They have different sets of instructions available. In general it would go something like

10 - Mov A to the working register
20 - Subtract B from the working register
30 - jump the next line if the negative flag bit is set (implying that A<B)
40 - Go to 'do_something' aka 1010
50 - carrying on without going to 'do something'
...
...
1000 - go to 10
'do_something' 1010 - this is where we do something

The program counter ticks through the program line by line. Some instructions might change the next location that the PC ticks to, like skipping 1 line if the N flag bit is set or branching to another line that you've named with a label, like 'do_something'. Obviously the actual commands are much more abbreviated than the descriptions I put down. The process used and the the number of clock cycles it takes to execute, depend on the uC you are using.

Again I recommend section 2 of https://cache.freescale.com/files/microcontrollers/doc/ref_manual/M68HC05AG.pdf It's a concise explanation of exactly what you are asking.
 

OK, it checks by using some combination of logic gates. What does that circuit looks like, that was my question? I assume that there are control bits that choose what operation is made - adding, substracting, logical OR, logical AND, logical IF...?

If you are interested in the implementation of logic from higher level descriptions, you should take a logic design class or pick up a book on logic design.

For the following code you get the following circuit (for Microsemi, Xilinx/Altera just show LUTs).
Code:
module cmp (
  output      c,
  input [7:0] a,
  input [7:0] b
);
assign c = a < b;
endmodule

gate level schematic of the circuit:
Capture.JPG
 

It depends on which particular microcontroller you are using. They have different sets of instructions available. In general it would go something like

10 - Mov A to the working register
20 - Subtract B from the working register
30 - jump the next line if the negative flag bit is set (implying that A<B)

...

Again I recommend section 2 of https://cache.freescale.com/files/microcontrollers/doc/ref_manual/M68HC05AG.pdf It's a concise explanation of exactly what you are asking.

Now I feel stupid :), subtraction is really simple way to see what number is greater.

I did read some parts of that document, but some parts are confusing.
 

Most microprocessors/controllers have an instruction like 'compare' CPxxx in the instruction set. Depending on how advanced the micro, is you can compsre Registers, memory locations and constants. This instruction is in reallity a virtual subtraction, not changing the contents of any Registers or memory positions.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top