4 Bit Microprocessor Design Using Vhdl

A Project Report on 4 BIT MICROPROCESSOR DESIGN USING VHDL In partial fulfilment of the requirement for the award of th

Views 164 Downloads 0 File size 390KB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

A Project Report on

4 BIT MICROPROCESSOR DESIGN USING VHDL In partial fulfilment of the requirement for the award of the degree of Bachelor of Technology in

Information Technology Submitted by

Sanjona Mazumder Registration No.: 111040110160 Roll No.:10400211064 Prof. Kajari Sur Department of Information Technology Academic Year 2011-2015

Institute of Engineering & Management Gurukul, Y-12, Block -EP, Sector-V, Salt Lake Electronics Complex Kolkata - 700 091, West Bengal, India. Affiliated to

West Bengal University of Technology

BF-142, Bidhannagar, Sector- I, Kolkata-700064, West Bengal, India.

Page | 1

INDEX S.No. Topic No. 1. 1.1 1.2 1.3 2. 2.1 2.2 2.2.1 2.2.2 2.2.3 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 3. 3.1 3.2 3.2.1 3.2.2 4. 4.1. 4.2. 4.2.1 4.2.2. 4.2.3 4.2.4. 4.2.5. 4.3 5. 6.

Pg.

Introduction……………………………………………………………...............6 A brief history…………………………………………………….........................6 Components of a Microprocessor………………………………………………....8 Objectives.………………………………..…………………………….................8 Overview of Microprocessor……………………………………………………...9 Microprocessor: A brief overview………………………………………………..9 Basic elements of a Microprocessor………………………………………………11 Arithmetic Logic Unit…………………………………………………………….11 Register Array…………………………………………………………………….12 Control Unit……………………………………………………………………... 13 More microprocessor sub-components…………………………………………...15 Memory…………………………………………………………………………...15 Input/Output Ports………………………………………………………..………16 System Bus…………………………………………………………….... ………16 Address Bus……………………………………………………………... ………16 Data Bus………………………………………………………………….………17 Control Bus…………………………………………………………………….... 17 Overview of Xilinx and VHDL…………………………………………. ……... 18 Xilinx……………………………………………………………………………. 18 VHDL…………………………………………………………………………… 19 Advantages……………………………………………………………………….20 Benefits of using VHDL………………………………………………………… 21 4-bit Microprocessor Design……………………………………………………..24 Introduction………………………………………………………………………24 Function of blocks of VSM……………………………………………………... 25 Program Counter…………………………………………………………………25 Program memory………………………………………………………………... 25 Accumulator……………………………………………………………………...27 Register………………………………………………………………………...... 28 ALU……………………………………………………………………………... 31 Instructions Table……………………………………………………………….. 34 Results and Discussion………………………………………………………….. 35 Conclusion………………………………………………………………………. 44

Page | 2

ACKNOWLEDGEMENT

I would like to express my heartiest gratitude to my project supervisor Professor Dr. Mohuya Chakraborty and Prof. Kajari Sur for their invaluable advices and consecutive support which made the whole work possible. They taught and guided me on how to approach a difficult project topic with simple and neat ways. I wish to express my sincere thanks to all my teachers and my classmates for providing necessary information whenever required. It is also a great pleasure to thank all the members of Department of Information Technology, Institute of Engineering and Management, West Bengal University of Technology.

Page | 3

ABSTRACT The main objective of this project is to understand the basic architecture of microprocessor by designing a 4-bit microprocessor. Microprocessor is basically an electronic device that consists of arithmetic and logic unit (ALU) and control circuitry which are required to function as computer’s CPU. Microprocessor is an integrated circuit that interprets and executes the program instructions and behaves intelligently. The processor operates at a speed of the internal clock and the speed of the clock depends upon the no. of pulses per second. With each clock pulse, the processor performs the function that corresponds to the instruction.

Page | 4

The power of the processor can be calculated by no. of instructions executed per second. During the execution of instructions, data are stored temporarily in memory units called registers. The control signal is the electronic signals used for communication among various processor units during the execution of the instruction. With the advancement in integrated circuit technology the power of the processor has increased tremendously. Microprocessors are widely used in the embedded sector based on general purpose application and special purpose application. Microprocessors are used in instruments to make it intelligent using behavioral coding. The existing microprocessors, namely, Intel 8086/8088 and 80186/80286, Zilog Z8001/Z8002, Digital Equipment LSI 11, Motorola 6800, national Semiconductors NS 1600 are very complex in design and understanding the basic functionality is a great challenge. In order to understand the basic knowhow of the microprocessor architecture, a simplified approach has been adopted by designing a 4-bit microprocessor. The software used for designing and simulating is Xilinx 7.1i using VHDL. All the sub-circuits are connected together and tested and simulated. VHDL is a hardware description language. It is a language specifically developed to describe digital electronic hardware and its attributes. It is a flexible language and can be applied to many different design situations. Digital circuits captured using VHDL can be easily simulated are more likely to be synthesizable into multiple target technologies and can be archived for later modification and reuse. VHDL is commonly used to write text models that describe a logic circuit. A sincere effort has been made through this project to understand the functioning of a microprocessor. By adopting this approach, a foundation for building complex microprocessors with extended instruction set and a more powerful Arithmetic Logic Circuit in order to build a more attractive and sophisticated microprocessor. Page | 5

