Winter-Spring 2001Codesign of Embedded Systems1 Fixed-Point Data Types in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Slides:



Advertisements
Similar presentations
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Advertisements

Chapter 7: User-Defined Simple Data Types, Namespaces, and the string Type.
Objectives In this chapter, you will:
Operator Overloading. Basics Define operations on user-defined data types –Perform same operation as it is supposed to but, with operands of the user-defined.
COMP1180 Review Date: 4 March, 2009 Time: 10:30am - 12:20pm Venue: –CS students -- FSC801C and FSC801D –IS and other students -- OEE1017 Remarks: – 1)
Sizes of simple data types sizeof(char) = 1 size(short) = 2 sizeof(int) = 4 size(long) = 8 sizeof(char) = 1 size(short) = 2 sizeof(int) = 2 size(long)
Operator Overloading in C++ Systems Programming. Systems Programming: Operator Overloading 22   Fundamentals of Operator Overloading   Restrictions.
Differences between Java and C CS-2303, C-Term Differences between Java and C CS-2303, System Programming Concepts (Slides include materials from.
Number Systems Standard positional representation of numbers:
Basic C Programming Data Types and Arithmetic Operations 01/30/15.
State Machines Timing Computer Bus Computer Performance Instruction Set Architectures RISC / CISC Machines.
2 Objectives You should be able to describe: Operator Functions Two Useful Alternatives – operator() and operator[] Data Type Conversions Class Inheritance.
Operator Overloading in C++
Number Systems Lecture 02.
Prepared by: Hind J. Zourob Heba M. Matter Supervisor: Dr. Hatem El-Aydi Faculty Of Engineering Communications & Control Engineering.
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
ELEN 5346/4304 DSP and Filter Design Fall Lecture 12: Number representation and Quantization effects Instructor: Dr. Gleb V. Tcheslavski Contact:
C Summary Wilmer Arellano. References Excerpts from the book: Predko, Myke. (2005). 123 PIC MICROCONTROLLER EXPERIMENTS FOR THE EVIL GENIOUS. USA: McGraw-Hill.
Fixed-Point Arithmetics: Part II
Chapter 4 Numbers. Python Program Structure Python programs consist of: Modules Statements Expressions Objects.
COMP 116: Introduction to Scientific Programming Lecture 28: Data types.
9.4 FLOATING-POINT REPRESENTATION
Bit Manipulation when every bit counts. Questions on Bit Manipulation l what is the motivation for bit manipulation l what is the binary, hexadecimal,
Instructor: Andrew Case Floating Point Slides adapted from Randy Bryant & Dave O’Hallaron.
Java ProgrammingtMyn1 Java Programming Timo Mynttinen Mikkeli University of Applied Sciences.
8-1 Embedded Systems Fixed-Point Math and Other Optimizations.
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
CSE 425: Data Types I Data and Data Types Data may be more abstract than their representation –E.g., integer (unbounded) vs. 64-bit int (bounded) A language.
1 Number Systems Lecture 10 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Chapter 7 Additional Control Structures. Chapter 7 Topics l Switch Statement for Multi-Way Branching l Do-While Statement for Looping l For Statement.
Winter-Spring 2001Codesign of Embedded Systems1 Reactivity, Ports, and Signals in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE )
Operator Overloading Operator Overloading allows a programmer to define new uses of the existing C/C++ operator symbols. –useful for defining common operations.
CPSC 252 Operator Overloading and Convert Constructors Page 1 Operator overloading We would like to assign an element to a vector or retrieve an element.
 2008 Pearson Education, Inc. All rights reserved Operator Overloading.
