π Lecture 7 β Design Process for ISA of FALCON-A
π Overview: This lecture outlines the systematic thinking process for designing an Instruction Set Architecture (ISA) by walking through each step of creating the ISA for a new processor called FALCON-A. It covers the key elements that define any ISA and introduces the programmer's view of the FALCON-A processor, which will serve as a teaching aid throughout the course.
ποΈ Topics Covered
The lecture covers the three key components that define any ISA: the operations the processor can execute, data access mode for operands, and representation of operations in memory. It then details eight specific steps for designing the FALCON-A ISA, including selecting instructions, choosing mnemonics, allocating op-code bits, assigning op-codes, determining operand types and formats, designing memory organization, specifying memory access instructions, and selecting addressing modes. The lecture concludes with an introduction to the FALCON-A processor and the programmer's view of its architecture.
π Lecture Summary
Instruction Set Architecture (ISA) Design: Outline of the thinking process
In this module, we learn to appreciate, understand, and apply the approach adopted in designing an instruction set architecture by designing an ISA for a new processor named FALCON-A. FALCON-A stands for First Architecture for Learning Computer Organization and Networks (version A). The term Organization is intended to include Architecture and Design in this acronym.
Elements of the ISA
Before designing the ISA for FALCON-A, we examine the three key components that define any instruction set architecture:
- The operations the processor can execute
- Data access mode for use as operands in the operations defined
- Representation of the operations in memory
The operations the processor can execute
All processors need to support at least three categories (or functional groups) of instructions:
- Arithmetic, Logic, Shift
- Data Transfer
- Control
ISA Design Steps β Step 1
We need to think of all instructions of each type that ought to be supported. The following instructions will be included in the ISA for FALCON-A:
Arithmetic: add, addi (add immediate), subtract, subtract-immediate, multiply, divide
Logic: and, and-immediate, or, or-immediate, not
Shift: shift left, shift right, arithmetic shift right
Data Transfer: Data transfer between registers, moving constants to registers, load operands from memory to registers, store from registers to memory, and movement of data between registers and input/output devices
Control: Jump instructions with various conditions, call and return from subroutines, instructions for handling interrupts
Miscellaneous instructions: Instructions to clear all registers, the capability to stop the processor, ability to "do nothing", etc.
ISA Design Steps β Step 2
Once we have decided on the instructions, the second step is to select suitable mnemonics for these instructions. The following mnemonics have been selected:
Arithmetic: add, addi, sub, subi, mul, div
Logic: and, andi, or, ori, not
Shift: shiftl, shiftr, asr
Data Transfer: load, store, in, out, mov, movi
Control: jpl, jmi, jnz, jz, jump, call, ret, int, iret
Miscellaneous: nop, reset, halt
ISA Design Steps β Step 3
The next step is to decide upon the number of bits to be reserved for the op-code part of the instructions. Since we have 32 instructions in the instruction set, 5 bits will suffice (as 2β΅ = 32) to encode these op-codes.
ISA Design Steps β Step 4
The fourth step is to assign op-codes to these instructions. The assigned op-codes are shown below:
Arithmetic: add (0), addi (1), sub (2), subi (3), mul (4), div (5)
Logic: and (8), andi (9), or (10), ori (11), not (14)
Shift: shiftl (12), shiftr (13), asr (15)
Data Transfer: load (29), store (28), in (24), out (25), mov (6), movi (7)
Control: jpl (16), jmi (17), jnz (18), jz (19), jump (20), call (22), ret (23), int (26), iret (27)
Miscellaneous: nop (21), reset (30), halt (31)
These instructions with their op-codes are listed in binary form as they would appear in machine instructions of FALCON-A.
Data access mode for operations
The ISA defines, besides the instructions implemented, the resources each instruction can access: the number of registers available, the number of registers each instruction can access, which instructions are allowed to access memory, any special registers, constants, and alternatives to general-purpose registers.
ISA Design Steps β Step 5
We now need to select the number and types of operands for various instructions.
ALU instructions may have 2 to 3 registers as operands. In case of 2 operands, a constant (an immediate operand) may be included in the instruction.
For load/store type instructions, we require a register to hold the data to be loaded/stored, another register to hold the base address for memory access, and a field for specifying the constant that is the displacement to the base address.
In jump instructions, we require a field for specifying the register holding the value to be compared as the condition for the branch, as well as a destination address specified as a constant.
Once we have decided on the number and types of operands, we need to assign specific bit-fields in the instruction for each operand. The number of bits required to represent each operand will determine the instruction word size. For FALCON-A, we reserve eight general-purpose registers. To encode a register, 3 bits are required (as 2Β³ = 8).
The instructions for FALCON-A will have a general format with four different formats, depending on the actual number of operands in a particular instruction.
ISA Design Steps β Step 6
The next step is the design of memory and its organization. The number of memory cells depends on the size of the Program Counter (PC) register and the size of the address bus. This is because these sizes limit how many memory cells can be referred to for loading an instruction. Additionally, the size of the data bus limits the size of the memory word that can be referred to in a single clock cycle.
ISA Design Steps β Step 7
We need to specify which instructions will be allowed to access the memory. Since FALCON-A is intended to be a RISC-like machine, only the load/store instructions will be allowed to access memory.
π Definition β RISC: Reduced Instruction Set Computer, a processor design philosophy that uses a small, highly optimized set of instructions.
ISA Design Steps β Step 8
Next we need to select the memory-addressing modes. The lecture lists the types of addressing modes supported for load/store instructions in FALCON-A.
FALCON-A: Introduction
FALCON stands for First Architecture for Learning Computer Organization and Networks. It is a 'RISC-like' general-purpose processor that will be used as a teaching aid for this course. Although FALCON-A is a simple machine, it is powerful enough to explain a variety of fundamental concepts in Computer Architecture.
Programmer's view of the FALCON-A
FALCON-A is an example of a GPR (General Purpose Register) computer. The programmer's view reveals the CPU contains a register file of 8 registers, named R0 through R7. Each register is 16 bits in length. Aside from these, there are two special-purpose registers: the Program Counter (PC) and the Instruction Register (IR).
π Definition β Big-endian: A byte ordering format where the most significant byte (MSB) is stored at the smallest memory address.
The main memory is organized as 2ΒΉβΆ x 8 bits, i.e., 2ΒΉβΆ cells of 1 byte each. The memory word size is 2 bytes (or 16 bits). The input/output space is 256 bytes (8-bit I/O ports). Storage in registers and memory is in the big-endian format.
π‘ Why this matters: Understanding the programmer's view gives you the complete picture of all resources available to the programmer, including register sizes, memory organization, and data representation, which are essential for writing and understanding programs.
β Key Takeaways
The ISA design process for FALCON-A follows eight systematic steps from selecting operations to defining addressing modes. The FALCON-A supports 32 instructions across arithmetic, logic, shift, data transfer, control, and miscellaneous categories, all encoded using 5-bit op-codes. The processor has 8 general-purpose registers (16 bits each), two special-purpose registers (PC and IR), and memory organized as 2ΒΉβΆ Γ 8 bits with 16-bit word size. As a RISC-like machine, only load/store instructions can access memory, and data is stored in big-endian format. The five addressing modes supported for load/store operations enable flexible memory access patterns using base registers and displacement values.
π§ Quick Revision Questions
- How many bits are required for the op-code field in FALCON-A, and why?
- What are the three key components that define any instruction set architecture?
- Which category of instructions is allowed to access memory in FALCON-A, and why?
- How many general-purpose registers does FALCON-A have, and what is the size of each register?
- What does the acronym FALCON stand for, and what type of processor architecture does it represent?
π Lecture 8 β ISA of the FALCON-A
π Overview: This lecture introduces the Instruction Set Architecture (ISA) of the FALCON-A processor, a simplified 16-bit processor used for learning computer architecture concepts. It covers the notation for registers and memory, instruction formats, and all the instructions grouped by type, providing the foundation for understanding how a processor executes programs.
ποΈ Topics Covered
The lecture begins with the notation used for registers and memory in the FALCON-A, including the big-endian format and concatenation for 16-bit words. It then details the processor's features, such as fixed-length 16-bit instructions and load/store architecture. The core of the lecture is a thorough walkthrough of all four instruction format types (I, II, III, IV) and the instructions that belong to each, including arithmetic, control, and data transfer operations. Finally, several examples are provided to demonstrate instruction identification, addressing modes, branch conditions, and binary encoding.
π Lecture Summary
Notation and Memory Organization for FALCON-A
The lecture begins by defining the notation for the FALCON-A. The contents of a register are referred to by enclosing the register name in square brackets (e.g., R[3] means the contents of register 3). Similarly, memory contents are referred to as M[8] for the contents of memory at location 8. Since the FALCON-A's memory is organized into 1-byte cells but its word size is 2 bytes, two adjacent memory cells make up a memory word. To refer to a 16-bit memory word, a concatenation notation is used, represented by the symbol Β©. For example, the 16-bit memory word at location 8 is written as M[8]Β©M[9].
π Definition β Big-endian: A byte ordering format where the largest numbered byte is placed at the most significant position in a word. The FALCON-A uses big-endian for bytes, but little endian (smallest numbered byte at the least-significant position) within each byte.
FALCON-A Features and Instruction Formats
The FALCON-A processor has fixed-length instructions, each 16 bits (2 bytes) long. It supports only load/store instructions for memory access, meaning arithmetic and logical operations are performed on registers. The three categories of instructions are arithmetic (including logical), control (for changing program flow), and data transfer (moving data between processor and memory). There are four instruction formats:
- Type I: Contains a 5-bit op-code (bits 11-15) and the rest of the bits are unused.
- Type II: Has a 5-bit op-code, a 3-bit register field (ra), and an 8-bit constant/immediate field (c2).
- Type III: Contains a 5-bit op-code, two 3-bit register fields (destination rd and source rs), and a 5-bit immediate operand field (c1).
- Type IV: Contains a 5-bit op-code, two 3-bit register fields (destination rd and source rs), and a 3-bit constant field (c1), plus two unused bits.
To encode the eight general-purpose registers (R0-R7) in binary, 3 bits are required. Register R0 has special usage; for example, in load/store operations, its value is considered zero. The binary encoding of registers is given in a table.
Type I Instructions
Five instructions belong to Type I, as they take no operands.
- nop (op-code = 21): Instructs the processor to do no operation. Useful in pipelining.
- reset (op-code = 30)
- halt (op-code = 31)
- int (op-code = 26)
- iret (op-code = 27)
Type II Instructions
Nine instructions belong to Type II. They have a single register operand and an 8-bit jump/displacement or constant value.
- movi (op-code = 7): Loads a register with a constant.
π Example:
movi R3, 56β R[3] β 56 - in (op-code = 24): Loads a register from an input device.
π Example:
in R3, 57β R[3] β IO[57] - out (op-code = 25): Moves data from a register to an output device.
π Example:
out R7, 34β IO[34] β R[7] - ret (op-code = 23): Returns control from a subroutine by setting PC to the value in a register.
π Example:
ret R3β PC β R[3] - jz (op-code = 19): Conditional jump if the register value is zero.
π Example:
jz r3, [4]β (R[3]=0): PC β PC+4 - jnz (op-code = 18): Conditional jump if the register value is not zero.
π Example:
jnz r4, [variable]β (R[4]β 0): PC β PC+variable - jpl (op-code = 16): Conditional jump if the register value is positive.
π Example:
jpl r3, [label]β (R[3]β₯0): PC β PC+(label-PC) - jmi (op-code = 17): Conditional jump if the register value is negative.
π Example:
jmi r7, [address]β (R[7]<0): PC β PC+address - jump (op-code = 20): Unconditional jump. Allows direct, indirect, PC-relative (near), and register-relative (far) jumps.
π Definition β PC-relative jump: When the
rafield is zero, the PC is incremented by the sign-extended value of thec2field. Formula: PC β PC + (8Β©C2<7>) Β© C2<7..0> π Definition β Register-relative jump: When therafield is non-zero, the PC is assigned the sum of the sign-extended constant and the value of the specified register. Formula: PC β R[ra] + (8Β©C2<7>) Β© C2<7..0> π Note: The compiler handles the interpretation of thec2field as a constant, variable, label, or address. The machine code contains an 8-bit constant that is added to the PC at run-time.
Type III Instructions
Nine instructions belong to Type III. They have a destination register, a source register, and a 5-bit constant/immediate operand.
- andi (op-code = 9): Bit-wise AND of a register and a constant.
π Example:
andi r4, r3, 5β R[4] β R[3] & 5 - addi (op-code = 1): Add a constant to a register.
π Example:
addi r4, r3, 4β R[4] β R[3] + 4 - subi (op-code = 3): Subtract a constant from a register.
π Example:
subi r5, r7, 9β R[5] β R[7] - 9 - ori (op-code = 11): Bit-wise OR of a register and a constant.
π Example:
ori r4, r7, 3β R[4] β R[7] ~ 3 - shiftl (op-code = 12): Shift the bits of a register to the left by a constant.
π Example:
shiftl r4, r3, 7 - shiftr (op-code = 13): Shift the bits of a register to the right by a constant.
π Example:
shiftr r4, r3, 9 - asr (op-code = 15): Arithmetic shift right, which divides a signed binary number by 2 for each shift. The sign-bit is left unchanged.
π Example:
asr r1, r2, 5This divides the value in r2 by 10 and places the result in r1. - load (op-code = 29): Load a register from a memory location. The address is the sum of a register and a constant.
π Example:
load r1, [r4 + 15]β R[1] β M[R[4] + 15] - store (op-code = 28): Store a register value to a memory location. The address is the sum of a register and a constant.
π Example:
store r6, [r7 + 13]β M[R[7] + 13] β R[6]
Type III Modified Instructions
Three instructions use a modified form of Type III, where the c1 field is unused.
- mov (op-code = 6): Copy data from one register to another.
π Example:
mov r4, r3β R[4] β R[3] - not (op-code = 14): Invert the bits of a register.
π Example:
not r4, r2β R[4] β !R[2] - call (op-code = 22): Procedure call. Saves the return address (current PC) in one register and then loads a new address into the PC from another register.
π Example:
call r4, r3β R[4] β PC, PC β R[3]
Type IV Instructions
Six instructions belong to Type IV, which operates on three registers: a destination and two sources.
- add (op-code = 0): Add two registers.
π Example:
add r4, r3, r5β R[4] β R[3] + R[5] - sub (op-code = 2): Subtract one register from another.
π Example:
sub r4, r3, r5β R[4] β R[3] - R[5] - mul (op-code = 4): Multiply two registers. The result uses a concatenation of R0 and the destination register.
π Example:
mul r5, r7, r1β R[0] Β© R[5] β R[7] * R[1] - div (op-code = 5): Divide one register by another. The result and remainder are stored.
π Example:
div r4, r7, r2β R[4] β R[0]Β©R[7]/R[2], R[0] β R[0]Β©R[7]%R[2] - and (op-code = 8): Bit-wise AND of two registers.
π Example:
and r1, r4, r5β R[1] β R[4] & R[5] - or (op-code = 10): Bit-wise OR of two registers.
π Example:
or r6, r7, r2β R[6] β R[7] ~ R[2]
Examples for FALCON-A
This section provides four examples to solidify the concepts:
- Identification of instruction types and operands: Given a list of instructions, the task is to identify their format type (I, II, III, or IV) and the values of their fields (op-code, ra, rb, rc, c1, c2).
- Addressing modes and RTL description: For instructions like
loadandstore, the addressing mode is register-relative. The RTL description explains the operation's meaning. - Branch condition and status of the PC: For branch instructions like
jz,jnz,jpl, andjmi, the condition for the branch (e.g., "if zero") and the new PC value after a true branch must be determined. - Binary encoding of instructions: Given instructions, the binary encoding of each field (op-code, register numbers, constants) is extracted using the instruction format definitions, op-code tables, and register encoding table.
π‘ Why this matters: Understanding how to encode an instruction into its binary format is the fundamental step in designing an assembler or understanding machine code.
β Key Takeaways
The FALCON-A is a 16-bit load/store architecture with fixed-length 16-bit instructions, divided into four formats (I, II, III, IV) that dictate the number and type of operands. The lecture details all 27 instructions, including their op-codes, operands, and RTL definitions. Students must memorize the instruction formats and the field widths, the special role of R0, and how conditional jumps and the subroutine call/return mechanism work. Finally, the ability to identify an instruction's format, its binary encoding, and its RTL meaning is essential for exam problems.
π§ Quick Revision Questions
- What are the three categories of instructions supported by the FALCON-A, and what is the purpose of each?
- How many bits are in a FALCON-A instruction? How many bits are used for the op-code?
- Describe the difference between a Type III and a Type III Modified instruction.
- Write the RTL for the
jumpinstruction whenrais non-zero (register-relative jump). - What is the binary encoding for the instruction
add r4, r3, r5? (Use the op-code and register encoding tables).
π Lecture 9 β Description of FALCON-A and EAGLE using RTL
π Overview: This lecture explores how Register Transfer Language (RTL) is used to formally describe both the static and dynamic behavior of the FALCON-A processor. It then introduces the EAGLE processor, an accumulator-based machine, and discusses its limitations, followed by the design improvements in the Modified EAGLE. Understanding RTL is crucial for specifying processor functionality before hardware implementation.
ποΈ Topics Covered
This lecture covers the use of Behavioral and Structural RTL to describe the FALCON-A processor, including register specification, field naming, processor state, and dynamic instruction execution. It then presents the EAGLE processor's architecture, instruction formats, and complete instruction set, followed by an analysis of its limitations and the enhancements introduced in the Modified EAGLE, including a dedicated accumulator and flag register.
π Lecture Summary
Use of Behavioral Register Transfer Language (RTL) to describe the FALCON-A
The use of RTL (an acronym for the Register Transfer Language) to describe the FALCON-A is discussed in this section. FALCON-A is the sample machine we are building in order to enhance our understanding of processors and their architecture.
Behavior vs. Structure
Computer design involves various levels of abstraction. The behavioral description of a machine is a higher level of abstraction, as compared with the structural description. A top-down approach is adopted in computer design. Designing a computer typically starts with defining the behavior of the overall system. This is then broken down into the behavior of the different modules. The process continues, till we are able to define, design and implement the structure of the individual modules.
As mentioned earlier, we are interested in the behavioral description of our machine, the FALCON-A, in this section.
Register Transfer Language
The RTL is a formal way of expressing the behavior and structure of a computer.
Behavioral RTL is used to describe what a machine does, i.e. it is used to define the functionality the machine provides. Basically, the behavioral architecture describes the algorithms used in a machine, written as a set of process statements. These statements may be sequential statements or concurrent statements, including signal assignment statements and wait statements.
Structural RTL is used to describe the hardware implementation of the machine. The structural architecture of a machine is the logic circuit implementation (components and their interconnections), that facilitates a certain behavior (and hence functionality) for that machine.
Using RTL to describe the static properties of the FALCON-A
We can employ the RTL for the description of various properties of the FALCON-A that we have already discussed.
Specifying Registers: In RTL, we will refer to a register by its abbreviated, alphanumeric name, followed by the number of bits in the register enclosed in angle brackets < >. For instance, the instruction register (IR), of 16 bits (numbered 0 to 15), will be referred to as, IR<15..0>
Naming of the Fields in a Register: We can name the different fields of a register using the := notation. For example, to name the most significant bits of the instruction register as the operation code (or simply op), we may write:
op<4..0> := IR<15..11>
Note that using this notation to name registers or register fields will not create a new copy of the data or the register fields; it is simply an alias for an already existing register, or part of a register.
Fields in the FALCON-A Instructions: We now use the RTL naming operator to name the various fields of the RTL instructions. Naming the fields appropriately helps us make the study of the behavior of a processor more readable.
op<4..0>:= IR<15..11>: operation code field
ra<2..0> := IR<10..8>: target register field
rb<2..0> := IR<7..5>: operand or address index
rc<2..0> := IR<4..2>: second operand
c1<4..0> := IR<4..0>: short displacement field
c2<7..0> := IR<7..0>: long displacement or the immediate field
We are already familiar with these fields, and their usage in the various instruction formats of the RTL.
Describing the Processor State using RTL: The processor state defines the contents of all the register internal to the CPU at a given time. Maintaining or restoring the machine or processor state is important to many operations, especially procedure calls and interrupts; the processor state needs to be restored after a procedure call or an interrupt so normal operation can continue. Our processor state consists of the following:
- PC<15..0>: program counter (the PC holds the memory address of the next instruction)
- IR<15..0>: instruction register (used to hold the current instruction)
- Run: one bit run/halt indicator
- Strt: start signal
- R[0..7]<15..0>: 8 general purpose registers, each consisting of 16 bits
FALCON-A in a black box: The given figure shows what a processor appears as to a user. We see a start button that is basically used to start up the processor, and a run indicator that turns on when the processor is in the running state. There may be several other indicators as well. The start button as well as the run indicator can be observed on many machines.
Using RTL to describe the dynamic properties of the FALCON-A
We have just described some of the static properties of the FALCON-A. The RTL can also be employed to describe the dynamic behavior of the processor in terms of instruction interpretation and execution.
Conditional expressions can be specified using the RTL. For instance, we may specify a conditional subtraction operation employing RTL as:
(op=2) : R[ra] β R[rb] - R[rc];
This instruction means that "if" the operation code of the instruction equals 2 (00010 in binary), then subtract the value stored in register rc from that of register rb, and store the resulting value in register ra.
Effective address calculations in RTL (performed at runtime): The operand or the destination address may not be specified directly in an instruction, and it may be required to compute the effective address at run-time. Displacement and relative addressing modes are instances of such situations. RTL can be used to describe these effective address calculations.
-
Displacement address: A displacement address is calculated, as shown:
disp<15..0> := (R[rb]+ (11Ξ± c1<4>)Β© c1<4..0>);This means that the address is being calculated by adding the constant value specified by the field c1 (which is first sign extended), to the value specified by the register rb. -
Relative address: A relative address is calculated by adding the displacement to the contents of the program counter register. The constant is first sign-extended. In RTL this is represented as:
rel<15..0>:=PC+(8Ξ±c2<7>)Β©c2<7..0>;
Range of memory addresses: Using the displacement or the relative addressing modes, there is a specific range of memory addresses that can be accessed.
-
Range of addresses when using direct addressing mode (displacement with rb=0):
- If c1<4>=0 (positive displacement) absolute addresses range: 00000b to 01111b (0 to +15)
- If c1<4>=1 (negative displacement) absolute addresses range: 11111b to 10000b (-1 to -16)
-
Address range in case of relative addressing:
- The largest positive value that can be specified using 8 bits (since we have only 8 bits available in c2<7..0>), is 2β·-1, and the most negative value that can be represented using the same is 2β·. Therefore, the range of addresses or locations that can be referred to using this addressing mode is 127 locations forward or 128 locations backward from the Program Counter (PC).
Instruction Fetch Operation (using RTL)
We will now employ the notation that we have learnt to understand the fetch-execute cycle of the FALCON-A processor.
The RTL notation for the instruction fetch process is:
instruction_Fetch := (
!Run&Strt : Run β 1,
Run : (IR β M[PC], PC β PC + 2;
instruction_Execution) );
This is how the instruction-fetch phase of the fetch-execute cycle for FALCON-A can be represented using RTL. Recall that := is the naming operator, ! implies a logical NOT, & implies a logical AND, β represents a transfer operation, ; is used to separate sequential statements, and concurrent statements are separated by ,. We can observe that in the instruction_Fetch phase, if the machine is not in the running state and the start bit has been set, then the run bit is also set to true. Concurrently, an instruction is fetched from the instruction memory; the program counter (PC) holds the next instruction address, so it is used to refer to the memory location from where the instruction is to be fetched. Simultaneously, the PC is incremented by 2 so it will point to the next instruction. (Recall that our instruction word is 2 bytes long, and the instruction memory is organized into 1-byte cells). The next step is the instruction execution phase.
Difference between , and ; in RTL:
We again highlight the difference between the , and ;. Statements separated by a , take place during the same clock pulse. In other words, the order of execution of statements separated by , does not matter.
On the other hand, statements separated by a ; take place on successive clock pulses. In other words, if statements are separated by ; the one on the left must complete before the one on the right starts. However, some things written with one RTL statement can take several clocks to complete.
We return to our discussion of the instruction-fetch phase. The statement !Run&Strt : Run β 1 is executed when 'Run' is 0, and 'Strt' is 1, that is, Strt has been set. It is used to set the Run bit. No action takes place when both 'Run' and 'Strt' are 0. The following two concurrent register transfers are performed when 'Run' is set to 1, (as : is a conditional operator; if the condition is met, the specified action is taken).
IR β M[PC]
PC β PC + 2
Since these instructions appear concurrent, and one of the instructions is using the value of PC that the other instruction is updating, a question arises; which of the two values of the PC is used in the memory access? As a rule, all right hand sides of the register transfers are evaluated before the left hand side is evaluated/updated. In case of simultaneous register transfers (separated by a ,), all the right hand side expressions are evaluated in the same clock-cycle, before they are assigned. Therefore, the old, un-incremented value of the PC is used in the memory access, and the incremented value is assigned to the PC afterwards. This corresponds to "master-slave" flip-flop operation in logic circuits.
This makes the PC point to the next instruction in the instruction memory. Once the instruction has been fetched, the instruction execution starts. We can also use i.F for instruction_Fetch and i.E for instruction_Execution. This will make the Fetch operation easy to write.
iF := ( !Run&Strt : Run β 1, Run : (IR β M[PC], PC β PC + 2; iE ) );
Instruction Execution (Describing the Execute operation using RTL)
Once an instruction has been fetched from the instruction memory, and the program counter has been incremented to point to the next instruction in the memory, instruction execution commences. In the instruction fetch-execute cycle we showed in the preceding discussion, the entire instruction execution code was aliased iE (or instruction_Execution), through the assignment operator :=. Now we look at the instruction execution in detail.
iE := (
(op<4..0>= 1) : R[ra] β R[rb]+ (11Ξ± c1<4>)Β© c1<4..0>,
(op<4..0>= 2) : R[ra] β R[rb]-R[rc],
. . .
. . .
(op<4..0>=31) : Run β 0,); iF );
As we can see, the instruction execution can be described in RTL by using a long list of concurrent, conditional operators that are inherently 'disjoint'. Being inherently disjointed implies that at any instance, only one of the conditions can be met; hence one of the statements is executed. The long list of statements is basically all of the instructions that are a part of the FALCON-A instruction set, and the condition for their execution is related to the operation code of the instruction fetched. We will take a closer look at the entire list in our subsequent discussion. Notice that in the instruction execute phase, besides the long list of concurrent, disjoint instructions, there is also the instruction fetch or iF sequenced at the end. This implies that once one of the instructions from the list is executed, the instruction fetch is called to fetch the next instruction. As shown before, the instruction fetch will call the instruction execute after fetching a certain instruction, hence the instruction fetch-execute cycle continues.
Jump instructions: Some of the instructions listed for the instruction execution phase are jump instruction, as shown.
- If op-code is 20, the branch is taken unconditionally (the jump instruction).
(op<4..0>=20) : (cond : (PC β R[ra]+C2(sign extended)), - If the op-code is 16, the condition for branching is checked, and if the condition is being met, the branch is taken; otherwise it remains untaken, and normal program flow will continue.
(op<4..0>= 16) : (cond : (PC β PC+C2 (sign extended))
Arithmetic and Logical Instructions: Several instructions provide arithmetic and logical operations functionality.
- If op-code is 0, the instruction is 'add'. The values in register rb and rc are added and the result is stored in register ra.
(op<4..0>=0) : R[ra] β R[rb] + R[rc], - If op-code is 1, the instruction is addi; the immediate constant specified by the constant field C1 is sign extended and added to the value in register rb. The result is stored in the register ra.
(op<4..0>=1) : R[ra] βR[rb] + (11Ξ± C1<4>)Β© C1<4..0>, - For op-code 2, value stored in register rc is subtracted from the value stored in register rb, and the result is stored in register ra.
(op<4..0>=2) : R[ra] β R[rb] - R[rc], - If op-code is 3, the immediate constant C1 is sign-extended, and subtracted from the value stored in rb. Result is stored in ra.
(op<4..0>=3) : R[ra] β R[rb]- (11Ξ± C1<4>)Β© C1<4..0>, - For op-code 4, values of rb and rc register are multiplied and result is stored in the destination register.
(op<4..0>=4) : R[ra] β R[rb] * R[rc], - If the op-code is 5, contents of register rb are divided by the value stored in rc, result is concatenated with 0s, and stored in ra. The remainder is stored in R0.
(op<4..0>=5) : R[ra] β R[0] Β©R[rb]/R[rc],R[0] β R[0] Β©R[rb]%R[rc], - If op-code equals 8, bit-wise logical AND of rb and rc register contents is assigned to ra.
(op<4..0>=8) : R[ra] β R[rb] & R[rc], - If op-code equals 10, bit-wise logical OR of rb and rc register contents is assigned to ra.
(op<4..0>=10) : R[ra] β R[rb] ~ R[c], - For op-code 14, the contents of register specified by field rc are inverted (logical NOT is taken), and the resulting value is stored in register ra.
(op<4..0>=14) : R[ra] β ! R[rc],
Shift Instructions: The shift instructions are also a part of the instruction set for FALCON-A.
- If the op-code is 12, the contents of the register rb are shifted right N bits. N is the number specified in the constant field. The space that has been created due to the shift out of bits is filled with 0s through concatenation.
(op<4..0>=12) : R[ra]<15..0> β R [rb]<(15-N)..0>Β©(NΞ±0), - If op-code is 13, rb value is shifted left, and 0s are inserted in place of shifted out contents at the right side of the value. The result is stored in ra.
(op<4..0>=13) : R[ra]<15..0> β (NΞ±0)Β©R [rb]<(15)..N>, - For op-code 15, arithmetic shift right operation is carried out on the value stored in rb. The arithmetic shift right shifts a signed binary number stored in the source register to the right, while leaving the sign-bit unchanged. Note that Ξ± means replication, and Β© means concatenation.
(op<4..0>=15) : R[ra]<15..0> β NΞ±(R [rb]<15>)Β© (R [rb]<15..N>),
Data transfer instructions: Several of the instructions belong to the data transfer category.
- Op-code 29 specifies the load instruction, i.e. a memory location is referenced and the value stored in the memory location is copied to the destination register. The effective address of the memory location to be referenced is calculated by sign extending the immediate field, and adding it to the value specified by register rb.
(op<4..0>=29) : R[ra]β M[R[rb]+ (11Ξ± C1<4>)Β© C1<4..0>], - A value is stored back to memory from a register using the op-code 28. The effective address in memory where the value is to be stored is calculated in a similar fashion as the load instruction.
(op<4..0>=28) : M[R[rb]+ (11Ξ± C1<4>)Β© C1<4..0>] β R [ra], - The move instruction has the op-code 6. The contents of one register are copied to another register through this instruction.
(op<4..0>=6) : R[ra] β R[rb], - To store an immediate value (specified by the field C2 of the instruction) in a register, the op-code 7 is employed. The constant is first sign-extended.
(op<4..0>=7) : R[ra] β (8Ξ±C2<7>)Β©C2<7..0>, - If the op-code is 24, an input is obtained from a certain input device, and the input word is stored into register ra. The input device is selected by specifying its address through the constant C2.
(op<4..0>=24) : R[ra] β IO[C2], - If the op-code is 25, an output (the register ra value) is sent to an output device (where the address of the output device is specified by the constant C2).
(op<4..0>=25) : IO[C2] β R[ra],
Miscellaneous instructions: Some more instructions included in the FALCON-A are:
- The no-operation (nop) instruction, if the op-code is 21. This instructs the processor to do nothing.
(op<4..0>= 21) : , - If the op-code is 31, setting the run bit to 0 halts the processor.
(op<4..0>= 31) : Run β 0, Halt the processor (halt)
At the end of this concurrent list of instructions, there is an instruction i.F (the instruction fetch). Hence when an instruction is executed, the next instruction is fetched, and the cycle continues, unless the processor is halted.
); iF );
The EAGLE (Original version)
Another processor that we are going to study is the EAGLE. We have developed two versions of it, an original version, and a modified version that takes care of the limitations in the original version. The study of multiple processors is going to help us get thoroughly familiar with the processor design, and the various possible designs for the processor. However, note that these machines are simplified versions of what a real machine might look like.
Introduction
The EAGLE is an accumulator-based machine. It is a simple processor that will help us in our understanding of the processor design process. EAGLE is characterized by the following:
- Eight General Purpose Registers of the CPU. These are named R0, R1...R7. Each register is 16-bits in length.
- Two 16-bit system registers transparent to the programmer are the Program Counter (PC) and the Instruction Register (IR). (Being transparent to the programmer implies the programmer may not directly manipulate the values to these registers. Their usage is the same as in any other processor)
- Memory word size is 16 bits
- The available memory space size is 2ΒΉβΆ bytes
- Memory organization is 2ΒΉβΆ x 8 bits. This means that there are 2ΒΉβΆ memory cells, each one byte long.
- Memory is accessed in 16 bit words (i.e., 2 byte chunks)
- Little-endian byte storage is employed.
EAGLE: Notation
Let us take a look at the notation that will be employed for the study of the EAGLE.
Enclosing the register name in square brackets refers to register contents; for instance, R[3] means contents of register R3.
Enclosing the location address in square brackets, preceded by 'M', lets us refer to memory contents. Hence M[8] means contents of memory location 8.
As little endian storage is employed, a memory word at address x is defined as the 16 bits at address x+1 and x. For instance, the bits at memory location 9,8 define the memory word at location 8. So employing the special notation for 16-bit memory words, we have:
M [8]<15...0>:=M [9]Β©M [8]
Where Β© is used to represent concatenation.
EAGLE Features
The following features characterize the EAGLE.
- Instruction length is variable. Instructions are either 8 bits or 16 long, i.e., instruction size is either 8-bits or 16-bits.
- The instructions may have either one or two operands.
- The only way to access memory is through load and store instructions.
- Limited addressing modes are supported.
EAGLE: Instruction Formats
There are five instruction formats for the EAGLE. These are:
- Type Z Instruction Format: The Z format instructions are half-word (1 byte) instructions, containing just the op-code field of 8 bits.
- Type Y Instruction Format: The type Y instructions are also half-word. There is an op-code field of 5 bits, and a register operand field ra.
- Type X Instruction Format: Type X instructions are also half-word instructions, with a 2-bit op-code field, and two 3-bit operand register fields.
- Type W instruction format: The instructions in this type are 1-word (16-bit) in length. 8 bits are reserved for the op-code, while the remaining 8 bits form the constant (immediate value) field.
- Type V instruction format: Type V instructions are also 1-word instructions, containing an op-code field of 5 bits, an operand register field of 3 bits, and 8 bits for specifying a constant.
Encoding of the General Purpose Registers
The encoding for the eight GPRs is shown in the table. These binary codes are to be used in place of the 'place-holders' ra, rb in the actual instructions of the processor EAGLE.
Listing of EAGLE instructions with respect to instruction formats
Type Z: There are four type Z instructions:
- halt (op-code=250): This instruction halts the processor.
- nop (op-code=249): nop, or the no-operation instruction stalls the processor for the time of execution of a single instruction. It is useful in pipelining.
- init (op-code=251): This instruction is used to initialize all the registers, by setting them to 0.
- reset (op-code=248): This instruction is used to initialize the processor to a known state. In this instruction the control step counter is set to zero so that the operation begins at the start of the instruction fetch and besides this PC is also set to a known value so that machine operation begins at a known instruction.
Type Y: Seven instructions of the processor are of type Y. These are:
- add (op-code=11): The type Y add instruction adds register ra's contents to register R0. For example,
add r1. In the behavioral RTL, we show this asR[0] β R[1]+R[0]. - and (op-code=19): This instruction obtains the logical AND of the value stored in register specified by field ra and the register R0, and assigns the result to R0, as shown in the example:
and r5which is represented in RTL asR[0] β R[1]&R[0]. - div (op-code=16): This instruction divides the contents of register R0 by the value stored in the register ra, and assigns result to R0. The remainder is stored in the divisor register, as shown in example:
div r6. In RTL, this isR[0] β R[0]/R[6],R[6] β R[0]%R[6]. - mul (op-code=15): This instruction multiplies the values stored in register R0 and the operand register, and assigns the result to R0. For example:
mul r4. In RTL, we specify this asR[0] β R[0]*R[4]. - not (op-code=23): The not instruction inverts the operand register's value and assigns it back to the same register, as shown in the example:
not r6,R[6] β ! R[6]. - or (op-code=21): The or instruction obtains the bit-wise OR of the operand register's and R0's value, and assigns it back to R0. An example:
or r5,R[0] β R[0] ~ R[5]. - **sub