CHAPTER 1 INTRODUCTION 1.1

A brief history Early computers were made possible by the invention of the transistor in 1947.

The transistor transferred information to other transistors over a network of chemicals embedded in silicon. These connected circuits, or integrated circuit, were the technology required for the eventual creation of the microprocessor. As manufacturing technology evolved, more and more transistors could be placed on a single silicon

Page | 6

wafer, and each transistor's function -- whether it was a simple gate for information, for example, or a decoder -- could be more accurately assigned and mapped. In 1971, Intel introduced the first processor on a single wafer, or microprocessor. On this one processor, engineers Federico Faggin, Ted Hoff and Stanley Mazor, placed all the required circuitry for a computer's function. The Intel 4004, as it was called, brought down the cost to produce computers, as well as the size of each unit, which previously had to store hundreds, if not thousands, of individual silicon wafers. A microprocessor is one of the most central part of a modern personal computer or, in fact, any advanced computer device. It integrates the functions of a central processing unit the portion of a computer responsible for carrying out programmed instructions, onto a single integrated circuit that couples the important thinking devices of the machine with the electrical infrastructure needed to support them. Microprocessor design is able to integrate a tremendous amount of processing power in a very small space. Perhaps more than any other component of the modern computer, the microprocessor has a long history. The microprocessor revolution began with a bold and innovative approach in logic design pioneered by Intel engineer Ted Hoff. In 1969, Intel was primarily in the business of designing semiconductor memory. Intel introduced a 64 bit bipolar RAM chip that year. In the same year Intel received a contract from a Japanese company named Busicom to design a programmable computer. The programmable calculator was designed successfully with a general purpose logic device that can be programmed by storing necessary patterns of 0s and 1s in the memory. Intel introduced the name “microprocessor”. They invented the first 4-bit microprocessor as 4004. This is quickly replaced by the 8-bit microprocessor w 8008, which was in turn superseded by the Intel 8080. In the mid-1970s, the Intel 8080 was widely used in control applications and small computers also were designed using 8080 as the CPU. Within a few years after the emergence of the 8080, the Motorola 6800, the Zilog Z80, Page | 7

and the Intel 8085 microprocessors were developed as improvements over the 8080.The 8080 was designed with a different architecture and instruction set from 8080. In 1978 16-bit chip 8086 was introduced and in 1979, the cheaper version of 8086, 8088 was invented by Intel. There were so many 16 bit chips such as Intel 80186, 80188, 80286. In 1986 the 32-bit chip 80386 was introduced that could address 4 GB memory. Intel 80486, Intel Pentium, Intel Pentium Pro , Pentium II Pentium III, Intel Dual Core were also a 32-bit microprocessor. In 2006 Intel Core 2 was introduced which was a 64-bit processor. Its clock speed was 1.2GHZ to 3 GHZ. It was launched in three different versions, Intel Core 2 Duo, Intel Core 2 Quad and Intel Core 2 Extreme. Intel Core i7, Intel Core i5 , Intel Corei3 were also 64 bit processor.

1.2

Components of a microprocessor The microprocessor system can be represented with the following components: (a) Microprocessor (b) Memory (c) Input/Output These three components work together to perform a given task and hence they

comprise a system. They are organized around a common communication path called a Bus. The components are referred to as subsystems and the entire group of components is referred to as a system. The physical components are known as hardware and a set of instructions written for the microprocessor to perform a atsk is caked a program and the group of programs is known as software. The microprocessor operates in the binary numbers 0 and 1 called bits. Each processor has a fixed set of instructions in the form of binary patterns called machine language. There are two categories of microprocessor applications, namely, reprogrammable systems and embedded systems. In reprogrammable systems, microprocessor is used for computing and data processing whereas in embedded Page | 8

systems the microprocessor is a part of a final product and is not available for programming to end users.

1.3

Objectives The objective of this project is to design a 4-bit microprocessor rby using

