SystemC Data Types - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

SystemC Data Types

Description:

Useful in DSP applications. Specify Quantization and Saturation Behavior ... Conversion may truncate data when necessary. e.g.: myInt = myFloat; 5. SystemC Data Types ... – PowerPoint PPT presentation

Number of Views:103
Avg rating:3.0/5.0
Slides: 26
Provided by: gor449
Category:
Tags: systemc | data | truncate | types

less

Transcript and Presenter's Notes

Title: SystemC Data Types


1
SystemC Data Types
2
SystemC Data Types
  • C Built-in Types
  • bool
  • char
  • int
  • float
  • strings
  • pointers / references

not synthesisable
3
SystemC Data Types
  • bit and bit vector
  • sc_bit, sc_bvltNgt
  • four-state logic
  • sc_logic, sc_lvltNgt
  • 0 Logical 0
  • 1 Logical 1
  • Z High Impedance
  • X Unknown
  • Fixed Precision ints
  • 64 Bits
  • sc_intltNgt
  • sc_uintltNgt
  • Arbitrary Precision
  • Up to 512 Bits
  • sc_bigintltNgt
  • sc_biguintltNgt

4
SystemC Data Types
  • Fixed Point Types
  • Useful in DSP applications
  • Specify Quantization and Saturation Behavior
  • sc_fixedltwl, iwl, q_mode, o_mode, n_bitsgt
  • wl Total WorD Length
  • iwl Integer Word Length
  • q_mode Quantization Mode
  • o_mode Overflow Mode
  • n_bits Number of Saturated Bits

5
SystemC Data Types
  • Common Characteristics
  • Native C types (int, float, string) and SystemC
    types may be mixed.
  • Equality and bitwise operators (, ltlt, gtgt)
  • All SystemC Data Types
  • Arithmetic and relational operators (, -, lt, gt)
  • Numeric data types only
  • Overloaded assignment operators
  • Provides conversion between different data types.
  • Conversion may truncate data when necessary.
  • e.g. myInt myFloat

5
6
SystemC Data Types
  • Utility Methods
  • Bit Select get and set specific bits
  • Range Select get and set a range of bits
  • Concatenation join bits
  • Bitwise Reduction
  • Integer Conversion
  • String input and output

6
7
SystemC Data Types
  • Bit Select
  • Read or write to a specific bit in a variable.
  • C operator overloaded to provide read/write
    access.
  • e.g.

sc_intlt4gt myInt // 4-bit signed
integer myInt1 true // Set bit 1 to
true.bool myBool bool b1 myInt0.to_bool() //
Read bit 0
7
8
SystemC Data Types
  • Part Select
  • Read/write a contiguous subset of bits within the
    variable.
  • Available methods
  • range(int, int)
  • C operator()
  • e.g.

sc_intlt8gt myInt 2 //
00000010 myInt.range(3, 2) myInt.range(1, 0)
// 00001010
8
9
SystemC Data Types
  • Concatenation
  • Concatenate the bits of two variables together.
  • Available methods
  • concat(arg0, arg1)
  • C comma operator operator,

sc_intlt8gt U1 2 // 00000010 sc_intlt2gt U2 1
// 01 sc_intlt8gt U3 (true, U1.range(3,0), U2,
U20) // U3
10010011 (U20, U10, U1.range(7,6))
U1.range(3, 0)
9
10
SystemC Data Types
  • Bitwise Reduction
  • Performs bitwise operation on all bits in integer
    or vector.
  • Returns bool.
  • Operations
  • and_reduce() - Bitwise AND between all bits
  • nand_reduce() - Bitwise NAND between all bits
  • or_reduce() - Bitwise OR between all bits
  • nor_reduce() - Bitwise NOR between all bits
  • xor_reduce() - Bitwise XOR between all bits
  • xnor_reduce() - Bitwise XNOR between all bits

10
11
SystemC Data Types
  • Integer Conversion
  • All SystemC data types
  • accept C integer assignment.
  • convert to C interger types
  • Conversion Methods
  • to_int() - Convert to native int type
  • to_uint() - Convert to native unsigned type
  • to_long() - Convert to native long type
  • to_ulong() - Convert to native unsigned long type
  • to_uint64() - Convert to native 64-bit unsigned
    integer
  • to_int64() - Convert to native 64-bit signed
    integer