Introduction to Programming
Slide 1 Chapter 8 Operator Overloading, Friends, and References.
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
Design & Co-design of Embedded Systems Data Types in SystemC Maziar Goudarzi.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
Chapter 3 – Variables and Arithmetic Operations. Variable Rules u Must declare all variable names –List name and type u Keep length to 31 characters –Older.
Slides created by: Professor Ian G. Harris Hello World #include main() { printf(“Hello, world.\n”); }  #include is a compiler directive to include (concatenate)
Copyright © Curt Hill Formatting Reals Outputs other than normal.
CSC 143F 1 CSC 143 Constructors Revisited. CSC 143F 2 Constructors In C++, the constructor is a special function automatically called when a class instance.
1 Lecture 5 More Programming Constructs Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 1 due Friday, 7pm. RAD due next Friday. Presentations week 6. Today: –More details on functions,
EEL 3801 C++ as an Enhancement of C. EEL 3801 – Lotzi Bölöni Comments  Can be done with // at the start of the commented line.  The end-of-line terminates.
Lecture 15: Course Review BJ Furman ME 30 16MAY2011.
Number Representation and Arithmetic Circuits
Chapter 1 C++ Basics Review (Section 1.4). Classes Defines the organization of a data user-defined type. Members can be  Data  Functions/Methods Information.
Struct s (7.4) Used as data aggregates for an entity can be different types of data e.g. for student id, name, GPA, address,... Similar to classes, but.
Chapter 3: Dataflow Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 3-1 Chapter 3: Dataflow Modeling.
Simple Data Types Chapter Constants Revisited t Three reasons to use constants –Constant is recognizable –Compiler prevents changes in value.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
Objectives A data type is  A set of values AND  A set of operations on those values A data type is used to  Identify the type of a variable when the.
Introduction to C++ programming Recap- session 1 Structure of C++ program Keywords Operators – Arithmetic – Relational – Logical Data types Classes and.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Operator Overloading.
Chapter 7: Expressions and Assignment Statements
Chapter 7: Expressions and Assignment Statements
C++, OBJECT ORIENTED PROGRAMMING
Pointers and References
Chapter 3: Dataflow Modeling
Operator Overloading; String and Array Objects
Chapter 7 Additional Control Structures
Operator Overloading; String and Array Objects
Operator overloading Dr. Bhargavi Goswami
Differences between Java and C
Summary of what we learned yesterday
Fundamental Programming
Presentation transcript:

Winter-Spring 2001Codesign of Embedded Systems1 Fixed-Point Data Types in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE )

Winter-Spring 2001Codesign of Embedded Systems2 Topics Fast Fixed-Point Types Dynamic Fixed-Point Types Context concept and its usage Defined Operators on Fixed-Point Types Complementary Notes on Fixed-Point Class Some other member functions of Fixed-Point class Type casting Arrays of Fixed-Point Data

Winter-Spring 2001Codesign of Embedded Systems3 Fixed-Point Data Types in SystemC Fast Fixed-Point Data Types

Winter-Spring 2001Codesign of Embedded Systems4 Fast Fixed-Point Data Types Arbitrary Precision vs. Simulation Speed Achieving Faster Speed Use double as underlying data type Mantissa limited to 53 bits Range limited to that of double Fast Fixed-Point Types sc_fixed_fast, sc_ufixed_fast sc_fix_fast, sc_ufix_fast Exactly the same declaration format and usage as before All fixed-point data types, can be mixed freely

Winter-Spring 2001Codesign of Embedded Systems5 Fast Fixed-Point Data Types: Simple Example #include “systemc.h” float adder(float a, float b) { sc_fixed_fast Inputa = a; sc_fixed_fast Inputb = b; sc_fixed_fast Output; Output = (Inputa + Inputb); return (Output); }

Winter-Spring 2001Codesign of Embedded Systems6 Fixed-Point Data Types in SystemC Dynamic Fixed-Point Data Types

Winter-Spring 2001Codesign of Embedded Systems7 Dynamic Fixed-Point Data Types Parameters passing sc_fxtype_params Type data members wl: word length iwl: integer word length q_mode: quantization mode o_mode: overflow mode n_bits: saturated bits some others Reading/writing individual data members.wl().iwl().q_mode().o_mode()

Winter-Spring 2001Codesign of Embedded Systems8 Dynamic Fixed-Point Data Types (cont’d) Example sc_fxtype_params my_fx_type(8,4,SC_RND,SC_SAT); sc_fix my_fx(my_fx_type); my_fx = 10.2; my_fx_type.wl(15); cout<<my_fx_type.wl();

Winter-Spring 2001Codesign of Embedded Systems9 Context Concept Specifies default values for (dynamic) fixed-point variables. Built-in defaults: Declaration syntax sc_fxtype_context obj_name( ) Scope C/C++ scopes for variables/objects Context is activated when declared Declaration without activating is supported sc_fxtype_context obj_name(, SC_LATER) Selective enabling/disabling of Contexts is supported.begin() and.end() member functions

Winter-Spring 2001Codesign of Embedded Systems10 Context Concept: Simple Example sc_fxtype_params myparams(SC_RND, SC_SAT); sc_fxtype_context mycontext(myparams); sc_fix_fast adder(sc_fix_fast a, sc_fix_fast b) { sc_fix_fast Output(a.wl() +1, a.iwl() +1); Output = a + b; return(Output); }

