CDA 4253 FPGA System Design PicoBlaze Instruction Set Hao Zheng Comp Sci & Eng U of South Florida.

Slides:



Advertisements
Similar presentations
Lecture 16 PicoBlaze Instruction Set & Assembler Directives
Advertisements

The 8051 Microcontroller and Embedded Systems
PicoBlaze CPLD Microcontroller
COMP3221 lec08-arith.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 8: C/Assembler Data Processing
Slides to Accompany a Video Tutorial on Harry Porter’s Relay Computer Harry Porter, Ph.D. Portland State University November 7, 2007.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
8051 ASSEMBLY LANGUAGE PROGRAMMING
1 The Design of a Relay Computer Harry Porter, Ph.D. Portland State University April 24, 2006.
Architecture of the MSP430 Processor. Central Processing Unit Program Counter (PC) - Contains the address of the next instruction to be executed. The.
MIPS Instruction Set Advantages
Assembly & Machine Languages
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Programmers Model and Instruction Set.
Lab 1 – Assembly Language and Interfacing Start date: Week 3 Due date: Week 4 1.
ECE 447 Fall 2009 Lecture 5: TI MSP430 Software Development in C and Assembly pt. 2.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
© 2003 Xilinx, Inc. All Rights Reserved Advanced Features.
ADAM2 Single Remocon MCU IDE User’s Manual S/W Integrated Development Environment - Assembler - Simulator - Code Wizard V1.0 Technical Sales Team, ETA.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 7.
ECE 448 – FPGA and ASIC Design with VHDL Lecture 12 PicoBlaze Overview.
ECE 448 – FPGA and ASIC Design with VHDL Lecture 12 PicoBlaze Overview.
The FPX KCPSM Module Exercise 1 Henry Fu The FPX KCPSM Module Exercise: Network Data Encryption / Decryption Using ROT13 Algorithm Henry Fu Washington.
Execution of an instruction
Lecture Set 4 Programming the 8051.
ECE 448 – FPGA and ASIC Design with VHDL Lecture 19 PicoBlaze Interrupt Interface & Assembly Code Development.
1 The Instruction Set Architecture September 27 th, 2007 By: Corbin Johnson CS 146.
CDA 4253 FPGA System Design The PicoBlaze Microcontroller
ECE 448: Lab 6 Using PicoBlaze Fast Sorting. Part 1: Introduction to Lab 6 Part 2: Instruction Set of PicoBlaze-6 Part 3: Hands-on Session: OpenPICIDE.
Picoblaze Overview EENG Introduction 8-bit microcontroller for Xilinx devices Soft Core – Soft Processor 5% of the resources of spartan 3 (3S200.
Assembly Language Programming of 8085 BY Prof. U. V. THETE Dept. of Computer Science YMA.
Lecture 13 PicoBlaze I/O & Interrupt Interface Example of Assembly Language Routine ECE 448 – FPGA and ASIC Design with VHDL.
ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set.
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Embedded Systems Lecture 5 January 25 th, 2016.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
CDA 4253 FPGA System Design PicoBlaze Interface Hao Zheng Comp Sci & Eng U of South Florida.
CDA 4253 FPGA System Design PicoBlaze Interface Hao Zheng Comp Sci & Eng U of South Florida.
Lecture 18 PicoBlaze Instruction Set & Assembler Directives
Unit 1 Instruction set M.Brindha AP/EIE
PROGRAMMING THE BASIC COMPUTER
Lecture 8: TI MSP430 Interrupts, ISRs
ELEC 418 Advanced Digital Systems Dr. Ron Hayne
MIPS Instruction Set Advantages
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
PROGRAMMING THE BASIC COMPUTER
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
Lecture 15 PicoBlaze Overview
The 8051 Microcontroller and Embedded Systems
Data Processing Instructions
Advisor: Prof. Gandhi Puvvada
Lecture 14 PicoBlaze Overview
Lecture 16 PicoBlaze I/O & Interrupt Interface
Lecture 16 PicoBlaze Overview
Introduction to ModelSim Implementing Sequential
Advisor: Prof. Gandhi Puvvada
Introduction to Micro Controllers & Embedded System Design Addressing Mode Department of Electrical & Computer Engineering Missouri University of Science.
ECE 448: Lab 6 Using PicoBlaze Fast Sorting Class Exercise 2.
Review of Aldec Active HDL Implementing Combinational
Chapter 8 Central Processing Unit
Lecture 13 PicoBlaze I/O & Interrupt Interface
Lecture 15 PicoBlaze I/O & Interrupt Interface
Lecture 17 PicoBlaze I/O & Interrupt Interface
8051 ASSEMBLY LANGUAGE PROGRAMMING
MIPS Assembly.
Chapter 6 Programming the basic computer
CNET 315 Microprocessor & Assembly Language
Lecture 14 PicoBlaze Instruction Set
CS501 Advanced Computer Architecture
Presentation transcript:

CDA 4253 FPGA System Design PicoBlaze Instruction Set Hao Zheng Comp Sci & Eng U of South Florida

2 Required reading P. Chu, FPGA Prototyping by VHDL Examples Chapter 15 PicoBlaze Assembly Code Development Recommended reading K. Chapman, PicoBlaze for Spartan-6, Virtex-6, and 7-Series (KCPSM6)

3 PicoBlaze-6 Programming Model FFC FFD FFE FFF Bank A Bank B

Addressing modes Direct mode ADD sa, sf IN s5, 0x2a sa <= sa + sf s5 <= PORT(0x2a) Indirect mode STORE s3, (sa) IN s9, (s2) RAM((sa)) <= s3 s9 <= PORT((s2)) s7 <= s7 – 0x07 s2 <= s2 + 0x08 + C Immediate mode SUB s7, 0x07 ADDC s2, 0x08 4

PicoBlaze Development Environments Xilinx KCPSM3/6FIDEx IDE Platform support WindowsWindows XP, Windows 7 and 8 Assembler Command-line in DOS window Graphical Instruction SyntaxKCPSM3/6FIDEx IDE Instruction Set Simulator Facilities provided for VHDL simulation Graphical/ Interactive Simulator BreakpointsN/AYes Register ViewerN/AYes Memory ViewerN/AYes FIDEx IDE is available at

KCPSM6 Assembler Files KCPSM6.EXE

Directives of Assembly Language FunctionKCPSM3/6 DirectiveFIDEx IDE Directive Locating CodeADDRESS 3FF ORG 0x3FF Aliasing Register NamesNAMEREG s5, myregname myregname EQU s5 Declaring ConstantsCONSTANT myconstant, 80 myconstant EQU 0x80 Naming the program ROM file Name using the same base filename as the assembler source file Specify the VHDL template file in the project settings under processor tab and compiler options Equating symbolic name for an I/O port ID N/A sw_port EQU 0x01 ; 8-bit switches sw_in EQU sf IN sw_in, sw_port ; read switch input data EQU s0 ; reg for tmp data led_port EQU 0x05 OUT data, led_port

Differences between Mnemonics of Instructions KCPSM3/ 6 MnemonicFIDEx IDE Mnemonic RETURN RET RETURN C RET C RETURN NC RET NC RETURN Z RET Z RETURN NZ RET NZ RETURNI ENABLE RETI ENABLE RETURNI DISABLE RETI DISABLE ENABLE INTERRUPT EINT DISABLE INTERRUPT DINT

Differences between Mnemonics of Instructions ADDCY sX, sYADDC sX, sY SUBCY sX, sYSUBC sX, sY INPUT sX, (sY)IN sX, (sY) INPUT sX, kkIN sX, kk OUTPUT sX, (sY)OUT sX, (sY) OUTPUT sX, (sY)OUT sX, (sY) COMPARE sX, sYCOMP sX, sY

Differences between Programs A50xA5

An Example in KCPSM Convention 11

Data Movement Instructions (1) Move data to/from registers LOAD sX, sY; direct addressing sX <= sY LOAD sX, 0F; immediate addressing sX <= 0F 12

Data Movement Instructions (2) Move data to/from scratch pad memory fectch sX, (sY); indirect addressing sX <= RAM[(sY)] fectch sX, KK; immediate addressing sX <= RAM[KK] store sX, (sY); indirect addressing RAM[(sY)] <= sX store sX, KK; immediate addressing RAM[KK] <= sX 13

Example: Clear Scratch Pad RAM constant RAM_SIZE 40; size of RAM = 64 clr_data_mem: load s2, RAM_SIZE ; unitize loop index to 64 load s0, 00 clr_mem_loop: sub s2, 01 ; dec loop index store s0, (s2) jump nz, clr_mem_loop ; repeat until s2=0 return; return from this sub-routine

Logic/Bit Manipulation Instructions AND sX, sY; direct addressing, sX <= sX and sY AND sX, 0F; immediate addressing sX <= sX and KK OR sX, sY; direct addressing sX <= sX or sY OR sX, 0F; immediate addressing sX <= sX or KK XOR sX, sY; direct addressing sX <= sX xor sY XOR sX, FF; immediate addressing sX <= sX xor FF 15

Questions Perform the following operations in the assembly language of PicoBlaze 1.Set the most significant bit of the register s0 to 1 1.Clear two middle bits of the register s1 1. Toggle the least significant bit of the register s2 16

Answers 1.Set the most significant bit of the register s0 to 1 constant BIT7, 80; create a symbolic constant or s0, BIT7 2.Clear two middle bits of the register s1 constant BITS43C, E7 AND s1, BITS43C 3. Toggle the least significant bit of the register s2 constant BIT0, 01 XOR s2, BIT0 17

Arithmetic/Multi-Byte Manipulation Instructions ADD sX, sY; direct addressing sX <= sX + sY ADD sX, 0F; immediate addressing sX <= sX + 0F 18

Arithmetic/Multi-Byte Manipulation Instructions ADDC sX, sY; direct addressing sX <= sX + sY + CARRY ADDC sX, 0F; immediate addressing sX <= sX + 0F + CARRY 19

Questions Perform the following operation in the assembly language of PicoBlaze Add two 3-byte numbers X=(x2, x1, x0) and Y=(y2, y1, y0), stored originally in registers (s2, s1, s0) and (s5, s4, s3), accordingly. 20

Answer 21

Another Example 22

SUB sX, sY; direct addressing sX <= sX – sY SUB sX, 0F; immediate addressing sX <= sX – 0F SUBC sX, sY; direct addressing sX <= sX – sY – CARRY SUBC sX, 0F; immediate addressing sX <= sX – 0F – CARRY 23 Arithmetic/Multi-Byte Manipulation Instructions

Questions Perform the following operation in the assembly language of PicoBlaze Perform the subtraction X = X - Y, where X=(x2, x1, x0) and Y=(y2, y1, y0), and these variables are originally stored in registers (s2, s1, s0) and (s5, s4, s3), accordingly. 24

Multi-Byte Subtraction Example 25

Edit instructions - Shifts *All shift instructions affect Zero and Carry flags 26

Edit instructions - Rotations *All rotate instructions affect Zero and Carry flags 27

Questions Perform the following operation in the assembly language of PicoBlaze Perform the left shift (C, X) <= X << 1, where X = (x2, x1, x0) is stored in registers (s2, s1, s0), and the most significant bit of X is shifted into the carry flag. 28

A Shift Example 29

Control Structures 30

Control Structures in High Level Language 31 if (s0 == s1) { /* then branch statements */ } else { /* else branch statements */ }

Control Structures in High Level Language 32 switch (s0) { case value1 : /* then branch statements */ break; case value1 : /* then branch statements */ break; default : /* default statements */ }

Test Instructions TEST sX, sY TEST sX, KK 33

Compare Instructions COMP sX, sY COMP sX, KK 34 Question: How to detect if sX > sY?

Program Flow Control Instructions (1) JUMP AAA PC <= AAA JUMP C, AAA if C=1 then PC <= AAA else PC <= PC + 1 JUMP NC, AAA if C=0 then PC <= AAA else PC <= PC + 1 JUMP Z, AAA if Z=1 then PC <= AAA else PC <= PC + 1 JUMP NZ, AAA if Z=0 then PC <= AAA else PC <= PC

If-Else Statement CAssembly language if (s0 == s1) { ………. } else { ……….. } 36

C Assembly language if (s0 == s1) { … ; if branch } else { … ; else branch } compare s0, s1 jump nz, else_branch … ; code for if brnach jump if_done else_branch: … ; code for else branch if_done: … ; code following the if stmt 37 If-Else Statement

C Assembly language if (s0 > s1) { … ; if branch } else { … ; else branch } compare s0, s1 jump z, else_branch jump c, else_branch … ; code for if brnach jump if_done else_branch: … ; code for else branch if_done: … ; code following the if stmt 38 If-Else Statement

CAssembly language switch (s0) { case value_1: ………. break; case value_2: ………. break; case value_3: ………. break; default: ………. } 39 Switch Statement

CAssembly language compare s0, value_1 jump nz, case_2 … ; code for case 1 jump case_done case_2: compare s0, value_2 jump nz, case_3 … ; code for case 2 jump case_done case_3: compare s0, value_3 jump nz, default … ; code for case 3 jump case_done default: … ; code for the default case case_done: ; code following the case stmy 40 switch (s0) { case value_1: ………. break; case value_2: ………. break; case value_3: ………. break; default: ………. } Switch Statement

C Assembly language for(i=MAX, i>=0, i--) { … ; loop body } 41 For Loop

C Assembly language for(i=MAX; i>0; i--) { … ; loop body } load s0, MAX for_loop: … ; code for loop body sub s0, 1 jump nz, for_loop for(i=MAX; i>=0; i--) { … ; loop body } load s0, MAX for_loop: … ; code for loop body sub s0, 1 jump nc, for_loop 42 For Loop

Subroutines 43

Subroutine-Related Instructions CALL AAA TOS <= TOS+1; STACK[TOS] <= PC; PC <= AAA CALL C | Z, AAA if C | Z =1 then TOS <= TOS+1; STACK[TOS] <= PC; PC <= AAA else PC <= PC + 1 CALL NC | NZ, AAA if C | Z =0 then TOS <= TOS+1; STACK[TOS] <= PC; PC <= AAA else PC <= PC Register/scratch pad RAM must be saved manually

RETURN PC <= STACK[TOS] + 1; TOS <= TOS - 1 RETURN C | Z if C | Z =1 then PC <= STACK[TOS] + 1; TOS <= TOS – 1 else PC <= PC + 1 RETURN NC | NZ if C | Z =0 then PC <= STACK[TOS] + 1; TOS <= TOS – 1 else PC <= PC + 1 Subroutine-Related Instructions 45

Subroutine Call Flow

mult_soft:; (s5, s6) <= s3 * s4 load s5, 00; clear s5 load s0, 08; initialize loop index mult_loop: sr0 s4; shoft LSB to carry jump nc, shift_prod; LSB = 0 add s5, s3; LSB = 1 shift_prod: sra s5; right shift upper byte sra s6; right shift lower byte sub s0, 01; dec loop index jump nz, mult_loop; repeat until s0=0 return Subroutine Example 47

1.Derive the pseudo code 2.Identify subroutines 3.Determine register/RAM uses 4.Derive assembly code for the subroutines. Program Development 48 Embedded SW template

1.read a and b from switches 2.compute a 2 +b 2 3.display result on LEDs Program Development: Example 49