Chapter 2 : Data types - PowerPoint PPT Presentation

About This Presentation
Title:

Chapter 2 : Data types

Description:

Title: Chapter 2 : Data type Author: cmchao Last modified by: cmchao Created Date: 9/28/2004 6:25:39 PM Document presentation format: – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 10
Provided by: cmc148
Category:
Tags: chapter | data | types

less

Transcript and Presenter's Notes

Title: Chapter 2 : Data types


1
Chapter 2 Data types
2
Extension Data Type Overview
Name Description
sc_bit single bit with two values, 0 and 1
sc_bvltngt Arbitrary width bit vector
sc_logic Signle bit with four value, 0, 1, X and Z
sc_lvltngt Arbitrary width logic vector
sc_intltngt Signed integer type , up to 64 bits
sc_uintltngt Unsigned integer type, up to 64 bits
sc_bigintltngt Arbitrary width signed integer type
sc_bituintltngt Arbitrary width signed integer type
3
sc_bit
Operator Function Usage
Bitwise AND expr1 expr2
Bitwise OR expr1 expr2
Bitwise XOR expr1 expr2
Bitwise NOT expr1
Assignment value_holder expr
Compound AND value_holder expr
Compound OR value_holder expr
Compound XOR value_holder expr
Equality expr1 expr2
Inequality expr1 ! expr2
4
sc_bvltngt
Operator Function Usage
Bit selection varindex
(,) Concatenation (expr1, expr2, expr3)
Method Function Usage
range(0 Range selection var.range(idx1, idx2)
and_reduce() Reduction AND var.and_reduce()
or_reduce Reduction OR var.or_reduce()
xor_reduce Reduction XOR var.xor_reduce()
5
sc_logic and sc_lvltngt
  • Four value
  • 0, SC_LOGIC_0
  • 1, SC_LOGIC_1
  • X, SC_LOGIC_X
  • Z, SC_LOGIC_Z
  • Operation
  • The same as sc_bit

6
Integer Type
  • Data width lt 64 bits
  • sc_int
  • sc_uint
  • Data width gt 64 bits
  • sc_bitint
  • sc_biguint
  • Operation
  • The same as C native definition
  • , (,), range()

7
User Defined Data
  • Four operator are required
  • Operator (assignment)
  • Operator (equality)
  • Operator ltlt (stream output)
  • sc_trace()
  • Example
  • struct blah
  • int a, int b
  • blah operator (const blah arg)
  • a arg.a, b arg.b
  • bool operatro (const blah arg)
  • return a arg.a b arg.b ? true
    false
  • ostream operatorltlt (ostream os, const
    blah arg)
  • os ltlt a ltlt arg.a ltlt b ltlt b
  • void sc_trace (sc_trace_file tf, const blah
    arg, const sc_string name)
  • sc_trace(tf, arg.a, name.a
  • sc_trace(tf, arg.b, name.b

8
Example
  • sc_logic x // object declaration
  • x 1 // assign a 1 value
  • x Z // assign a Z value
  • sc_bvlt16gt val
  • val "1111111111111111"
  • sc_uintlt4gt myrange
  • sc_uintlt32gt myint
  • myrange myint.range(7,4)
  • sc_uintlt4gt inta
  • sc_uintlt4gt intb
  • sc_uintlt8gt intc
  • intc (inta, intb)

9
Recommended Data Types
  • Primitive type is better
  • For one bit, use bool
  • Replace sc_int and sc_uint by int and unsigned
    int if acceptable
  • Use sc_logic and sc_lv types when four types are
    really needed
Write a Comment
User Comments (0)
About PowerShow.com