VHDL (Very High Speed Integrated Circuit Hardware Description Language). This microprocessor has the basic instruction that has been explained in the Microprocessor subject. This design uses VHDL as a hardware description language. Based on available resources, limited time frame and expertise, this research project is narrowed down to the following scope of work:  This project includes the design of 4-bit microprocessor  Its components using VHDL and collecting the simulation result  Analysis of the simulated result of 4-bit microprocessor.

CHAPTER 2 OVERVIEW OF MICROPROCESSOR 2.1

Microprocessor: A brief overview A microprocessor is programmable device that accepts digital data as input,

processes it according to the instruction stored in its memory and provides results as output. It can be viewed as a programmable logic device that can be used to control processes or to turn on/off devices. The Microprocessor can be viewed as a data processing unit or a computing unit of a computer. It has computing and decisionmaking capability similar to that of the central processing unit of a computer. Nowadays, the microprocessor is being used in a wide range of products called microprocessor-based products or systems. VHDL language is a general purpose Page | 9

language and this language has various features. The main aim of this project is to tie all of these features together to design a small CPU, verify its functionality that it can be synthesized. A central processing unit (CPU) is the electronic circuitry within a computer that carries out the instructions of a computer program by performing the basic arithmetic, logical, control and input/output (I/O) operations specified by the instructions. The term has been used in the computer industry at least since the early 1960s.[1] Traditionally, the term "CPU" refers to a processor and its control unit (CU), distinguishing these core elements of a computer from external components such as main memory and I/O circuitry. Most modern CPUs are microprocessors, meaning they are contained on a single integrated circuit (IC) chip. An IC that contains a CPU may also contain memory, peripheral interfaces, and other components of a computer; such integrated devices are variously called microcontrollers or systems on a chip (SoC). Some computers employ a multi-core processor, which is a single chip containing two or more CPUs called "cores"; in that context, single chips are sometimes referred to as "sockets".Array processors or vector processors have multiple processors that operate in parallel, with no unit considered central.

CENTRAL PROCESSOR INPUT

ALU

CU

OUTPUT

MEMORY UNIT RAM CACHE

ROM

Page | 10

STORAGE Fig 2.1: Block diagram of CPU

2.2

Basic elements of a microprocessor The basic elements of a microprocessor are:

Arithmetic Register Logic Array Unit

Page | 11

Fig 2.2: Basic elements of a microprocessor

2.2.1

Arithmetic Logic Unit The ALU is the fundamental building block of the central processing unit of a

computer. Depending on how the ALU is designed it can make the CPU more powerful. It performs a number of arithmetic and logical operations such as add and subtract and some logical operations such as AND, OR, and XOR .

Fig 2.3: ALU Interface

This is the symbol of an ALU. Inputs a and b are the two input busses upon which the ALU operations are performed. Output bus c returns the result of the ALU operation. Input select (sel) determines which of the arithmetic or logical operations operation is performed.

Page | 12

2.2.2

Register Array The regarray segment is used to form the set of registers within the CPU that

are used to store intermediate values during instruction process.

Fig 2.4: RegArray Symbol

To write a location in the regarray, set input sel (select) to the location to be written, input data with the data to be written, and put a rising edge on the input clk (clock). To read a location from regarray, set input sel to the location to be read and set input en to a ‘1’; the data is output on port q.

2.2.3

Control Unit

Page | 13

The control block supplies the necessary signal to make the data flow properly through the CPU and perform the expected functions. In the program the architecture contains a state machine that causes all appropriate signal values to update based on the current state and input signals and produce a next state for the state machine. The control has a few inputs and a lot of outputs.

Fig 2.5: Control Symbol

The control block provides all of the control signals to regulate data traffic for the CPU. The control block is a very large state machine that contains a number of states

Page | 14

for each instruction. Executing all of the states for an instruction performs the necessary steps to complete the instruction.

2.3

More microprocessor sub-components

2.3.1

Memory In computing, memory refers to the devices used to store information for use in

a computer. The term primary memory is used for storage systems which functions at a high-speed (i.e. RAM), as a distinction from secondary memory, which provides program and data storage that is slow to access but offers higher memory capacity. Random Access Memory is the same as main memory. When used by itself, the term RAM refers to read and write memory; that is, you can both write data into RAM and read data from RAM. This is in contrast to ROM, which permits you only to read data. Most RAM is volatile, which means that it requires a steady flow of electricity to maintain its contents. As soon as the power is turned off, whatever data was in RAM is lost. Computers almost always contain a small amount of read-only memory (ROM) that holds instructions for starting up the computer. Unlike RAM, ROM cannot be written to. In a memory chip, all registers are arranged in a sequence and identified by binary numbers called memory addresses. To communicate with memory, the microprocessor unit should be able to select the chip and then identify the register and then read from or write into the register. The microprocessor unit uses its address bus to send the address of a memory register and uses the data bus and control lines to read from or write into that register. Page | 15

