ECE 526 – Network Processing Systems Design Microengine Programming Chapter 23: D. E. Comer.

Slides:



Advertisements
Similar presentations
Intermediate Code Generation
Advertisements

Lecture 6 Programming the TMS320C6x Family of DSPs.
SPARC Architecture & Assembly Language
Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
The Assembly Language Level
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 7: User-Defined Functions II.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 7: User-Defined Functions II.
Chapter 7: User-Defined Functions II
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 7: User-Defined Functions II.
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
COMP3221 lec08-arith.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 8: C/Assembler Data Processing
Execution of an instruction
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 7: User-Defined Functions II.
C Lecture Notes 1 Program Control (Cont...). C Lecture Notes 2 4.8The do / while Repetition Structure The do / while repetition structure –Similar to.
IXP1200 Microengines Apparao Kodavanti Srinivasa Guntupalli.
Memory - Registers Instruction Sets
Chapter 6. 2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single Value Pass by Reference Variable Scope.
Chapter 4 Macro Processors
ECE 526 – Network Processing Systems Design IXP XScale and Microengines Chapter 18 & 19: D. E. Comer.
ECE 265 – LECTURE 9 PROGRAM DESIGN 8/12/ ECE265.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 19 - The Preprocessor Outline 19.1 Introduction 19.2 The #include Preprocessor Directive 19.3.
Imperative Programming
CoE3DJ4 Digital Systems Design
chap13 Chapter 13 Programming in the Large.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single.
Lecture 4 C Program Control Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Chapter 6: User-Defined Functions
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
CSC 3210 Computer Organization and Programming Chapter 1 THE COMPUTER D.M. Rasanjalee Himali.
Chapter 18 – Miscellaneous Topics. Multiple File Programs u Makes possible to accommodate many programmers working on same project u More efficient to.
Dr. José M. Reyes Álamo 1.  Review: ◦ Statement Labels ◦ Unconditional Jumps ◦ Conditional Jumps.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Execution of an instruction
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessing Lecture 12 April 7, 2005.
Assembly Language for x86 Processors 7th Edition Chapter 13: High-Level Language Interface (c) Pearson Education, All rights reserved. You may modify.
Overview of Super-Harvard Architecture (SHARC) Daniel GlickDaniel Glick – May 15, 2002 for V (Dewar)
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessor Midterm Review Lecture 7 Feb 17, 2004.
ECE 353 Lab 2 Pipeline Simulator Additional Material.
Functions Math library functions Function definition Function invocation Argument passing Scope of an variable Programming 1 DCT 1033.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
The Preprocessor Directives Introduction Preprocessing – Occurs before program compiled Inclusion of external files Definition of symbolic constants.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Chapter 7 - Functions. Functions u Code group that performs single task u Specification refers to what goes into and out of function u Design refers to.
Building Programs from Existing Information Solutions for programs often can be developed from previously solved problems. Data requirements and solution.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
C Program Control September 15, OBJECTIVES The essentials of counter-controlled repetition. To use the for and do...while repetition statements.
Lecture 3 Translation.
Format of Assembly language
Addressing Modes in Microprocessors
Chapter 7: User-Defined Functions II
Computer Architecture Instruction Set Architecture
Control Unit Lecture 6.
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Microcomputer Programming
C Basics.
CS/COE0447 Computer Organization & Assembly Language
User-Defined Functions
CS/COE0447 Computer Organization & Assembly Language
Computer Architecture and Design Lecture 6
Apparao Kodavanti Srinivasa Guntupalli
Introduction to Micro Controllers & Embedded System Design
Chapter 7: User-Defined Functions II
COMS 361 Computer Organization
Instruction Set Principles
Instructions in Machine Language
CS/COE0447 Computer Organization & Assembly Language
Presentation transcript:

ECE 526 – Network Processing Systems Design Microengine Programming Chapter 23: D. E. Comer

Ning WengECE 5262 Overview Lab 3: packet forwarding and counting on IXP2400 ─ Any problems with Part I and Part II Microcode programming Lab 3 part III

Ning WengECE 5263 Microengine Assembler Assembly languages matches the underlying hardware ─ Intel developed “microengine assembly language” Assembly is difficult to program directly ─ Assembler supports higher-level statements High-level mechanisms: ─ Assembler directives ─ Symbolic register names and automated register allocation ─ Macro preprocessor ─ Pre-defined macros for common control structures Balance between low-level and higher-level programming

Ning WengECE 5264 Assembly Language Syntax Instructions: label: operator operands token ─ Operands and token are optional ─ Label: symbolic name as target for branch ─ Operator: single microengine instruction or high-level command ─ Operands and token: depend on operator Comments: ─ C-style: /* comment */ ─ C++-style: // comment ─ ASM-style: ; comment ─ Benefit of ASM style: remain with code after preprocessing Directives: ─ Start with “.”

Ning WengECE 5265 Operand Syntax Example: ALU instruction alu [dst, src1, op, src2] ─ dst: destination for result ─ src1 and src2: source values ─ op: operation to be performed Notes: ─ Destination register cannot be read-only (e.g., read transf. reg.) ─ If two source regs are used, they must come from different banks ─ Immediate values can be used ─ “--” indicates non-existing operand (e.g., source 2 for unary operation or destination)

Ning WengECE 5266 ALU Operators