11
12
SystemC Data Types
  • String input and output
  • All SystemC data types
  • can be set by reading from a C input text
    stream
  • can print their value to a C output text stream

void scan(istream input) void print(ostream
output)
12
13
Debugging
14
Text-based Debugging
  • C printf debugging

printf(Hello World) cout ltlt Hello World ltlt
endl
14
15
Text-based Debugging
  • Constructor Debugging
  • Find out how your design is built up when the
    simulation starts.
  • Use the name() method to identify SystemC classes

SC_CTOR(nand2) cout ltlt Constructing nand2
ltlt name() ltlt endl ... ... OUTPUT Construc
ting stim Constructing nand2 exor2.N1 Constructung
nand2 exor2.N2
15
16
Text-based Debugging
  • Debugging methods available on all SystemC
    objects
  • const char name()
  • Returns the name of the object
  • const char kind()
  • Returns the objects sub-class name
  • void print(ostream out)
  • Prints the objects name to the output stream
  • void dump(ostream out)
  • Prints the objects diagnostic data to the output
    stream.

16
17
Text-based Debugging
  • Debugging threads and methods
  • All SystemC data types can be printed to cout.
  • e.g. print inputs A, B, and F to cout in a table

OUTPUT Time A B F 10 ns 1 0 0 20 ns
1 1 0 30 ns 1 1 1 40 ns 0 0 1
17
18
Text-based Debugging
SC_MODULE(mon) sc_inltboolgt A,B,F
sc_inltboolgt Clk void monitor() cout
ltlt "Time A B F" ltlt endl while (true)
cout ltlt sc_time_stamp() ltlt ", "
cout ltlt A.read() ltlt ", " cout ltlt
B.read() ltlt ", " cout ltlt F.read() ltlt
endl wait() // wait for 1 clock cycle
SC_CTOR(mon)
SC_THREAD(monitor) sensitive ltlt Clk.pos()

18
19
Advanced Debugging
  • Standard C debugging tools
  • GDB, etc...
  • SystemC-specific debuggers and visualizers.

19
20
Advanced Debugging
21
Wave-form Debugging
  • Requires adding additional SystemC statements to
    sc_main()
  • Wave-form data written to file as simulation
    runs.
  • Sequence of operations
  • Declare and create the trace file
  • Register signals or events for tracing
  • Run the simulation
  • Close the trace file

21
22
Wave-form Tracing
int sc_main(int argc, char argv)
sc_signalltboolgt ASig, BSig, FSig sc_clock
TestClk("TestClock", 10, SC_NS,0.5, 1, SC_NS)
// Set up simulation ... // Set up trace
file sc_trace_file Tf Tf
sc_create_vcd_trace_file("traces") //
Create Trace File ((vcd_trace_file)Tf)-gtsc_set_
vcd_time_unit(-9) // Set time unit
sc_trace(Tf, ASig , "A" ) // Register
signals sc_trace(Tf, BSig , "B" )
// and variables. sc_trace(Tf, FSig ,
"F" ) sc_trace(Tf, DUT.S1, "S1")
sc_trace(Tf, DUT.S2, "S2") sc_trace(Tf,
DUT.S3, "S3") sc_start() // run
forever // Start the simulation
sc_close_vcd_trace_file(Tf) // Close the trace
file return 0
22
23
Wave-form Tracing
  • Sample Output

23
24
Questions?
25
References
  • http//embedded.eecs.berkeley.edu/Respep/Research/
    hsc/abstract.htmlmotivation
  • http//www.esperan.com/pdf/Esperan_SystemC_tutoria
    l.pdf
  • http//www.doulos.com/knowhow/systemc/tutorial/
  • http//www.comelec.enst.fr/hdl/sc_docs/systemc_qui
    ckreference.pdf
  • http//www.ecsi-association.org/ecsi/projects/odet
    te/files/6.systemc.pdf
Write a Comment
User Comments (0)
About PowerShow.com