2.3.2

Input and Output Ports Input and output ports are the physical interfaces through which the

microprocessor communicates with the outside world. The microprocessor unit accepts binary data as input from devices such as keyboards and A/D converters and sends data to outside devices such as LEDs or printers.

2.3.3

System Bus The system bus is a communication path between the microprocessor and

peripherals. It is a group of wires to carry bits. These buses are classified into the address bus, the data bus and the control bus. All the peripherals and memory share the same bus.

2.3.4

Address Bus The address bus is unidirectional. The bits flow in one direction from the

microprocessor unit to the peripheral devices. The microprocessor unit uses the address bus to perform the first function that is identifying a peripheral or a memory location. Most 8-bit microprocessors have 16 address lines. The number of address lines is arbitrary, it is determined by the designer of a microprocessor based on such considerations as availability of pins and intended applications of the processor. Page | 16

2.3.5

Data bus The data bus is a group of lines used for data flow. These lines are

bidirectional. The data flows in both directions between the microprocessor unit and memory and peripheral devices. The microprocessor unit uses the data bus to perform the second function that is transferring binary information. The 8 data lines in case of 8085 enable the microprocessor unit to manipulate 8-bit ranging from 00 to ff. So 8085 is known as an b-bit microprocessor and Motorola 68000 and Zilog Z8000 are known as 16-bit microprocessors.

2.3.6

Control Bus The control bus comprises of various single lines that carry synchronization

signals. The microprocessor unit uses such lines to perform the third function that is providing timing signals.

Page | 17

CHAPTER 3 OVERVIEW OF XILINX AND VHDL 3.1

Xilinx Xilinx ISE (Integrated Synthesis Environment) is a software tool produced

by Xilinx for synthesis and analysis of HDL designs, enabling the developer to synthesize ("compile") their designs, perform timing analysis, examine RTL diagrams, simulate a design's reaction to different stimuli, and configure the target device with the programmer. The Xilinx ISE is a design environment for FPGA products from Xilinx, and is tightly-coupled to the architecture of such chips, and cannot be used with FPGA products from other vendors. The Xilinx ISE is primarily used for circuit synthesis and design, while the ModelSim logic simulator is used for system-level testing. Other components shipped with the Xilinx ISE include the Embedded Development Kit (EDK), a Software Development Kit (SDK) and ChipScope Pro. The primary user interface of the ISE is the Project Navigator, which includes the design hierarchy (Sources), a source code editor (Workplace), an output console (Transcript), and a processes tree (Processes). The Design hierarchy consists of design files (modules), whose dependencies are interpreted by the ISE and displayed as a tree structure. For single-chip designs there may be one main module, with other modules included by the main module,

Page | 18

similar to themain() subroutine in C++ programs. Design constraints are specified in modules, which include pin configuration and mapping. The Processes hierarchy describes the operations that the ISE will perform on the currently active module. The hierarchy includes compilation functions, their dependency functions, and other utilities. The window also denotes issues or errors that arise with each function. The Transcript window provides status of currently running operations, and informs engineers on design issues. Such issues may be filtered to show Warnings, Errors, or both. System-level testing may be performed with the ModelSim logic simulator, and such test programs must also be written in HDL languages. Test bench programs may include simulated input signal waveforms, or monitors which observe and verify the outputs of the device under test. ModelSim may be used to perform the following types of simulations: 

Logical verification, to ensure the module produces expected results



Behavioural verification, to verify logical and timing issues



Post-place & route simulation, to verify behaviour after placement of the module within the reconfigurable logic of the FPGA 

Xilinx's patented algorithms for synthesis allow designs to run up to 30% faster than competing programs and allows greater logic density which reduces project costs.



Also, due to the increasing complexity of FPGA fabric, including memory blocks and I/O blocks, more complex synthesis algorithms were developed that separate unrelated modules into slices, reducing post-placement errors.



IP Cores are offered by Xilinx and other third-party vendors, to implement system-level functions such as digital signal processing (DSP), bus interfaces, networking protocols, image processing, embedded processors, and

Page | 19

peripherals. Xilinx has been instrumental in shifting designs from ASIC-based implementation to FPGA-based implementation.

3.2

VHDL VHDL is a hardware description language. It is a language specifically

developed to describe digital electronic hardware and its attributes. It is a flexible language and can be applied to many different design situations. Digital circuits captured using VHDL can be easily simulated are more likely to be synthesizable into multiple target technologies and can be archived for later modification and reuse. VHDL is commonly used to write text models that describe a logic circuit. Such a model is processed by a synthesis program, only if it is part of the logic design. A simulation program is used to test the logic design using simulation models to represent the logic circuits that interface to the design. This collection of simulation models is commonly called a test bench. We have already mentioned that, we have used VHDL for our project. VHDL was first developed in 1980 at US, to describe structure and function of an IC. Then it was adopted and developed by IEEE. VHDL has mainly four styles for coding:   