Winter-Spring 2001Codesign of Embedded Systems11 Context Concept: Complex Example

Winter-Spring 2001Codesign of Embedded Systems12 sc_fxtype_params param1(12,3); sc_fxtype_params param2(32,3,SC_RND,SC_SAT); sc_fxtype_params param3(16,16,SC_TRN,SC_SAT_ZERO); sc_fxtype_context c_1(param1,SC_LATER); sc_fxtype_context c_2(param2); sc_fxtype_context c_3(param3, SC_LATER); sc_fix a; c_1.begin(); sc_fix b; c_3.begin(); sc_fix c; sc_fixed zz; c_3.end(); sc_fix d; c_1.end(); sc_fix e; c_2.end(); sc_fix f; c_2 active c_1 active c_3 active c_1 active c_2 active

Winter-Spring 2001Codesign of Embedded Systems13 Fixed-Point Data Types in SystemC Fixed-Point Operators

Winter-Spring 2001Codesign of Embedded Systems14 Operators on Fixed-Point Data Types Bitwise:&|^~ Arithmetic:*/ > Equality:==!= Relational: >= Assignment:=&=|=^=+= -=*=/= >= Bit Selection:[] Part Selection.range(,) Bit selection return type: like sc_bit Part selection return type: like sc_bv

Winter-Spring 2001Codesign of Embedded Systems15 Operators on Fixed-Point Data Types Alignment is done before each binary operation &

Winter-Spring 2001Codesign of Embedded Systems16 Fixed-Point Data Types in SystemC Complementary Notes on Fixed-Point Classes

Winter-Spring 2001Codesign of Embedded Systems17 Useful State Information Status member functions is_neg() is_zero() overflow_flag() quantization_flag() sc_fixed my_var; if (my_var.is_zero())...

Winter-Spring 2001Codesign of Embedded Systems18 Conversion To String Conversion member function to_string(number_representation, format) Available number representations SC_DEC (is the default) SC_BINSC_BIN_USSC_BIN_SM SC_OCTSC_OCT_USSC_OCT_SM SC_HEXSC_HEX_USSC_HEX_SM SC_CSD Available formats SC_FFixed Notation (is the default) SC_EScientific Notation sc_fixed my_var; cout << my_var.to_string(SC_CSD);

Winter-Spring 2001Codesign of Embedded Systems19 Type Casting Done during initialization and/or assignment (if required) Type casting operations 1. Quantization 2. Overflow handling (sign-extension and/or zero filling is done wherever necessary) Can be turned ON or OFF, using Current Context Parameter during fix-point data declaration SC_ON, SC_OFF sc_ufixed d(SC_OFF);

Winter-Spring 2001Codesign of Embedded Systems20 Type Casting (cont’d) Turning Casting off will turn off fixed-point handling of the operand It will be treated as a large float Bit-accurate behavior of the operand will not be available

Winter-Spring 2001Codesign of Embedded Systems21 Arrays of Fixed-Point Data Static fixed-point data types sc_fixed a[8]; Only CAST Switch is determined by current Context The same for all Static fixed-point types Dynamic fixed-point data types sc_fix a[8]; Default constructor is called. Default values are taken from current context

Winter-Spring 2001Codesign of Embedded Systems22 Example: 17 Tap FIR Filter

Winter-Spring 2001Codesign of Embedded Systems23 sc_fixed fir_fx(sc_fixed Input) { const int NumberOfCoefficients = 17; static sc_fixed state[16]; static sc_fixed coeff[17] = { e-02, …}; sc_fixed * pstate; sc_fixed * pcoeff; sc_fixed sum; int i; /* FIR filter output */ pcoeff = &coeff[0];pstate = &state[0]; sum = ((*pcoeff++ ) * (Input)); for (i = 0; i<16; i++) sum = (sum + ((*pcoeff++ ) * (*pstate++ ))); /* shift state */ pstate = &state[15];pcoeff = (pstate - 1); for (i = 0; i < 15; i++) *pstate-- = *pcoeff-- ; *pstate = Input; return(Sum); }

Winter-Spring 2001Codesign of Embedded Systems24 What we learned today Fix-point data types Faster versions Dynamic versions Default behaviors Operators Arrays Other complementary notes

Winter-Spring 2001Codesign of Embedded Systems25 Complementary Notes: Assignments Today is due date for all LATE assignments. From now on, 5% penalty is re-enabled