Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 3 — General Register Organization

Lesson 33 of 49 in the free Computer Organization and Architecture notes on Siksha Sarovar, written by Rohit Jangra.

Why General Registers?

The basic computer of the previous lessons has one accumulator. Every operation must pass through AC and therefore through memory, which is slow.

   Memory access time  ~  50-100 ns  (main memory)
   Register access time ~   1 ns

   A CPU with 8-32 general-purpose registers can keep intermediate
   results on-chip, dramatically reducing memory traffic.
General register organization = a set of registers plus a common ALU, interconnected by buses, with the source, destination and operation all selected by fields of a control word.

1. The Register File Architecture

   Components:
      - 7 registers R1..R7 (plus an external input)
      - Two 8-to-1 MUXes forming bus A and bus B (the two ALU operands)
      - An ALU performing the selected micro-operation
      - A 3-to-8 decoder selecting the destination register
      - Everything is controlled by ONE control word.

2. The Control Word

    3      3      3      5
   +------+------+------+--------+
   | SELA | SELB | SELD |  OPR   |     = 14 bits
   +------+------+------+--------+

   SELA : selects the source for bus A (the first operand)
   SELB : selects the source for bus B (the second operand)
   SELD : selects the destination register
   OPR  : selects the ALU operation

Encoding of SELA / SELB

BinarySELA sourceSELB source
000InputInput
001R1R1
010R2R2
011R3R3
100R4R4
101R5R5
110R6R6
111R7R7

Encoding of SELD

BinaryDestination
000None (result discarded — used for compare)
001R1
010R2
111R7

Encoding of OPR (the ALU operation)

OPROperationSymbol
00000Transfer ATSFA
00001Increment AINCA
00010Add A + BADD
00101Subtract A − BSUB
00110Decrement ADECA
01000AND A and BAND
01010OR A and BOR
01100XOR A and BXOR
01110Complement ACOMA
10000Shift right ASHRA
11000Shift left ASHLA

3. Worked Micro-operation Encodings

   Micro-operation:  R1 <- R2 - R3

      SELA = R2   = 010
      SELB = R3   = 011
      SELD = R1   = 001
      OPR  = SUB  = 00101

      Control word: 010 011 001 00101
   Micro-operation:  R4 <- R4 v R5      (OR)

      SELA = 100,  SELB = 101,  SELD = 100,  OPR = 01010
      Control word: 100 101 100 01010
   Micro-operation:  R7 <- R1           (transfer)

      SELA = 001,  SELB = 000 (don't care),  SELD = 111,  OPR = 00000
      Control word: 001 000 111 00000
   Micro-operation:  Output <- R2       (send R2 to the external output)

      SELA = 010,  SELB = xxx,  SELD = 000 (none),  OPR = 00000
      Control word: 010 000 000 00000
   Micro-operation:  R4 <- shl R4

      SELA = 100,  SELB = 000,  SELD = 100,  OPR = 11000
      Control word: 100 000 100 11000
   Micro-operation:  R5 <- 0            (clear)

      Clear is XOR with itself:
      SELA = 101,  SELB = 101,  SELD = 101,  OPR = 01100 (XOR)
      Control word: 101 101 101 01100

4. Complete Worked Table

Micro-operationSELASELBSELDOPRControl word
R1 ← R2 − R3R2R3R1SUB010 011 001 00101
R4 ← R4 ∨ R5R4R5R4OR100 101 100 01010
R6 ← R6 + 1R6R6INCA110 000 110 00001
R7 ← R1R1R7TSFA001 000 111 00000
Output ← R2R2NoneTSFA010 000 000 00000
Output ← InputInputNoneTSFA000 000 000 00000
R4 ← shl R4R4R4SHLA100 000 100 11000
R5 ← 0R5R5R5XOR101 101 101 01100

5. Advantages of General Register Organization

AdvantageWhy
Fewer memory referencesIntermediates stay in registers
Faster executionRegister access is ~50× faster than memory
Shorter instructionsA 3-bit register field vs a 16-bit address
Flexible operand selectionAny register can be any operand
Compiler friendlyRegister allocation is a well-solved optimisation
Supports 2- and 3-address formatsR1 ← R2 + R3 in one instruction

6. Accumulator vs General Register vs Stack Organization

BasisAccumulator (single-AC)General registerStack
Operand locationOne in AC, one in memoryRegisters (and memory)Top of stack
Instruction format1-address2- or 3-address0-address
Example: X = A + BLOAD A; ADD B; STORE XMOV R1,A; ADD R1,B; MOV X,R1PUSH A; PUSH B; ADD; POP X
Instruction lengthShortMediumVery short
Program lengthLongShortMedium
Memory trafficHighLowMedium
HardwareSimpleModerateSimple
ExamplesBasic computer, 8085 (partly)x86, ARM, MIPS, RISC-VJava VM, older Burroughs machines

7. Register Windows (bonus — RISC concept)

   Problem: every procedure call must save and restore registers -> slow.

   Solution (SPARC): the register file is much larger than what is
   visible at once. A moving WINDOW exposes a subset:

      +-------------------+
      | Incoming params   |  <- overlaps the caller's outgoing block
      +-------------------+
      | Local variables   |
      +-------------------+
      | Outgoing params   |  <- overlaps the callee's incoming block
      +-------------------+

   A call simply moves the window; the overlap passes the parameters
   with ZERO register copying.

Summary

   Control word = SELA | SELB | SELD | OPR
   SELA, SELB   : 8-to-1 MUX select for the two ALU operand buses
   SELD         : 3-to-8 decoder select for the destination
   OPR          : ALU function select
   Encoding a micro-operation = filling in these four fields.

The next lesson covers the alternative organization named in that comparison table: the stack.