Ning WengECE 5267 Other Operators ALU shift/rotate: ─ alu_shf [dst, src1, op, src2, shift] ─ shift specifies right or left shift or rotate (e.g., >rot3) Memory accesses: ─ sram [direction, xfer_reg, addr1, addr2, count] ─ direction is “read” or “write” ─ addr1 and addr2 are used for base+offset and scaling Immediate: ─ immed [dst, ival, rot] ─ Immediate has upper 16 bit all 0 or all 1 ─ Rotation is “0”, “<<8”, or “<<16” ─ Also direct access to individual bytes/words: immed_b2, immed_w1

Ning WengECE 5268 Symbolic Register Names Assembler supports automatic register allocation ─ Either entirely manual or automatic – no mixture possible Symbolic register names: ─.areg loopindex 5 ─ Assigns the symbolic name “loopindex” to register 5 in bank A Other directives:

Ning WengECE 5269 Register Types and Syntax Register names with relative and absolute addressing: Note: read and write transfer registers are separate ─ You cannot read a value after you have written it to a xfer reg Also: some instruction sequences impossible: ─ Z <- Q + R ─ Y <- R + S ─ X <- Q + S

Ning WengECE Scoping Scopes define regions where variable names are valid ─.local directive: Outside scope registers can be reused Scopes can be nested ─ Names are “shadowed”

Ning WengECE Macro Preprocessor Preprocessor functionality: ─ File inclusion ─ Symbolic constant substitution ─ Conditional assembly ─ Parameterized macro expansion ─ Arithmetic expression evaluation ─ Iterative generation of code Macro definition ─ #macro name [parameter1, parameter2, …] lines of text #endm

Ning WengECE Macro Example Example for a=b+c+5: ─ #macro add5 [a, b, c].local tmp alu[tmp, c, +, 5] alu[a, b, +, tmp].endlocal #endm Problems when tmp variable is overloaded: ─ add5[x, tmp, y] ─ Why? One has to be careful with marcos!

Ning WengECE Preprocessor Statements

Ning WengECE Structured Programming Directives Structured directives are similar to control statements:

Ning WengECE Example If statement with structured directives: ─.if ( conditional_expression ) /* block of microcode */.elif ( conditional_expression ) /* block of microcode */.else /* block of microcode */.endif While statement: ─.while ( conditional_expression ) /* block of microcode */.endw Very useful and less error-prone than hand-coding

Ning WengECE Conditional Expressions Conditional expressions may have C-language operators ─ Integer comparison:, =, ==, != ─ Shift operator: > ─ Logic operators: &&, || ─ Parenthesis: (, ) Additional test operators

Ning WengECE Context Switches Instructions that cause context switches: ─ ctx_arb instruction ─ Reference instruction ctx_arb instruction: ─ One argument that specifies how to handle context switch ─ voluntary ─ signal_event – waits for signal ─ kill – terminates thread permanently Reference instruction to memory, hash, etc. ─ One argument ─ ctx_swap – thread surrenders control until operation completed ─ sig_done – thread continues and is signaled completion

Ning WengECE Indirect References Sometimes memory addresses are not known at compile time ─ Indirect references use result of ALU instruction to modify immediately following reference ─ “Unlike the conventional use of the term [indirect reference], Intel’s indirect reference mechanism does not follow pointers; the terminology is confusing at best.” ☺ Indirect reference can modify: ─ Microengine associated with memory reference ─ First transfer register in a block that will receive result ─ The count of words of memory to transfer ─ The thread ID of the hardware thread executing the instruction Bit patterns specifying operation and parameter must be loaded into ALU ─ Uses operation without destination: alu_shf[--,--,b,0x13,<<16] ─ Reference: scratch[read,$reg0,addr1,addr2,0],indirect_ref

Ning WengECE Transfer Registers Memory transfers need contiguous registers ─ Specified with.xfer_order ─.local $reg1 $ref2 $ref3 $ref4.xfer_order $reg1 $reg2 $reg3 $reg4 Library macros for transfer register allocation ─ Allocations: xbuf_alloc[] ─ Deallocation: xbuf_free[] ─ Example: xbuf_alloc[$$buf,4] allocates $$buf0, …, $$buf3 Allocation is based on 32-bit chunks ─ Transfer of 2 SDRAM units requires 4 transfer registers

Ning WengECE Lab 3: Part III type = _buf_byte_extract((UINT*)p_pkt,PPP_IPV4_TCP_PORT _OFFSET,PPP_IPV4_TCP_DPORT_LEN,memType); // _buf_byte_extract: extract a numeric byte field from buffer. // in_src pointer to the buffer data that contains the field. // in_field_start start byte offset of field to be extracted. // in_bytes_num length of field in bytes. ─ #define PPP_IPV4_TCP_DPORT_LEN 2 ─ #define PPP_IPV4_TCP_PORT_OFFSET 0x18

Ning WengECE Lab 3: part III if (type == PPP_IPV4_TCP_WEB) { sram_incr((volatile void __declspec(sram) *)(COUNT_IPV4_TCP_WEB_SRAM_ADDR)); dlNextBlock = BID_IPV4; return; } ─ #definePPP_IPV4_TCP_WEB0x0050 ─ #define COUNT_IPV4_TCP_WEB_SRAM_ADDR 0x sram_incr() ─ Description: this function increments the longword at address by one. ─ Arguments: address Address to read from. ─ Reference: Microengine C compiler language

Ning WengECE Summary Assembly help performance but difficult to program directly High-level mechanisms: ─ Assembler directives ─ Symbolic register names and automated register allocation ─ Macro preprocessor ─ Pre-defined macros for common control structures Balance between low-level and higher-level programming