3.2.1

Dataflow Behavioral Structural Mixed

Advantages

i> The key advantage of VHDL, when used for systems design, is that it allows the behavior of the required system to be described (modelled) and verified (simulated) before synthesis tools can translate the design into hardware.

Page | 20

ii> Another benefit is that VHDL allows the description of a concurrent system. VHDL is a dataflow language, unlike procedural computing languages such as BASIC, C, and assembly code, which all run sequentially, one instruction at a time. iii> VHDL project is multipurpose. Being created once, a calculation block can be used in many other projects. Also, many formational and functional block parameters can be tuned (capacity parameters, memory size, element base, block composition and interconnection structure). iv> VHDL project is portable. Being created for one element base, a computing device project can be ported on another element base, for example VLSI with various technologies.

3.2.2

Benefits of using VHDL VHDL is a general-purpose programming language optimized for electronic

circuit design. As such, there are many points in the overall design process at which VHDL can help. For design specification This is particularly useful for large projects involving many team members. Using a top-down approach to design, a system designer may define the interface to each component in the system, and describe the acceptance requirements of those components in the form of a high level test bench. The interface definition (typically expressed as a VHDL entity declaration) and high-level performance specification (the test bench) can then be passed on to other team members for completion or refinement.

Page | 21

For design capture Design capture is that phase in which the details of the system are entered (captured) in a computer-based design system. In this phase, design may be expressed as schematics (either board-level or purely functional) or using VHDL descriptions. The design capture phase may include tools and design entry methods other than VHDL. In many cases, design descriptions written in VHDL are combined with other representations, such as schematics, to form the complete system. For design simulation Once entered into a computer-based design system, if someone want to simulate the operation of the circuit to find out if it will meet the functional and timing requirements developed during the specification process. If one or more test benches are created as a part of the design specification, then a simulator is used to apply the test bench to the design as it is written for synthesis (a functional simulation) and possibly using the post-synthesis version of the design as well. For design documentation The structured programming features of VHDL, coupled with its configuration management features, make VHDL a natural form in which to document a large and complex circuit. The value of using a high-level language such as VHDL for design documentation is pointed out by the fact that the U.S. Department of Defense now requires VHDL as the standard format for communicating design requirements between government subcontractors. As an alternative to schematics Schematics have long been a part of electronic system design, and it is unlikely that they will become extinct anytime soon. Schematics have their advantages, Page | 22

particularly when used to depict circuitry in block diagram form. For this reason many VHDL design tools now offer ability to combine schematic and VHDL representations in a design.

Design Flow in VHDL In VHDL design flow is composed of 3 steps:

1. Coding 2. Simulation 3. Synthesis

Fig 3.1: Design flow in VHDL

Coding: The phase in which VHDL code is written. Designer may write the code from scratch or use IDE to make some of the code to be written by wizards. Simulation: In this phase the prepared VHDL code is tested before downloading to the FPGA. By simulation possible errors are minimized. Page | 23

Synthesis: In this phase, the VHDL code is translated to hardware, i.e. converted to RTL. This process is carried on by the synthesizers. But if you wish you can do it manually which would require advanced knowledge and heavy work for large designs.

CHAPTER 4 4-BIT MICROPROCESSOR DESIGN 4.1

Introduction This chapter gives an insight in to the microprocessor architecture. The goal of

the project is to build a 4-bit processor at logic level and then simulate the processor at layout level. The very simple 4-bit microprocessor is an updated version of the popular Simple As Possible (SAP) computer architecture proposed by Albert P Malvino in 1993 in his famous book “Digital Computer Electronics”. The Very Simple Microprocessor (VSM) computer introduces the basic concepts of microprocessor architecture in the simplest possible way. The VSM is primitive but already quite complex. Fig 4.1: VSM basic architecture Internal Bus

Clock

Controller

Clear

Accumulat or A Arithmetic Unit

Enable signals

Accumulat or Page B | 24

Latch signals

Program Counter

4.2

Function of blocks of VSM

Program Memory

Input register

Output register

4.2.1 Program Counter: A program counter is a register in a computer processor that contains the address (location) of the instruction being executed at the current time. As each instruction gets fetched, the program counter increases its stored value by 1. In most processors, the PC is incremented after fetching an instruction, and holds the memory address of ("points to") the next instruction that would be executed. (In a processor where the incrementation precedes the fetch, the PC points to the current instruction being executed.) Instructions are usually fetched sequentially from memory, but control transfer instructions change the sequence by placing a new value in the PC. These include branches (sometimes called jumps), subroutine calls, and returns. A transfer that is conditional on the truth of some assertion lets the computer follow a different sequence under different conditions. A branch provides that the next instruction is fetched from somewhere else in memory. A subroutine call not only branches but saves the preceding contents of the PC somewhere. A return retrieves the saved contents of the PC and places it back in the PC, resuming sequential execution with the instruction following the subroutine call.

