Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 2 : Data types. Extension Data Type Overview NameDescription sc_bitsingle bit with two values, ‘0’ and ‘1’ sc_bv Arbitrary width bit vector sc_logicSignle.

Similar presentations


Presentation on theme: "Chapter 2 : Data types. Extension Data Type Overview NameDescription sc_bitsingle bit with two values, ‘0’ and ‘1’ sc_bv Arbitrary width bit vector sc_logicSignle."— Presentation transcript:

1 Chapter 2 : Data types

2 Extension Data Type Overview NameDescription sc_bitsingle bit with two values, ‘0’ and ‘1’ sc_bv Arbitrary width bit vector sc_logicSignle bit with four value, ‘0’, ‘1’, ‘X’ and ‘Z’ sc_lv Arbitrary width logic vector sc_int Signed integer type, up to 64 bits sc_uint Unsigned integer type, up to 64 bits sc_bigint Arbitrary width signed integer type sc_bituint Arbitrary width signed integer type

3 sc_bit OperatorFunctionUsage &Bitwise ANDexpr1 & expr2 |Bitwise ORexpr1 | expr2 ^Bitwise XORexpr1 ^ expr2 ~Bitwise NOT~ expr1 =Assignmentvalue_holder = expr &=Compound ANDvalue_holder &=expr |=Compound ORvalue_holder |=expr ^=Compound XORvalue_holder ^=expr ==Equalityexpr1 == expr2 |=Inequalityexpr1 != expr2

4 sc_bv OperatorFunctionUsage []Bit selectionvar[index] (,)Concatenation(expr1, expr2, expr3) MethodFunctionUsage range(0Range selectionvar.range(idx1, idx2) and_reduce()Reduction ANDvar.and_reduce() or_reduceReduction ORvar.or_reduce() xor_reduceReduction XORvar.xor_reduce()

5 sc_logic and sc_lv 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 <= 64 bits  sc_int  sc_uint Data width > 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 << (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& operator<< (ostream& os, const blah& arg) { os << “a : “ << arg.a << “b :” << 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_bv val; val = "1111111111111111"; sc_uint myrange; sc_uint myint; myrange = myint.range(7,4); sc_uint inta; sc_uint intb; sc_uint 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


Download ppt "Chapter 2 : Data types. Extension Data Type Overview NameDescription sc_bitsingle bit with two values, ‘0’ and ‘1’ sc_bv Arbitrary width bit vector sc_logicSignle."

Similar presentations


Ads by Google