George Mason University ECE 448 – FPGA and ASIC Design with VHDL Experiment 7 VHDL Modeling of Embedded Microprocessors and Microcontrollers.

Slides:



Advertisements
Similar presentations
Computer Science Education
Advertisements

3-Software Design Basics in Embedded Systems
Chapter 3 General-Purpose Processors: Software
Control path Recall that the control path is the physical entity in a processor which: fetches instructions, fetches operands, decodes instructions, schedules.
Arithmetic Logic Unit (ALU)
331 W08.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 8: Datapath Design [Adapted from Dave Patterson’s UCB CS152.
The Processor: Datapath & Control
Execution of an instruction
Chapter 3 General-Purpose Processors: Software
General Purpose Processors: Software This Week In DIG II  Introduction  Basic Architecture  Operation  Programmer’s view (that would be you !) 
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ input/output and clock inputs Sequence of control signal combinations.
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 3 General-Purpose Processors: Software ECE 4330 Embedded System Design.
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 3 General-Purpose Processors: Software.
General Purpose Processors: Software. This Week In DIG II  Introduction  Basic Architecture  Memory  Programmer’s view (that would be you !)  Development.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 30: PIC data memory.
Microcontroller Architecture— PIC18F Family
General Purpose Processors: Software. This Week In DIG II  Introduction  Basic Architecture  Memory  Programmer’s view (that would be you !)  Development.
Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 4: IT Students.
Microcontroller Programming How to make something almost do something else Raffi Krikorian MAS November 2003.
Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
Basic Operational Concepts of a Computer
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Microprocessors.
Building Assembler Programs Chapter Five Dr. Gheith Abandah1.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
1 3-Software Design Basics in Embedded Systems. 2 Two Memory Architectures Processor Program memory Data memory Processor Memory (program and data) HarvardPrinceton.
Microprocessor and Interfacing PIC Code Execution
Lecture 15 VHDL Modeling of Microprocessors.
Chapter 14 Introduction to Microprocessors. 2 Microcomputer A self-contained computer system that consists of CPU (central processing unit), memory (RAM.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
Computer Architecture Lecture 09 Fasih ur Rehman.
1 3-Software Design Basics in Embedded Systems Optimizing the design of General Purpose processors.
Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 1 Basic Architecture Control unit and datapath –Note similarity.
Processor: Datapath and Control
Introduction to Computer Engineering CS/ECE 252, Fall 2009 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin – Madison.
A Simple Computer Architecture Digital Logic Design Instructor: Kasım Sinan YILDIRIM.
George Mason University ECE 449 – Computer Design Lab Welcome to the ECE 449 Computer Design Lab Spring 2005.
Computer Organization CSC 405 (VSC) Very Simple Computer.
ECE 448 – FPGA and ASIC Design with VHDL George Mason University Lab 1 Introduction to Aldec Active HDL Implementing Combinational Logic in VHDL.
Team DataPath Research Computer Architechture. PC and IF in the Processor.
COMPILERS CLASS 22/7,23/7. Introduction Compiler: A Compiler is a program that can read a program in one language (Source) and translate it into an equivalent.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Computer Organization and Assembly Languages Yung-Yu Chuang 2005/09/29
Features of the PIC18 microcontroller - 8-bit CPU - 2 MB program memory space (internal 32KB to 128KB) bytes to 1KB of data EEPROM - Up to 4096 bytes.
Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display.
Department of Electronic & Electrical Engineering Introduction to microcontrollers A microcontroller is a small computer on a single integrated circuit.
Department of Electronic & Electrical Engineering Lecture 2. PIC16F84A Architecture / Instructions Memory. Program/Data (Harvard) File Registers (Data).
Elements of Datapath for the fetch and increment The first element we need: a memory unit to store the instructions of a program and supply instructions.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
COM181 Computer Hardware Lecture 6: The MIPs CPU.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
1 3-Software Design Basics in Embedded Systems. 2 Two Memory Architectures Processor Program memory Data memory Processor Memory (program and data) HarvardPrinceton.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Department of Electronic & Electrical Engineering Lecture 3. ● Template program. ● Introduction to IO ● PORTA PORTB TRISA TRISB ● Using a subroutine ●
Programming PIC 16F84A in Assembly. PIC16F84 pin-out and required external components.
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ read/write and clock inputs Sequence of control signal combinations.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
3-Software Design Basics in Embedded Systems
ELEC 418 Advanced Digital Systems Dr. Ron Hayne
Chapter 3 General-Purpose Processors: Software
Processor (I).
The Processor Lecture 3.1: Introduction & Logic Design Conventions
Chapter 3 General-Purpose Processors: Software
Fundamental Concepts Processor fetches one instruction at a time and perform the operation specified. Instructions are fetched from successive memory locations.
COMS 361 Computer Organization
Chapter 3 General-Purpose Processors: Software
General Purpose Processor : Software
COMS 361 Computer Organization
Processor: Datapath and Control
Presentation transcript:

George Mason University ECE 448 – FPGA and ASIC Design with VHDL Experiment 7 VHDL Modeling of Embedded Microprocessors and Microcontrollers

George Mason University ECE 448 – FPGA and ASIC Design with VHDL Simple Microprocessor

3ECE 448 – FPGA and ASIC Design with VHDL Basic Architecture Control unit and datapath Note similarity to single-purpose processor Key differences Datapath is general Control unit doesn’t store the algorithm – the algorithm is “programmed” into the memory Processor Control unitDatapath ALU Registers IRPC Controller Memory I/O Control /Status Source: Vahid and Givargis, "Embedded System Design: A Unified Hardware/Software Introduction"

4ECE 448 – FPGA and ASIC Design with VHDL Instruction Cycles Processor Control unitDatapath ALU Registers IRPC Controller Memory I/O Control /Status load R0, M[500] inc R1, R0 101 store M[501], R1 102 R0R1 PC= Fetch ops Exec. Store results clk Fetch load R0, M[500] Decode 100 Source: Vahid and Givargis, "Embedded System Design: A Unified Hardware/Software Introduction"

5ECE 448 – FPGA and ASIC Design with VHDL Architectural Considerations Clock frequency Inverse of clock period Must be longer than longest register to register delay in entire processor Memory access is often the longest Processor Control unitDatapath ALU Registers IRPC Controller Memory I/O Control /Status Source: Vahid and Givargis, "Embedded System Design: A Unified Hardware/Software Introduction"

6ECE 448 – FPGA and ASIC Design with VHDL A Simple (Trivial) Instruction Set opcode operands MOV Rn, direct Rm ADD Rn, Rm 0000Rndirect 0010Rn 0100RmRn Rn = M(direct) Rn = Rn + Rm SUB Rn, Rm 0101Rm Rn = Rn - Rm MOV Rn, #immed. 0011Rnimmediate Rn = immediate Assembly instruct.First byteSecond byteOperation JZ Rn, relative 0110Rnrelative PC = PC+ relative (only if Rn is 0) Rn MOV direct, Rn 0001Rndirect M(direct) = Rn Rm M(Rn) = Rm Source: Vahid and Givargis, "Embedded System Design: A Unified Hardware/Software Introduction"

7ECE 448 – FPGA and ASIC Design with VHDL Addressing Modes Data Immediate Register-direct Register indirect Direct Indirect Data Operand field Register address Memory address Data Memory address Data Addressing mode Register-file contents Memory contents Source: Vahid and Givargis, "Embedded System Design: A Unified Hardware/Software Introduction"

8ECE 448 – FPGA and ASIC Design with VHDL Sample Program int total = 0; for (int i=10; i!=0; i--) total += i; // next instructions... C program MOV R0, #0; // total = 0 MOV R1, #10; // i = 10 JZ R1, Next; // Done if i=0 ADD R0, R1; // total += i MOV R2, #1; // constant 1 JZ R3, Loop; // Jump always Loop: Next:// next instructions... SUB R1, R2; // i-- Equivalent assembly program MOV R3, #0; // constant Source: Vahid and Givargis, "Embedded System Design: A Unified Hardware/Software Introduction"

9ECE 448 – FPGA and ASIC Design with VHDL Architecture of a Simple Microprocessor Storage devices for each declared variable register file holds each of the variables Functional units to carry out the FSMD operations One ALU carries out every required operation Connections added among the components’ ports corresponding to the operations required by the FSM Unique identifiers created for every control signal Datapath IRPC Controller (Next-state and control logic; state register) Memory RF (16) RFwa RFwe RFr1a RFr1e RFr2a RFr2e RFr1RFr2 RFw ALU ALUs 2x1 mux ALUz RFs PCld PCinc PCclr 3x1 mux Ms MweMre To all input control signals From all output control signals Control unit 16 Irld A D 1 0 Source: Vahid and Givargis, "Embedded System Design: A Unified Hardware/Software Introduction"

10ECE 448 – FPGA and ASIC Design with VHDL A Simple Microprocessor FSM operations that replace the FSMD operations after a datapath is created RFwa=rn; RFwe=1; RFs=01; Ms=01; Mre=1; RFr1a=rn; RFr1e=1; Ms=01; Mwe=1; RFr1a=rn; RFr1e=1; Ms=00; Mwe=1; RFwa=rn; RFwe=1; RFs=10; RFwa=rn; RFwe=1; RFs=00; RFr1a=rn; RFr1e=1; RFr2a=rm; RFr2e=1; ALUs=00 RFwa=rn; RFwe=1; RFs=00; RFr1a=rn; RFr1e=1; RFr2a=rm; RFr2e=1; ALUs=01 PCld= ALUz; RFrla=rn; RFrle=1; MS=10; Irld=1; Mre=1; PCinc=1; PCclr=1; Reset Fetch Decode IR=M[PC]; PC=PC+1 Mov1 RF[rn] = M[dir] Mov2 Mov3 Mov4 Add Sub Jz op = 0000 M[dir] = RF[rn] M[rn] = RF[rm] RF[rn]= imm RF[rn] =RF[rn]+RF[rm] RF[rn] = RF[rn]-RF[rm] PC=(RF[rn]=0) ?rel :PC to Fetch PC=0; from states below FSMD Datapath IRPC Controller (Next-state and control logic; state register) Memory RF (16) RFwa RFwe RFr1a RFr1e RFr2a RFr2e RFr1RFr2 RFw ALU ALUs 2x1 mux ALUz RFs PCld PCinc PCclr 3x1 mux Ms MweMre To all input contro l signals From all output control signals Control unit 16 Irld A D 1 0 You just built a simple microprocessor! Source: Vahid and Givargis, "Embedded System Design: A Unified Hardware/Software Introduction"

George Mason University ECE 448 – FPGA and ASIC Design with VHDL PIC Microcontroller

12ECE 448 – FPGA and ASIC Design with VHDL PIC Microcontroller implemented inside of an FPGA device PIC µController FPGA PORTB PORTA 7-Seg Decoder PORTA Display PORTC = PORTC(0)STROBE CLK RESET

13ECE 448 – FPGA and ASIC Design with VHDL PICROM 256 x 12 Data Addr PROGRAM PCPC Instruction Decoder W ALU COMPUTATIONS CONSTANTS OPCODES Address Bus Data Bus 8 8 CONTROL UNIT MCLRCLK EXTENDED ALU PORTAPORTBPORTC 488 DATA FSR DinDout REGFILE R8 R31 Fsel PIC Microcontroller Core

14ECE 448 – FPGA and ASIC Design with VHDL Set Port Directions RESET Sum <= ‘0’ Counter <= ‘0’ Wait for a rising edge at Port C(0) Port B <= Port A Sum <= Sum + Port A Counter <= Counter + 1 Counter = 8? N Y Wait for a rising edge at Port C(0) Port B <= Sum(3 downto 0) Wait for a rising edge at Port C(0) Port B <= Sum(7 downto 4) Flowchart of our PIC program

15ECE 448 – FPGA and ASIC Design with VHDL Selected Registers of PIC W PC PORTA ADDR Working Register (Accumulator) Program Counter PORTB PORTC R8 R9 R30 R31 1F Bidirectional Input/Output Ports Register File (General Purpose Registers) TRISA Direction Registers for Ports A, B & C TRISB TRISC      1E.... 0A R10

16ECE 448 – FPGA and ASIC Design with VHDL Selected PIC Instructions (1) MOVF f, d f W MOVF f, 0 MOVF f, 1 MOVWF f W f MOVLW k k W k  f 

17ECE 448 – FPGA and ASIC Design with VHDL Selected PIC Instructions (2) CLRF f f 0 CLRW W 0 f 

18ECE 448 – FPGA and ASIC Design with VHDL Selected PIC Instructions (3) INCF f, d f INCF f,1 +1 W INCF f,0

19ECE 448 – FPGA and ASIC Design with VHDL Selected PIC Instructions (4) ADDWF f, d W ADDWF f, 1 + f ADDWF f, 0

20ECE 448 – FPGA and ASIC Design with VHDL Selected PIC Instructions (5) ANDWF f, d W ANDWF f, 1 and f ANDWF f, 0

21ECE 448 – FPGA and ASIC Design with VHDL Selected PIC Instructions (6) SWAPF f, d SWAPF f, 0 f H f L W SWAPF f, 1

22ECE 448 – FPGA and ASIC Design with VHDL Selected PIC Instructions (7) CALL label label RETLW CALL label label GOTO label label

23ECE 448 – FPGA and ASIC Design with VHDL Selected PIC Instructions (8) BTFSC f, b b 7 0 f f(b) = 0? BTFSC f, b Yes No After-next Instruction Next instruction

24ECE 448 – FPGA and ASIC Design with VHDL Selected PIC Instructions (8) BTFSS f, b b 7 0 f f(b) = 1? BTFSS f, b Yes No After-next Instruction Next instruction

25ECE 448 – FPGA and ASIC Design with VHDL Selected PIC Instructions (9) TRIS f TRISB 8 TRISA 4 TRISC 8 W TRIS PORTA TRIS PORTB TRIS PORTC 1 – Input port bit direction 0 – Output port bit direction

26ECE 448 – FPGA and ASIC Design with VHDL MPASM *.ASM *.LST*.HEX MPSIM Source File in the PIC Assembly Language Listing FileHEX File PIC Programming Environment

27ECE 448 – FPGA and ASIC Design with VHDL Questions?