Microcontrollers in FPGAs Tomas Södergård University of Vaasa.

Slides:



Advertisements
Similar presentations
CPU Structure and Function
Advertisements

DSPs Vs General Purpose Microprocessors
Instruction Set Design
CPU Review and Programming Models CT101 – Computing Systems.
ISA Issues; Performance Considerations. Testing / System Verilog: ECE385.
1 Lecture 3: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation.
CS1104: Computer Organisation School of Computing National University of Singapore.
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
Computer Organization and Architecture
Microprocessor Design Nattha Jindapetch December 2008.
Processor System Architecture
Computer Organization and Architecture
Operand And Instructions Representation By Dave Maung.
6.1 Introduction Two details related to instructions –The way instructions are specified –The ways that operands can be specified.
Chapter 5 The Processor: Datapath and Control Basic MIPS Architecture Homework 2 due October 28 th. Project Designs due October 28 th. Project Reports.
FPGAs and VHDL Lecture L12.1. FPGAs and VHDL Field Programmable Gate Arrays (FPGAs) VHDL –2 x 1 MUX –4 x 1 MUX –An Adder –Binary-to-BCD Converter –A Register.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Topics covered: CPU Architecture CSE 243: Introduction to Computer Architecture and Hardware/Software Interface.
Computer ArchitectureFall 2007 © October 3rd, 2007 Majd F. Sakr CS-447– Computer Architecture.
State Machines Timing Computer Bus Computer Performance Instruction Set Architectures RISC / CISC Machines.
Computer ArchitectureFall 2008 © September 17th, 2008 Majd F. Sakr CS-447– Computer Architecture.
Henry Hexmoor1 Chapter 10- Control units We introduced the basic structure of a control unit, and translated assembly instructions into a binary representation.
Group 5 Alain J. Percial Paula A. Ortiz Francis X. Ruiz.
Operand Addressing and Instruction Representation
1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.
Atmega32 Architectural Overview
Machine Instruction Characteristics
Instruction Set Architecture
Multiple-bus organization
A Simple Computer Architecture Digital Logic Design Instructor: Kasım Sinan YILDIRIM.
Instruction Set Architecture The portion of the machine visible to the programmer Issues: Internal storage model Addressing modes Operations Operands Encoding.
Module : Algorithmic state machines. Machine language Machine language is built up from discrete statements or instructions. On the processing architecture,
Lec 15Systems Architecture1 Systems Architecture Lecture 15: A Simple Implementation of MIPS Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
1 COMP541 Multicycle MIPS Montek Singh Apr 4, 2012.
Operand Addressing And Instruction Representation Cs355-Chapter 6.
Computer Organization CDA 3103 Dr. Hassan Foroosh Dept. of Computer Science UCF © Copyright Hassan Foroosh 2002.
ALU (Continued) Computer Architecture (Fall 2006).
Instruction Sets: Addressing modes and Formats Group #4  Eloy Reyes  Rafael Arevalo  Julio Hernandez  Humood Aljassar Computer Design EEL 4709c Prof:
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
Chapter 3 Basic Processing Unit.
What is a program? A sequence of steps
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
BASIC COMPUTER ARCHITECTURE HOW COMPUTER SYSTEMS WORK.
“Atmega32 Architectural Overview” SIGMA INSTITUTE OF ENGINEERING Prepared By: SR.NO NAME OF STUDENT ENROLLMENT 1 Parihar Shipra A Guided By:-
Controller Implementation
STUDY OF PIC MICROCONTROLLERS.. Design Flow C CODE Hex File Assembly Code Compiler Assembler Chip Programming.
15-740/ Computer Architecture Lecture 3: Performance
Atmega32 Architectural Overview
ECE354 Embedded Systems Introduction C Andras Moritz.
A Closer Look at Instruction Set Architectures
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers The Processor
Processor Architecture: Introduction to RISC Datapath (MIPS and Nios II) CSCE 230.
A Closer Look at Instruction Set Architectures: Expanding Opcodes
Instructions at the Lowest Level
Rocky K. C. Chang 6 November 2017
Computer Organization
Vishwani D. Agrawal James J. Danaher Professor
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Introduction to Microprocessor Programming
ECE 352 Digital System Fundamentals
Single Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Addressing mode summary
Computer Architecture Assembly Language
Chapter 4 The Von Neumann Model
Presentation transcript:

Microcontrollers in FPGAs Tomas Södergård University of Vaasa

Contents Finite state machine Design of instructions Architecture Registry file Hardware aspects of MCUs Comparison of microcontrollers – Picoblaze, Nios II and Atmega328P Conclusions

Finite state machine Moore Machine – Output only dependent on current state (Pedroni: 2004: 159) Mealy Machine – Output dependent on current state and external input. Synchronisation (Zwolinski 2000: 82) – Clock – Reset Programmable state machine – General purpose FSM (Meyer-Baese 2007: 537, Chu 2008: )

Programmable state machine Control Data Memory ALU Program Memory

Instructions Operations ALU operations Add Mul Not Data move Move Push Pop Branch Compare Jump - Loop

Addressing modes “Addressing modes describe how the operands for an operation are located.” (Meyer-Baese 2007: 544) Implied addressing (Meyer-Baese 2007: ) – Location is implicitly defined – No operands in the instruction Immediate addressing (Meyer-Baese 2007: 546) – One operand in the instruction – The operand is a constant

Addressing modes Register addressing (Meyer-Baese 2007: 546–547) – Data is fetched from fast CPU registers – Used for ALU operations in most RISC machines Memory addressing (Meyer-Baese 2007: 547–549) – Direct addressing Additional register needed due to instruction size In base addressing the additional register contains a constant that is added to the constant in the instruction. In page addressing the additional register contain the most significant bits of the address. Full address is obtained by concatenation. – Indirect addressing The additional register contains the full address

Data flow An instruction contains at least one (the first) of the following: – Operation code – Operands – Result location Parameters affecting the instruction size – Number of operations – Number of operands – Memory size

Zero address CPU – Stack machine No operands in the instruction All operations are performed on the two top elements of the stack Code example: Push #5 Push #3 Add Pop Reg1 (Meyer-Baese 2007: )

One address CPU – Accumulator machine One operand in the instruction The second operand is the value of the accumulator The destination is the accumulator Code example Load #5 Add #3 Store Reg1 (Meyer-Baese 2007: )

Two address CPU The instruction contains two operands The destination of the result is the location of the first operand Code examples Move Reg1, #5Move Reg2, #5 Add Reg1, #3Move Reg1, #3 Add Reg1, Reg2 (Meyer-Baese 2007: 555)

Three address CPU The instruction contains three addresses Destination and sources can be specified separately Code examples Move Reg2, #5Add Reg1, #5, #3 Move Reg3, #3 Add Reg1,Reg2,Reg3 (Meyer-Baese 2007: )

Architecture Von Neumann Architecture – Shared data and program memory = One bus Harvard Architecture – Separate data and program memory = Two buses Super Harvard Architecture – Separate X and Y data memories and separate program memory = Three buses Fast cache registers for immediate results (Meyer-Baese 2007: 558) CPU Data & Program CPU Data Program CPU Data X Data Y Program

Registry file Two dimensional bit array Has a mechanism for storing data to the registry file Has a mechanism for reading data from the registry file Consumes many logical elements in a FPGA – The registry file in the example discussed on the following pages is of size 8x16 and consumes 211 LEs (Meyer-Baese 2007: 560)

VHDL registry file example Entity declaration (Meyer-Baese 2007: 560) Entity reg_file IS generic (W: integer:=7; N: integer :=15); port(clk, reg_ena : in std_logic; data : in std_logic_vector(W downto 0); rd, rs, rt : in integer range 0 to 15; s, t : out std_logic_vector(W downto 0)); End;