4.2.2

Program Memory: Program (CODE) memory is read only; it cannot be

written to. Program memory may reside within the 8051 MCU, it may be external, or it may be both, depending upon the 8051 derivative and the hardware design. Page | 25



The 8051 architecture supports up to 64K Bytes of program memory. However, program space can be expanded using code banking.



Some devices offer a larger code space.



Program code, including all functions and library routines, is stored in program memory.



Constant variables may also be stored in program memory.



The 8051 executes programs stored in program memory only.



Program memory may be accessed from your C programs using the code memory type specifier. Internal data memory resides within the 8051 MCU and is read/write. Up to 256

bytes of internal data memory are available depending upon the 8051 derivative. The first 128 bytes of internal data memory are both directly and indirectly addressable. The upper 128 bytes of data memory (from 0x80 to 0xFF) can be addressed only indirectly (this address space, when accessed directly, is mapped to SFRs). There is also a 16 byte area starting at 20h that is bit-addressable. Access to internal data memory is very fast because it can be accessed using an 8bit address. However, internal data memory is limited to a maximum of 256 bytes. Internal data can be broken down into three distinct memory types: data, idata, and bdata. 

The data memory specifier always refers to the first 128 bytes of internal data memory. Variables stored here are accessed using direct addressing.



The idata memory specifier refers to all 256 bytes of internal data memory; however, this memory type specifier code is generated by indirect addressing which is slower than direct addressing.



The bdata memory specifier refers to the 16 bytes of bit-addressable memory in the internal data area (20h to 2Fh). This memory type specifier allows you to declare data types that may also be accessed at the bit level.

Page | 26

External data memory is read/write. Since external data memory is indirectly accessed through a data pointer register (which must be loaded with an address), it is slower than access to internal data memory. Several 8051 devices provide on-chip XRAM space that is accessed with the same instructions as the traditional external data space. This XRAM space is typically enabled via dedicated chip configuration SFR registers and overlaps the external memory space. There may be up to 64K Bytes of external data memory; though, this address space does not necessarily have to be used as memory. Your hardware design may map peripheral devices into the memory space. If this is the case, your program would access external data memory to program and control the peripheral. This technique is referred to as memory-mapped I/O. The C51 Compiler offers two memory types that access external data: xdata and pdata. The xdata memory specifier refers to any location in the 64K Byte address



space of external data memory. The large memory model locates variables in this memory space. The pdata memory type specifier refers to exactly one (1) page (256 bytes) of



external data memory. Thecompact memory model locates variables in this memory space.

4.2.3

Accumulator

In a computer's central processing unit (CPU), an accumulator is a register in which intermediate arithmetic and logic results are stored. Without a register like an accumulator, it would be necessary to write the result of each calculation (addition, multiplication, shift, etc.) to main memory, perhaps only Page | 27

to be read right back again for use in the next operation. Access to main memory is slower than access to a register like the accumulator because the technology used for the large main memory is slower (but cheaper) than that used for a register. Early electronic computer systems were often split into two groups, those with accumulators and those without. Modern computer systems often have multiple general purpose registers that operate as accumulators, and the term is no longer as common as it once was. However, a number of special-purpose processors still use a single accumulator for their work, in order to simplify their design. Modern CPUs are typically 2-operand or 3-operand machines. The additional operands specify which one of many general purpose registers (also called "general purpose accumulators"[1]) are used as the source and destination for calculations. These CPUs are not considered "accumulator machines". The characteristic which distinguishes one register as being the accumulator of a computer architecture is that the accumulator (if the architecture were to have one) would be used as an implicit operand for arithmetic instructions. For instance, a CPU might have an instruction like: ADD memaddress that adds the value read from memory locationmemaddress to the value in the accumulator, placing the result back in the accumulator. The accumulator is not identified in the instruction by a register number; it is implicit in the instruction and no other register can be specified in the instruction. Some architectures use a particular register as an accumulator in some instructions, but other instructions use register numbers for explicit operand specification.

4.2.4

Register In computer architecture, a processor register is a small amount

of storage available as part of a digital processor, such as a central processing unit (CPU). Such registers are typically addressed by mechanisms other than main memory and can be accessed faster. Almost all computers, load-store architecture or Page | 28

