Author Options:

simple program counter ? Answered

Hello  ,
I need help,I am posting schematic. I don't understand ,that   how program counter know some instructions  (jump , branch , subroutine call ) I have attached two diagram.look the 1st diagram.I am using 4 counter. how to improve that circuit for program counter .




3 years ago

You want to count how many operations the MCU performs for an istruction ?

there are different type of instructions

I want to count following instruction s

load , store , mov instruction

arithmetic - add, sub , mul, div

logical - AND , OR , XOr , X nor

branch, jump instruction

Increment , decrement instruction

Very simple, place an interrupt before the selected instruction and up-count a reserved register then return to continue the program.

Later you can send the count back to your PC. I usually include an LED to let me know its counting.

ok how many mistake I have done , just tell me . I will modify the circuit.

1) INSTRUCTIONS need to be more then the data bus

2) you need to send 4 bit data to the PC

3) ask me an easy question .... how many stars in the sky

4) spending my life for you because you don't want to learn a working device.

5) have a nice life .


If you think that you are wasting your life then I have to stop here

have a nice life

Thanks for best answer.

You are not a waste of life.

Trying to learn is a valuable gift.

I meant I was putting long effort into your one way obsession to design a 4bit uP .

The drawing shows how to jump relative using the PC parallel load feature took me over an hour.

This message is taking 20 minutes.

You need to work with the 8051 then come back to your design with the new insight :)

ok next Time I will remember for your valuable time. I have done some project on proteus software like Led blinking , LCD display , DC motor

next what I have to do with 8051 ?

ok how many mistake I have done , just tell me . I will modify the circuit.

Here is a good block diag of a working uP.

A program counter advances to the next instruction in flash memory to be placed on the program bus every clock cycle

A clock cycle may consist of up to four phases.

There is an 8 Bit wide DATA BUS that allows changing the lower 8 bits of the program counter this is known as a relative jump of as much as +128 or -127..... A full 1K Page Direct jump requires two sequential instructions.

The 8 level stack allows PUSH (save) the program counter and POP (retrieve) your place in the program counter up to eight consecutive times used by interrupt and advanced software.

The flash memory places the information pointed to by the PC program counter into the Instruction Register which operates the Instruction Decode & Control block and provides the top 5 bits of a direct address to the PC.

The ALU Arithmetic Logic Unit does your add shift and or subtract functions. The Working register is used in most immediate math and logic.

The status register provides a carry bit, the zero bit, the equal bit, the greater bit, FSR bits, interrupt enable bit and timer roll over bit.

The Address Multiplexer works the 68 words (read/write registers) 8 bits wide RAM (Random Access Memory) storage and retrieval.

Power up timer waits for all elements to synch.

Power on reset forces the PC to start executing instruction code at a top flash memory location.

A Watch Dog Timer when enabled by a wise programmer requires a WDT reset command instruction every couple of milliseconds otherwise the WDT will restart the uP on the assumption that something has gone wrong.


I saw that circuit ,that's are very complicated

That is what it takes to make a very simple 8051 processor work.

You can see how hard it is to advise you on wiring your beginning designs.

This was 4 of 39 micros I learned to use... A very easy way to learn is to buy a low cost 8051 kit and start to program it..... Then very quickly it will make sense to you.

A] The key to understand is your instructions are saved in the flash memory just like text on a page.

B] The program counter goes line by line.

C] Sometimes there is a decision and branch.

D] IF you don't understand go and read [A]

E] When you DO understand continue advancing the PC

F] Give ICeng a Best Answer !

G] End of Program......

thank you very much for helping me , no doubt you always give best answers

I have knowledge about assembly language. I wrote some code for LED, Display and motor but thats part of

you are experts I just want to improve my circuit.

tell me at least 5 mistake that I can Improve to make basic processor ? I will try to solve all mistake one by one

circuit data transfer.pngcircuit ALU.png

Ok but Its very tough for me

I have circuit that can execute following instructions

instruction LOAD, MOV, STORE , ADD, SUB , AND , OR

how to execute jump and branch instruction ?

please look the circuit I have attach circuit below.


On your incomplete schematic, count the OE signal cycles of your 3state IC data drivers with one or four simple digital counters that have a numeric display.

You execute a jump by overriding and loading a numeric address into the processors PC = Program Counter...


Best Answer 3 years ago

What are you trying to count, a waveform or some uP event or What ?


3 years ago

counter for MCU