VHDL registry file example Architecture: type declarations (Meyer-Baese 2007: 560) Architecture fpga of reg_file is subtype bitw is std_logic_vector(W downto 0); type SLV_NxW is array (0 to N) of bitw; signal r : SLV_NxW; Begin Mux: Process Begin wait until clk=’1’; if rd>0 then r(rd)<=data; end if; End Process Mux;

VHDL registry file example Architecture: Demux for outputs (Meyer-Baese 2007: 560) Demux: Process(r,rs,rt) Begin if rs>0 then s<=r(rs); else s ’0’); end if; if rt>0 then t<=r(rt); else t ’0’); end if; End Process Demux;

FSM vs PSM(Chu:2008:324) FSMPSM Special purposeGeneral purpose State registerProgram counter (PC) Generates certain output based on simple logic Generates outputs based on encoding and decoding Next state can be specified freelyNext state is normally an incrementation of the PC. Exceptions are branch instructions.

Structural aspects for FPGAs Harvard Architecture better for FPGA MCUs – Reason: Memory size more limited (and slower) Data flow (Meyer-Baese 2007: ) – A more complex instruction implies: Easier assembly programming More complicated C compiler development Longer instruction Fewer instructions needed Lower speed Larger constant is immediate addressing

Comparison of instructions ParameterPicoblazeNios IIAtmega328P ArchitectureHarvard Registry file16 x 8 bit32 x 32 bit32 x 8 bit Clk/instr Instr. count Data mem.64 B?2 kB Instr. width18 bit32 bit? LE count~200>700- Data flow2 address3 address2 address (Chu 2008: 323, , 329, Altera Nios II/e, Altera Nios II/f, Altera 2011: 3,11-12, Atmega328P: 1, 8, Moshovos 2007)

Recently developed MCU Article publiched in Semptember 2011 by Martin Shoeberl. Properties: – Name= Leros – 16 bit microcontroller – Accumulator machine/one address CPU – 200 LEs – 2 stage pipeline = fectch and decode – 2 clock cycles/instruction – Portable= Successfully tested in Altera and Xilinx devices – Assembly compiler available

Conclusions – Useful technology? Area optimisation – Algorithms like FFT may consume less resources, but will hence become slower. (Meyer-Baese 2007: 537) – Main purpose of FPGA technology is processing speed? Reuse of code – Controller and datpath partitioning (Zwolinski 2000: 160) – General vs special purpose state machine (Chu 2008: 324) Complexity – Moves some of the complexity of VHDL (or Verilog) to the compiler

Conclusions – Useful technology? Speed – No parallism anymore – Backwards development? Especially useful when: – Part of a larger circuit – Multi controller systems that perform simpler tasks

Sources Atmega 328P. 8-bit Microcontroller with 4/8/16/32K Bytes In-System Programmable Flash [online] [cited ] Available from Internet: URL AVR assembly. Beginner’s introduction to AVR assembler [online][cited ] Available from Internet: URL Altera Nios II (2011). Processor Architecture. [online][cited ] Altera Nios II/e Core. Economy. [online][cited ] URL: core.html

Sources Altera Nios II/f Core. Fast for Performance Critical Applications [online] [cited ]. URL: fast-core.html Chu, Pong P. (2007). FPGA Prototyping by VHDL Examples. Ohio: Wiley. Meyer-Baese, U. (1999). Digital Signal Processing with Field Programmable Gate Arrays. 3. Edition. Heidelberg: Springer. Moshovos, Andreas (2007). Using Assembly Language to Write Programs. [online] [cited ]. Available from Internet. URL: %20Intro%20to%20Assembly.htm

Sources Shoeberl, Martin (2011). Leros: A Tiny Microcontroller for FPGAs. Field Program- mable Logic and Applications (FPL), 2011 International Conference. 10–14. Zwolinski, Mark (2000). Digital System Design with VHDL. 2. Edition. Essex: Pearson Education Limited.