RANN
RANN
on
Submitted By:
Submitted To:
Pankaj Raj Dawadi
We wish to extend our heartfelt thanks to Mr. Pankaj Raj Dawadi, our mentor, for his
invaluable guidance, direction, and unwavering support throughout the development of
our computer design, rooted in the foundational principles of "Basic Computer." Our
gratitude also extends to all those who facilitated our successful completion of this
endeavor. Through this project, we deepened our comprehension of essential
components like computer memory, registers, and flip-flops. Additionally, we
appreciate the university and the Department of Computer Science and Engineering
(DOCSE) for granting us the opportunity to undertake this project.
Abstract
A computer is an electronic device capable of interpreting and carrying out a few sets
of commands and instructions built into its design. These commands make up the
computer's instruction set. RANN computer is a 12-bit CPU computer that has
implemented all the basic requirements of a basic computer.
1. A memory of 256 x 12
2. Registers: AR, PC, DR, AC, SC, IR, TR, INPR, OUTR
4. 3 X 8 Decoders
As we have used a 256 x 12 sized memory, it will allow us to have 256 different slots
wherein 12 different bits can be stored and executed in each slot.
i
Table of Contents
ACKNOWLEDGEMENT ............................................................................................. i
Abstract .......................................................................................................................... i
List of Figures .............................................................................................................. iv
List of Tables ................................................................................................................ v
Chapter 1 Introduction ............................................................................................ 1
Chapter 2 Design Considerations ........................................................................... 2
2.1 Instruction Format .......................................................................................... 2
2.2 Addressing Modes .......................................................................................... 2
2.2.1 Direct Addressing Mode ......................................................................... 3
2.2.2 Indirect Addressing Mode....................................................................... 3
2.3 Instruction Sets ............................................................................................... 4
2.3.1 Memory Reference Instruction (MRI) .................................................... 4
2.3.2 Register Reference Instruction (RRI) ..................................................... 5
2.3.3 Input Output Instruction (IOI) .................................................................... 5
2.4 Control Unit.................................................................................................... 6
2.4.1 Timing and Control ................................................................................. 6
2.4.2 Timing Signals ........................................................................................ 8
2.5 Instruction Cycle ............................................................................................ 8
2.5.1 Fetch Cycle ............................................................................................. 8
2.5.2 Decode Cycle .......................................................................................... 9
2.5.3 Execution Cycle .................................................................................... 11
2.6 I/O and Interrupt ........................................................................................... 13
2.6.1 Register Transfer Operations in Interrupt Cycle ................................... 15
2.7 Components.................................................................................................. 16
2.7.1 Registers ................................................................................................ 16
2.7.2. Arithmetic and Logic Unit (ALU) ............................................................. 18
2.7.3. Memory ..................................................................................................... 18
ii
2.7.4. Common Bus System ................................................................................ 19
2.7.5 Flip Flops .................................................................................................... 21
Chapter 3 Design of Components ......................................................................... 22
3.1 Control of Registers and Memory ................................................................ 22
3.1.1 AR ............................................................................................................... 22
3.1.2 DR ............................................................................................................... 23
3.1.3 PC ............................................................................................................... 24
3.1.4 SC ............................................................................................................... 24
3.1.5 IR ................................................................................................................ 25
3.1.6 TR ............................................................................................................... 25
3.1.7 OUTR ......................................................................................................... 26
3.1.8 AC ............................................................................................................... 26
3.1.9 Memory ...................................................................................................... 27
3.2 Control of Flags ............................................................................................ 28
3.2.1 Start-Stop Flip Flop (S) ............................................................................ 28
3.2.2 End-around Carry (E) ............................................................................... 29
3.2.3 Interrupt Flip Flop(R) ............................................................................... 29
3.2.3 Interrupt Enable (IEN) .............................................................................. 30
3.2.3 Input Flag (FGI)........................................................................................ 30
3.2.3 Output Flag (FGO) ..................................................................................... 31
3.3 Control of Common Bus ................................................................................... 32
3.4. ALU (Adder and Logic Circuit) ....................................................................... 36
Chapter 4: Conclusion................................................................................................. 37
iii
List of Figures
iv
List of Tables
v
Chapter 1 Introduction
Computers can only process binary code, which consists of specific instructions. The
capacity of computers to understand and carry out these instructions is ingrained in
their design, forming an instruction set. Choosing the correct set of instructions and
binary code is vital for computer developers.
RANN is a 12-bit CPU that we have developed and simulated, implements all the ideas
of Computer System Architecture together. It has different instructions based on the
suitability of design. RANN has one bit addressing mode, 3 bit opcode, and 8 bit
address length.
1. A memory of 256 x 12
4. Decoders
1
Chapter 2 Design Considerations
The following section describes the design process, the internal architecture of the
RANN computer, and the instruction set supported by this computer.
b. Address: It specifies the registers and/or locations in the memory to use for a
particular operation.
In the RANN computer, the memory contains 256 (or 28) words, so we need 8 bits to
specify the memory address used by an instruction. Given that each word is 12 bits, we
allocate 8 least significant bits (LSBs) for the address. The most significant bit (MSB)
is reserved to represent the addressing mode. The remaining 3 bits are used to represent
the opcodes of the instruction.
Io 0 Direct
I1 1 Indirect
2
2.2.1 Direct Addressing Mode
The address of the operand is stored in the memory location specified in the instruction
in the direct addressing mode.
The address of the operand is stored in the instruction in the indirect addressing mode.
3
2.3 Instruction Sets
The different types of instruction formats with their instruction types in RANN
Computer is described below:
In MRI, 4 bits are read from the memory during the fetch and decode cycle. It is used
to specify the memory operation, and the next 8 bits read from the memory contains
the memory address of the operand.
Table 2. Memory Reference Instruction
I=0 I=1
4
2.3.2 Register Reference Instruction (RRI)
RRI instructions manipulate the contents of the registers without involving memory
locations.
5
OUT 1111 00000010 Output character from AC
The control unit in the RANN computer is set up with a hardwired control system. It
uses circuits made of gates, flip-flops, and other digital components. Its main role is to
organize how the computer operates, deciding how instructions and data move around
inside the system.
The RANN computer relies on a master clock to ensure synchronization. This clock
sends regular pulses to various components like flip-flops and memory registers.
However, these pulses only impact a component if it's instructed to do so by a control
signal. These control signals originate from the control unit, directing different parts of
the computer. For instance, they guide the memory on data transmission and instruct
the processor on which operations to execute.
6
Figure 4. Control Unit of RANN computer
The block diagram of the control unit is shown in the figure above. It consists of two
decoders, a sequence counter, and several control logic gates. An instruction read from
memory is placed in the instruction register (IR). The IR consists of three parts: the
addressing mode field, the operation code, and the address. The addressing mode field
in bits 12 is stored in I flip flop. Similarly, the operation codes in bits 10 through 8 are
decoded with a 3 x 8 decoder. The eight outputs of the opcode decoder are designated
by the symbols D0 through D7. Bits 0 through 7 are applied to the control logic gates.
7
2.4.2 Timing Signals
The 4-bit sequence counter can count in binary from 0 through 15. Its outputs are
decoded into 16 timing signals labeled T0 through T15. The sequence counter can be
either incremented or cleared synchronously. Typically, the counter is incremented to
generate the sequence of timing signals through the 4x16 decoder. Occasionally, after
the completion of an instruction, the counter is reset to 0, causing the next active timing
signal to be T0.
1. Fetch Cycle: Here, the instruction is fetched from the main memory.
In the fetch cycle, the instruction is retrieved from memory and stored in the instruction
register. Initially, the address of the next instruction in memory is held in the program
counter. During the first T0 timing signal, this address is transferred to the Address
Register. Subsequently, during the next timing signal, the content of the memory
pointed to by the Address Register is copied to the instruction register. At the same
time, both the Program Counter and the Address Register are incremented by one.
The following RTL denotes the fetch cycle.
T0 : AR ← PC
T1 : IR ← M[AR], PC ← PC + 1
8
2.5.2 Decode Cycle
During the decode cycle, the instruction stored in the instruction register is decoded to
determine its type. This decoding process generates the necessary lines to specify the
operation to be performed. The RTL (Register Transfer Language) notation represents
the decoding cycle.
T2 : D0…D7 ←Decode IR (10-8), I ← IR(11), AR ←IR(7-0)
After the instruction is fetched from memory, it undergoes decoding during the T2
cycle to determine its nature before proceeding to the Execution cycle. The decoded
values of I and D0 to D7 are evaluated to identify whether the instruction is MRI
(Memory Reference Instruction), RRI (Register Reference Instruction), or IOI
(Input/Output Instruction).
A flowchart illustrating the fetch and decode cycle is provided below.
9
Figure 5. Instruction Types
From Figure 5,
D7’IT3 : AR ← M[AR]
D7’I’T3 : Nothing (NOP)
D7I’T3 : Execute a register reference instruction
D7IT3 : Execute an input-output instruction
10
2.5.3 Execution Cycle
After the decision is made in the T2 cycle, the instructions are directed to their
respective addressing modes. Subsequently, during the T3 cycle, the execution phase
commences. The instructions are divided into three categories: register-reference,
memory-reference, and input-output instructions.
CLA rB0 AC ← 0
CME rB2 E ← E’
11
2.5.3.2 Memory Reference Instructions (MRI)
12
2.5.3.3 Input Output Instructions (IOI)
13
Figure 6. Flowchart for interrupt cycle
14
2.6.1 Register Transfer Operations in Interrupt Cycle
The interrupt cycle begins after the last execution phase if the interrupt flip-flop R is
set to 1. This flip-flop is activated if the IEN (Interrupt Enable) is equal to 1 and either
FGI (Flag for Input) or FGO (Flag for Output) is equal to 1. This condition can occur
during any clock transition except when timing signals T0, T1, or T2 are active. The
condition for setting flip-flop R to 1 can be expressed with the following register
transfer statement:
T0’T1’T2’(IEN)(FGI + FGO): R ← l
The symbol ‘+’ between FGI and FGO in the control function designates a logic OR
operation. This is ANDed with IEN and T0’T1’T2’.
We now modify the fetch and decode phases of the instruction cycle. Instead of solely
relying on timing signals T0, T1, and T2 (as shown in Figure:6), we will AND these
signals with the interrupt flip-flop R to recognize the fetch and decode phases using the
three control functions RT0, RT1, and RT2. This modification ensures that after an
instruction is executed and the SC (Sequence Counter) is cleared to 0, the control will
enter a fetch phase only if R equals 0. However, if R equals 1, indicating an interrupt
request, the control will proceed through an interrupt cycle. During this cycle, the return
address (available in PC - Program Counter) will be stored into memory location 0, the
control will branch to memory location 1, and the interrupt enable (IEN), interrupt flip-
flop (R), and SC will all be cleared to 0. This sequence of microoperations can be
implemented as follows:
RT0 : AR ← 0, TR ← PC
RT1 : M [AR] ← TR, PC ← 0
RT2 : PC ← PC+1, IEN ← 0, R ← 0, SC ← 0
During the first timing signal, the Address Register (AR) is cleared to 0, and the content
of the Program Counter (PC) is transferred to the temporary register (TR). With the
second timing signal, the return address is stored in memory at location 0, and the PC
is cleared to 0. During the third timing signal, the PC is incremented to 1, the interrupt
15
enable (IEN) and interrupt flip-flop (R) are cleared, and control returns to T0 by
clearing the Sequence Counter (SC) to 0.
At the beginning of the next instruction cycle, the condition RT0 is met, and the content
of the PC is equal to 1. The control then proceeds through an instruction cycle that
fetches and executes the BUN (Branch Unconditionally) instruction located at memory
location 1.
2.7 Components
2.7.1 Registers
RANN Computer is composed of 9 registers. They are as follows:
Size: 12 bits
IR stores the 12 bits of instruction read from the memory. At the start of each instruction
cycle, the address contained in the PC is transferred to the AR, and the content of the
memory location pointer by AR is then transferred to the IR through the common bus
system (CBS). Once the instruction is loaded in the IR it is then decoded to obtain the
decoded lines (10-8), (D0 - D7) and B0 - B7 which along with the timing signals are
used to provide the necessary control signals for the computer to execute the stated
operation.
Size: 8 bits
The program counter contains the address of the memory location where the next
instruction is located. At the beginning of each instruction cycle (fetch), the content of
the program counter is transferred to AR and then is incremented by one point to the
next consecutive location. In the case of subroutines, the content of the program counter
(PC) is saved in the memory and is loaded with the location of the memory containing
16
the subroutine procedure. Finally, at the end of the subroutine call, the PC is loaded
with the previously saved address and the execution cycle continues.
Size: 12 bits
The data register is used to store the operand read from the memory that is to be
processed. The output of the data register is an input to the ALU.
2.7.1.4 Accumulator
Size: 12 bits
The accumulator is the main register for most of the operations. It stores the result of
any operation after its completion. The input of the accumulator comes from the output
of the ALU. The input of the accumulator is not directly interfaced with the CBS. The
output of the AC goes to the common bus system which goes to ALU as the first
operand, the second being the content of the Data register.
Size: 6 bits
Input register (INPR) is connected to the ALU and the content of the input register is
transferred to the ALU on the selection of the transfer operation.
Size: 6 bits
Output register (OUTR) is used by the computer to provide output. It receives its output
from the common bus system which usually comes from the accumulator. This output
may be then connected to an external display.
Size: 12 bits
17
A 12-bit non-programmable register is used to hold data during an arithmetic and logic
operation. In our RANN computer design, the temporary register came into play, when
we were performing the SWP operation.
It is used for data rarely written to (e.g. system time), where the reader wants a
consistent set of information and is willing to retry if that information changes. In
RANN, a 3-bit sequence counter is used which is connected to a 4 x 16-bit decoder.
Size:8 bits
It contains the main memory addresses of data and instructions or a portion of the
address that is used in the calculation of the complete addresses. It holds the memory
location of data that needs to be accessed.
The arithmetic and logic unit in our computer performs arithmetic and logical
operations.
2.7.3. Memory
Size: 256*12
The memory size of 256 x 12 indicates a basic computer having 256 different slots
where 12 bits of instructions can be stored and executed in each slot. Memory stores
both the instruction and the data on which processing is to be performed. We require
an 8-bit address line to address all the words of the memory. Memory receives its
address from the Address Register (AR), it receives/sends its data from the common
bus system, read or write operations are distinguished from the control signal.
18
2.7.4. Common Bus System
The RANN Computer uses a 12-bit pathway called a bus to connect its internal
registers. These registers include Memory, Accumulator, Address Register, Program
Counter, Instruction Register, Temporary Register, and Data Register, each capable of
handling 12 bits of data. The Data Register communicates with the Arithmetic Logic
Unit (ALU), which is connected to both the Control Unit and the 12-bit Accumulator.
The Control Unit directs the system's operations and communicates with different parts
using control signals. It gets instructions from the Instruction Register, interprets them,
and coordinates tasks accordingly. Additionally, there's an Output Register with a
capacity of 6 bits, connected directly to the bus, enabling output operations. On the
other hand, an Input Register communicates with the ALU to receive incoming data.
In a nutshell, the RANN Computer employs a 12-bit bus to connect various registers,
facilitating data transfer and manipulation under the control of the Control Unit.
19
Figure 7. Common Bus System
20
2.7.5 Flip Flops
R Interrupt Flag
21
Chapter 3 Design of Components
The following are the controls of registers and memory used in computers. For
simplification, we have used r and p as a combination of signals such as:
Figure 8. r signal
r → D7I’T3
Figure 9. p signal
p → D7IT3
3.1.1 AR
LD:
R’T0 : AR ← PC
R’T2 : AR ← IR (11-0)
D7’IT3 : AR ← M[AR]
INC:
D6T4 : AR ← AR + 1
CLR:
RT0 : AR ← 0
22
Figure 10. AR Control
3.1.2 DR
LD:
D1T4 : DR ← M[AR]
D2T4 : DR ← M[AR]
D3T4 : DR ← M[AR]
D4T4 : DR ← M[AR]
23
3.1.3 PC
LD:
D5T4 : PC ← AR
D6T5 : PC ← AR
INC:
R’T1 : PC ← PC + 1
pB3 : PC ← PC + 1 (if FGO = 1)
pB2 : PC ← PC + 1 (if FGI = 1)
RT2 : PC ← PC + 1
3.1.4 SC
CLR:
r : SC ← 0
D0T6 : SC ← 0
D1T5 : SC ← 0
D2T5 : SC ← 0
D3T5 : SC ← 0
24
D4T4 : SC ← 0
D5T4 : SC ← 0
D6T5 : SC ← 0
RT2 : SC← 0
3.1.5 IR
CLR:
R’T1 : IR ← M[AR]
3.1.6 TR
LD:
D0T4 : TR ← M[AR]
25
RT0 : TR ← PC
3.1.7 OUTR
LD:
pB1 : OUTR ← AC
3.1.8 AC
LD:
pB0 : AC ← INPR
D3T5 : AC ← DR
D0T6 : AC ← TR
rB4 : AC ← (AC)’
INC:
rB6 : AC ← AC + 1
26
CLR:
rB0 : AC ← 0
3.1.9 Memory
D0T5 : M[AR] ← AC
D6T4 : M[AR] ← PC
RT1 : M[AR] ← TR
27
3.1.9.2 Memory Read:
R’T1 : IR ← M[AR]
D7’IT3 : AR ← M[AR]
D1T4 : DR ← M[AR]
D2T4 : DR ← M[AR]
D3T4 : DR ← M[AR]
D4T4 : DR ← M[AR]
D0T4 : TR ← M[AR]
rB7 : S ← 0
28
3.2.2 End-around Carry (E)
rB1 : E ← 0
rB2 : E ← E’
D2T5 : E ← Cout
T0’T1’T2’(IEN)(FGI + FGO): R ← l
RT2 : R ← 0
29
3.2.3 Interrupt Enable (IEN)
pB4 : IEN ← l
pB5 : IEN ← 0
RT2 : IEN ← 0
pB0 : FGI ← 0
30
3.2.3 Output Flag (FGO)
pB1 : FGO ← 0
31
3.3 Control of Common Bus
The 12-bit common bus is controlled by the selection inputs S2, S1, S0. Each binary
number selects each register. Each binary number is associated with a Boolean variable
X1 through X7.
0 0 0 0 0 0 0 0 0 0 None
0 0 0 0 0 0 1 0 0 1 AR
0 0 0 0 0 1 0 0 1 0 PC
0 0 0 0 1 0 0 0 1 1 DR
0 0 0 1 0 0 0 1 0 0 AC
0 0 1 0 0 0 0 1 0 1 IR
0 1 0 0 0 0 0 1 1 0 TR
1 0 0 0 0 0 0 1 1 1 Memory
To find the logic that makes X1 = 1, we extract all those statements with AR as source.
D5T4 : PC ← AR
D6T5 : PC ← AR
32
X1 = D5T4 + D6T5
To find the logic that makes X2 = 1, we extract all those statements with PC as source.
R’T0 : AR ← PC
RT0 : TR ← PC
D6T4 : M[AR] ← PC
X2 = R’T0 + RT0 + D6T4
To find the logic that makes X3 = 1, we extract all those statements with DR as source.
D3T5 : AC ← DR
X3 = D3T5
To find the logic that makes X4 = 1, we extract all those statements with AC as source.
pB1 : OUTR ← AC
D1T5 : AC ← AC AND DR
D2T5 : AC ← AC + DR
X4 = D3T5 + D1T5 + D2T5
To find the logic that makes X5 = 1, we extract all those statements with IR as source.
R’T2 : AR ← IR (7-0)
R’T2 : AR ← IR (7-0)
X5 = R’T2
To find the logic that makes X6 = 1, we extract all those statements with TR as source.
RT1 : M[AR] ← TR
D0T6 : AC ← TR
X6 = D0T6 + RT1
To find the logic that makes X7 = 1, we extract all those statements with M[AR] as
source.
D7’IT3 : AR ←M[AR]
33
R’T1 : IR ← M[AR]
D1T4 : DR ← M[AR]
D2T4 : DR ← M[AR]
D3T4 : DR ← M[AR]
D4T4 : DR ← M[AR]
D0T4 : TR ← M[AR]
X7 = D7’IT3 + R’T1 + D1T4 + D2T4 + D3T4 + D4T4 + D0T4
34
Figure 26. Control of Common Bus System
35
3.4. ALU (Adder and Logic Circuit)
We have implemented the one stage of the ALU with the corresponding input and
output carries.
36
Chapter 4: Conclusion
Designing a 12-bit CPU was a complex yet indispensable process required to integrate
all concepts of Computer System Architecture. A comprehensive understanding of
computer organization and architecture was vital for the completion of this task.
After all hardware components were assembled accordingly, ensuring that different
instructions could run smoothly without causing any issues was found to be more
challenging than initially anticipated. However, through gradual work, the assembly of
all signal and control lines, and the alignment of the appropriate logic gates, led to the
successful design of the computer, which we named RANN.
In summary, crafting the 12-bit CPU, RANN, underscored the importance of Computer
System Architecture understanding, overcoming initial challenges to achieve
successful implementation.
37