not, load data from a larger memory into registers where it is used for arithmetic, manipulated or tested by machine instructions. Manipulated data is then often stored back into main memory, either by the same instruction or a subsequent one. Modern processors use either static or dynamic RAM as main memory, with the latter usually accessed via one or more cache levels. Processor registers are normally at the top of the memory hierarchy, and provide the fastest way to access data. The term normally refers only to the group of registers that are directly encoded as part of an instruction, as defined by the instruction set. However, modern high-performance CPUs often have duplicates of these "architectural registers" in order to improve performance via register renaming, allowing parallel and speculative execution. Modern x86 design acquired these techniques around 1995 with the releases ofPentium Pro, Cyrix 6x86, Nx586, and AMD K5. A common property of computer programs is locality of reference, which refers to accessing the same values repeatedly and holding frequently used values in registers to improve performance; this is what makes fast registers and caches meaningful. Allocating frequently used variables to registers can be critical to a program's performance; thisregister allocation is performed either by a compiler in the code generation phase, or manually by an assembly language programmer. Registers are normally measured by the number of bits they can hold, for example, an "8-bit register" or a "32-bit register". A processor often contains several kinds of registers, that can be classified according to their content or instructions that operate on them: User-accessible registers – instructions that can be read or written by machine



instructions. The most common division of user-accessible registers is into data registers and address registers. 

Data registers can hold numeric values such as integer and, in some architectures, floating-point values, as well as characters, small bit arrays and

Page | 29

other data. In some older and low end CPUs, a special data register, known as the accumulator, is used implicitly for many operations. Address registers hold addresses and are used by instructions that



indirectly access primary memory. Some processors contain registers that may only be used to hold



an address or only to hold numeric values (in some cases used as an index register whose value is added as an offset from some address); others allow registers to hold either kind of quantity. A wide variety of possible addressing modes, used to specify the effective address of an operand, exist. The stack pointer is used to manage the run-time stack. Rarely,



other data stacks are addressed by dedicated address registers, see stack machine. 

General purpose registers (GPRs) can store both data and addresses, i.e., they are combined Data/Address registers and rarely the register file is unified to include floating point as well.



Conditional registers hold truth values often used to determine whether some instruction should or should not be executed.



Floating point registers (FPRs) store floating point numbers in many architectures.



Constant registers hold read-only values such as zero, one, or pi.



Vector registers hold data for vector processing done by SIMD instructions (Single Instruction, Multiple Data).



Special purpose registers (SPRs) hold program state; they usually include the program counter, also called the instruction pointer, and the status register; the program counter and status register might be combined in a program status word (PSW) register. The aforementioned stack pointer is Page | 30

sometimes also included in this group. Embedded microprocessors can also have registers corresponding to specialized hardware elements. In some architectures, model-specific registers (also called machine-



specific registers) store data and settings related to the processor itself. Because their meanings are attached to the design of a specific processor, they cannot be expected to remain standard between processor generations. Memory Type Range Registers (MTRRs)



Internal registers – registers not accessible by instructions, used internally for



processor operations. 

Instruction register, holding the instruction currently being executed.



Registers related to fetching information from RAM, a collection of storage registers located on separate chips from the CPU: 

Memory buffer register (MBR)



Memory data register (MDR)



Memory address register (MAR)

Hardware registers are similar, but occur outside CPUs. In some architectures, such as SPARC and MIPS, the first or last register in the integer register file is a pseudo-register in a way that it is hardwired to always return zero when read (mostly to simplify indexing modes), and it cannot be overwritten. In Alpha this is also done for the floating-point register file. As a result of this, register files are commonly quoted as having one register more than how many of them are actually usable; for example, 32 registers are quoted when only 31 of them fit within the above definition of a register.

4.2.5

Arithmetic Logic Unit

Page | 31

An arithmetic logic unit (ALU) is a digital circuit used to perform arithmetic and logic operations. It represents the fundamental building block of the central processing unit (CPU) of a computer. Modern CPUs contain very powerful and complex ALUs. In addition to ALUs, modern CPUs contain a control unit (CU). Most of the operations of a CPU are performed by one or more ALUs, which load data from input registers. A register is a small amount of storage available as part of a CPU. The control unit tells the ALU what operation to perform on that data and the ALU stores the result in an output register. The control unit moves the data between these registers, the ALU and memory. An ALU performs basic arithmetic and logic operations. Examples of arithmetic operations are addition, subtraction, multiplication, and division. Examples of logic operations are comparisons of values such as NOT, AND, and OR. All information in a computer is stored and manipulated in the form of binary numbers, i.e. 0 and 1.Transistor switches are used to manipulate binary numbers, since there are only two possible states of a switch: open or closed. An open transistor, through which there is no current, represents a 0. A closed transistor, through which there is a current, represents a 1. Operations can be accomplished by connecting multiple transistors. One transistor can be used to control a second one, in effect turning the transistor switch on or off depending on the state of the second transistor. This is referred to as a gate, because the arrangement can be used to allow or stop a current. An arithmetic-logic unit (ALU) is the part of a computer processor (CPU) that carries out arithmetic and logic operations on the operands in computer instruction words. In some processors, the ALU is divided into two units, an arithmetic unit (AU) and a logic unit (LU). Some processors contain more than one AU - for example, one for fixed-point operations and another for floating-point operations. (In personal computers floating point operations are sometimes done by a floating point unit on a separate chip called a numeric coprocessor.)

Page | 32

Typically, the ALU has direct input and output access to the processor controller, main memory (random access memory or RAM in a personal computer), and input/output devices. Inputs and outputs flow along an electronic path that is called a bus. The input consists of an instruction word (sometimes called a machine instruction word) that contains an operation code (sometimes called an "op code"), one or more operands, and sometimes a format code. The operation code tells the ALU what operation to perform and the operands are used in the operation. (For example, two operands might be added together or compared logically.) The format may be combined with the op code and tells, for example, whether this is a fixed-point or a floating-point instruction. The output consists of a result that is placed in a storage register and settings that indicate whether the operation was performed successfully. (If it isn't, some sort of status will be stored in a permanent place that is sometimes called the machine status word.) In general, the ALU includes storage places for input operands, operands that are being added, the accumulated result (stored in an accumulator), and shifted results. The flow of bits and the operations performed on them in the subunits of the ALU is controlled by gated circuits. The gates in these circuits are controlled by a sequence logic unit that uses a particular algorithm or sequence for each operation code. In the arithmetic unit, multiplication and division are done by a series of adding or subtracting and shifting operations. There are several ways to represent negative numbers. In the logic unit, one of 16 possible logic operations can be performed - such as comparing two operands and identifying where bits don't match. The design of the ALU is obviously a critical part of the processor and new approaches to speeding up instruction handling are continually being developed.

Page | 33

4.3

Instructions Table

INSTRUCTION MOVA Rd MOVR Rd LOAD Mem LOADI Imm STORE Mem JZ Address

OPCODE 0000 0001 0010 0011 0100 0101|0000

JMP Address ADD Rd ANDR Rd

0110|0000 0111 1001

INV SHR SUB Rd

1011|0000 1010|0000 1000

FUNCTION Accumulator=Register Register=Accumulator Accumulator=Memory Accumulator=Immediate Memory=Accumulator If (Acc==0) PC=Address //goto address Else NOP //do nothing PC=Address Accumulator=Accumulator+Register Accumulator= Accumulator AND Register Accumulator= NOT Accumulator Accumulator=Accumulator>>1 Accumulator=Accumulator-Register Page | 34

HALT

1111|1111

Stop execution

The OPCODE and ADDRESS are both 4 bits wide. This would mean we would have a datapath that is only 4 bits. This is true. The input of the datapath (Data Memory) and output is only 4-bits wide. This means the ALU and registers are also 4-bits wide.

CHAPTER 5 RESULTS AND DISCUSSION Accumulator: In a computer's central processing unit (CPU), an accumulator is a register in which intermediate arithmetic and logic results are stored. Without a register like an accumulator, it would be necessary to write the result of each calculation (addition, multiplication, shift, etc.) to main memory, perhaps only to be read right back again for use in the next operation. Access to main memory is slower than access to a register like the accumulator because the technology used for the large main memory is slower (but cheaper) than that used for a register. Early electronic computer systems were often split into two groups, those with accumulators and those without. In this design, we have 3 inputs, namely, “rst”, “clk”, “input” and “enb” which are reset, clock, input and enable, respectively and one output. Page | 35

If we set reset to 1, then output is “0000”. Else if clock is set to 1 then the output is same as that of the input. Otherwise, it remains 0.

The RTL diagram for Accumulator is:

The timing diagram for Accumulator is:

Page | 36

Register: In computer architecture, a processor register is a small amount of storage available as part of a digital processor, such as a central processing unit (CPU). Such registers are typically addressed by mechanisms other than main memory and can be accessed faster. Almost all computers, load-store architecture or not, load data from a larger memory into registers where it is used for arithmetic, manipulated or tested by machine instructions. Manipulated data is then often stored back into main memory, either by the same instruction or a subsequent one. Modern processors use either static or dynamic RAM as main memory, with the latter usually accessed via one or more cache levels. In this design, we have 5 inputs, namely, reset, clock, input, select and enable and one output. We have 4 signals, namely, out0, out1, out2 and out3. When clock event and clock are equal to “1” and enable is equal to “0” then we select a case using “sel”. Page | 37

For example, when “00” is selected by “sel” then out0