Professional Documents
Culture Documents
SystemC
Language Reference
Manual
Sponsored by the
Design Automation Standards Committee
IEEE
3 Park Avenue
New York, NY 10016-5997
USA
9 January 2012
IEEE Computer Society
IEEE Std 1666"-2011
(Revision of
IEEE Std 1666-2005)
IEEE Std 1666
-2011
(Revision of
IEEE Std 1666-2005)
IEEE Standard for Standard
SystemC
Language Reference
Manual
Sponsor
Design Automation Standards Committee
of the
IEEE Computer Society
Approved 10 September 2011
IEEE-SA Standards Board
The Institute of Electrical and Electronics Engineers, Inc.
3 Park Avenue, New York, NY 10016-5997, USA
Copyright 2012 by the Institute of Electrical and Electronics Engineers, Inc.
All rights reserved. Published 9 January 2012. Printed in the United States of America.
IEEE is a registered trademark in the U.S. Patent & Trademark Office, owned by the Institute of Electrical and Electronics
Engineers, Incorporated.
SystemC is a registered trademark in the U.S. Patent & Trademark Office, owned by the Accellera Systems Initiative.
Print: ISBN978-0-7381-6801-2 STD97162
PDF: ISBN978-0-7381-6802-9 STDPD97162
IEEE prohibits discrimination, harassment, and bullying. For more information, visit http://www.ieee.org/web/aboutus/
whatis/policies/p9-26.html.
No part of this publication may be reproduced in any form, in an electronic retrieval system or otherwise, without the prior
written permission of the publisher.
Grateful acknowledgment is made to the Open SystemC Initiative (OSCI) for the permission to use
the following source material:
OSCI TLM Language Reference Manual Version 2.0.1
Note that a merger of OSCI and Accellera, announced on 5 December 2011, created a new
organization, Accellera Systems Initiative.
Abstract: SystemC
Language Reference
Manual .
v
Copyright 2012 IEEE. All rights reserved.
Updating of IEEE documents
Users of IEEE standards shoul d be aware that these documents may be superseded at any time by
the i ssuance of new editions or may be amended from time to time through the issuance of
amendments, corrigenda, or errata. An offi ci al I EEE document at any point in time consi sts of the
current edi tion of the document together with any amendments, corrigenda, or errata then i n eff ect.
I n order to determi ne whether a gi ven document is the current edition and whether it has been
amended through the issuance of amendments, corrigenda, or errata, visit the I EEE Standards
Associati on websi te at http://ieeexplore.i eee.org/xpl/standards.j sp, or contact the I EEE at the address
li sted previ ously.
For more informati on about the I EEE Standards Associati on or the I EEE standards development process,
visit the IEEE-SA website at http://standards.ieee.org.
Errata
Errata, i f any, f or this and al l other standards can be accessed at the f ol lowi ng URL: http://
standards.ieee.org/fi ndstds/errata/i ndex.html. Users are encouraged to check thi s URL f or errata
periodicall y.
Interpretations
Current i nterpretations can be accessed at the foll owing URL: http://standards.ieee.org/fi ndstds/
interps/index.html.
Patents
Attenti on is call ed to the possibil ity that i mplementati on of thi s standard may requi re use of subject matter
covered by patent rights. By publ icati on of thi s standard, no posi ti on is taken with respect to the exi stence or
val idi ty of any patent ri ghts i n connection therewith. The IEEE shall not be responsibl e f or identif ying
patents or patent appl icati ons for whi ch a l icense may be requi red to i mplement an I EEE standard or for
conducti ng inquiries i nto the legal val idity or scope of those patents that are brought to its attenti on.
vi
Copyright 2012 IEEE. All rights reserved.
Participants
This entity-based standard was created under the leadershi p of the fol lowi ng i ndi vi dual s:
Stan Krolikoski, Chai r
JeromeCornet, Vi ce Chai r
John Aynsley, Techni cal Lead and Author
David Long, Co-Author (SystemC Data Types)
DennisBrophy, Secretar y
SofieVandeputte, Typogr aphi cal Edi tor
At the time this enti ty-based standard was completed, the LRM Worki ng Group had the f oll owing
membership:
The f ol lowi ng members of the enti ty-based bal loting commi ttee voted on this standard. Bal loti ng enti ti es
may have voted for approval, disapproval, or abstention.
The worki ng group gratef ul ly acknowledges the contributi ons of the f ol lowi ng participants:
Accel l era Organi zati on
Cadence Design Systems
Freescal e Semi conductors
I ntel Corporati on
JEITA
Mentor Graphi cs
NXP Semi conductors
OSCI
STARC
STMi croel ectroni cs
Synopsys
Texas I nstruments
Accel l era Organi zati on
Cadence Desi gn Systems
I ntel Corporati on
JEI TA
Mentor Graphi cs
NXP Semi conductors
OSCI
Qual comm Incorporated
SGCC
STARC
STMi croel ectroni cs
Synopsys
Texas I nstruments
John Aynsl ey
Bi shnupri ya Bhattacharya
Davi d C. Bl ack
Jerome Cornet
Al an Fitch
Mark Gl asser
Puneet Goel
Andy Goodrich
Phil i pp A. Hartmann
Hi roshi I mai
Marti n Janssen
Tor Jeremiassen
Davi d Long
Mi chael McNamara
Mi ke Meredi th
Eric E. Roesl er
Stuart Swan
Bart Vanthournout
Yossi Vel l er
Kaz Yoshi naga
vii
Copyright 2012 IEEE. All rights reserved.
When the I EEE-SA Standards Board approved this standard on 10 September 2011, it had the f oll owing
membership:
Richard H. Hulett, Chai r
John Kulick, Vi ce Chai r
Robert Grow, Past Chai r
Judith Gorman, Secr etary
* Member Emeri tus
Al so included are the fol lowing nonvoti ng I EEE-SA Standards Board l iaisons:
Satish K. Aggarwal, NRC Repr esentati ve
Ri chard DeBlasi o, DOE Repr esentati ve
Al an H. Cookson, NI ST Repr esentati ve
Mi chel l e D. Turner
I EEE Standar ds Pr ogram Manager , Document Devel opment
Joan Wool ery
I EEE Standar ds Pr ogr am Manager , Techni cal Pr ogr amDevel opment
Masayuki Ariyoshi
Wi ll i am Bartl ey
Ted Burse
Cl i nt Chapl i n
Wael Di ab
Jean-Phi l i ppe Faure
Al ex Gel man
Paul Houz
Ji m Hughes
Joseph L. Koepf i nger*
Davi d Law
Thomas Lee
Hung Li ng
Ol eg Logvi nov
Ted Ol sen
Gary Robi nson
Jon Rosdahl
Sam Sci acca
Mi ke Seavey
Curti s Si l l er
Phil Wi nston
Howard Wolf man
Don Wri ght
vii i
Copyright 2012 IEEE. All rights reserved.
Contents
1. Overview.............................................................................................................................................. 1
1.1 Scope............................................................................................................................................ 1
1.2 Purpose......................................................................................................................................... 1
1.3 Subsets......................................................................................................................................... 2
1.4 Relationshi p withC++................................................................................................................. 2
1.5 Gui dancefor readers.................................................................................................................... 2
2. Normativereferences........................................................................................................................... 4
3. Termi nol ogy and conventi ons used i n this standard............................................................................ 5
3.1 Terminology................................................................................................................................. 5
3.1.1 Shal l, shoul d, may, can.................................................................................................... 5
3.1.2 Implementati on, appl icati on............................................................................................ 5
3.1.3 Call , call ed from, deri ved from........................................................................................ 5
3.1.4 Specifi ctechnical terms................................................................................................... 5
3.2 Syntacti cal conventions............................................................................................................... 7
3.2.1 Implementati on-defined................................................................................................... 7
3.2.2 Di sabled........................................................................................................................... 7
3.2.3 Ell ipsis (...)....................................................................................................................... 7
3.2.4 Classnames...................................................................................................................... 7
3.2.5 Embolded text .................................................................................................................. 8
3.3 Semanti c conventi ons.................................................................................................................. 8
3.3.1 Classdefi ni ti ons and theinheri tancehierarchy ............................................................... 8
3.3.2 Functi ondefi niti onsand side-effects............................................................................... 8
3.3.3 Functionswhosereturn typeis areferenceor apointer .................................................. 8
3.3.4 Namespaces and internal nami ng.................................................................................. 10
3.3.5 Non-compliant applicati ons and errors.......................................................................... 11
3.4 Notes and exampl es................................................................................................................... 11
4. Elaborati onand si mulati on semanti cs............................................................................................... 12
4.1 El aboration................................................................................................................................. 12
4.1.1 Instanti ati on ................................................................................................................... 12
4.1.2 Process macros............................................................................................................... 14
4.1.3 Port bi nding and export binding.................................................................................... 14
4.1.4 Setti ng thetimeresolution............................................................................................. 15
4.2 Si mulati on.................................................................................................................................. 15
4.2.1 Thescheduli ngalgorithm.............................................................................................. 16
4.2.2 Ini ti al ization, cycles, and pauses in thescheduling algori thm....................................... 19
4.3 Running el aboration and si mulati on.......................................................................................... 20
4.3.1 Function declarations..................................................................................................... 20
4.3.2 Function sc_el ab_and_sim............................................................................................. 20
4.3.3 Functionssc_argc andsc_argv ...................................................................................... 21
4.3.4 Runni ng under appli cation control usi ngfunctions sc_main and sc_start..................... 21
4.3.5 Runni ngunder control of thekernel .............................................................................. 23
4.4 El aboration and si mulation call backs........................................................................................ 23
4.4.1 before_end_of_elaborati on............................................................................................ 24
4.4.2 end_of_elaboration........................................................................................................ 25
4.4.3 start_of_si mulation........................................................................................................ 26
ix
Copyright 2012 IEEE. All rights reserved.
4.4.4 end_of_simul ati on ......................................................................................................... 27
4.5 Other functi ons rel ated to the scheduler .................................................................................... 27
4.5.1 Function declarations..................................................................................................... 27
4.5.2 Function sc_pause.......................................................................................................... 28
4.5.3 Functi on sc_stop, sc_set_stop_mode, and sc_get_stop_mode ...................................... 29
4.5.4 Function sc_ti me_stamp ................................................................................................ 30
4.5.5 Function sc_del ta_count ................................................................................................ 31
4.5.6 Function sc_is_running.................................................................................................. 31
4.5.7 Functi ons to detect pending activity .............................................................................. 31
4.5.8 Function sc_get_status................................................................................................... 32
5. Core language class defi ni ti ons......................................................................................................... 35
5.1 Cl ass header fi les....................................................................................................................... 35
5.1.1 #include "systemc"......................................................................................................... 35
5.1.2 #include "systemc.h" ...................................................................................................... 35
5.2 sc_modul e.................................................................................................................................. 37
5.2.1 Descripti on..................................................................................................................... 37
5.2.2 Class defi nition .............................................................................................................. 37
5.2.3 Constraints on usage...................................................................................................... 39
5.2.4 kind ................................................................................................................................ 39
5.2.5 SC_MODULE ............................................................................................................... 40
5.2.6 Constructors................................................................................................................... 40
5.2.7 SC_CTOR...................................................................................................................... 40
5.2.8 SC_HAS_PROCESS..................................................................................................... 41
5.2.9 SC_METHOD, SC_THREAD, SC_CTHREAD........................................................... 42
5.2.10 Method process.............................................................................................................. 43
5.2.11 Thread and cl ocked thread processes............................................................................. 43
5.2.12 Clocked thread processes............................................................................................... 44
5.2.13 reset_si gnal _i s and async_reset_si gnal _is..................................................................... 46
5.2.14 sensitive ......................................................................................................................... 48
5.2.15 dont_initial ize ................................................................................................................ 48
5.2.16 set_stack_si ze................................................................................................................. 49
5.2.17 next_trigger .................................................................................................................... 50
5.2.18 wait................................................................................................................................. 52
5.2.19 Posi ti onal port binding................................................................................................... 53
5.2.20 bef ore_end_of _el aboration, end_of_elaborati on, start_of _si mulati on,
end_of _simulati on ......................................................................................................... 55
5.2.21 get_chil d_objects and get_chi ld_events ........................................................................ 55
5.2.22 sc_gen_unique_name..................................................................................................... 56
5.2.23 sc_behavior and sc_channel ........................................................................................... 56
5.3 sc_modul e_name ....................................................................................................................... 57
5.3.1 Descripti on..................................................................................................................... 57
5.3.2 Class defi nition .............................................................................................................. 57
5.3.3 Constraints on usage...................................................................................................... 58
5.3.4 Module hierarchy ........................................................................................................... 58
5.3.5 Member f unctions.......................................................................................................... 58
5.4 sc_sensitive.............................................................................................................................. 60
5.4.1 Descripti on..................................................................................................................... 60
5.4.2 Class defi nition .............................................................................................................. 60
5.4.3 Constraints on usage...................................................................................................... 60
5.4.4 operator<<...................................................................................................................... 60
5.5 sc_spawn_opti ons and sc_spawn............................................................................................... 61
5.5.1 Descripti on..................................................................................................................... 61
x
Copyright 2012 IEEE. All rights reserved.
5.5.2 Class defi nition .............................................................................................................. 61
5.5.3 Constraints on usage...................................................................................................... 62
5.5.4 Constructors................................................................................................................... 62
5.5.5 Member f unctions.......................................................................................................... 63
5.5.6 sc_spawn........................................................................................................................ 64
5.5.7 SC_FORK and SC_JOIN............................................................................................... 66
5.6 sc_process_handl e ..................................................................................................................... 67
5.6.1 Descripti on..................................................................................................................... 67
5.6.2 Class defi nition .............................................................................................................. 68
5.6.3 Constraints on usage...................................................................................................... 69
5.6.4 Constructors................................................................................................................... 69
5.6.5 Member f unctions.......................................................................................................... 69
5.6.6 Member f unctions f or process control ........................................................................... 73
5.6.7 sc_get_current_process_handle ..................................................................................... 88
5.6.8 sc_i s_unwinding ............................................................................................................ 89
5.7 sc_event_finder and sc_event_fi nder_t ..................................................................................... 90
5.7.1 Descripti on..................................................................................................................... 90
5.7.2 Class defi nition .............................................................................................................. 90
5.7.3 Constraints on usage...................................................................................................... 90
5.8 sc_event_and_li st and sc_event_or_li st ..................................................................................... 92
5.8.1 Descripti on..................................................................................................................... 92
5.8.2 Class defi nition .............................................................................................................. 92
5.8.3 Constraints and usage .................................................................................................... 93
5.8.4 Constructors, destructor, assi gnment ............................................................................. 93
5.8.5 Member f unctions and operators ................................................................................... 94
5.9 sc_event_and_exprand sc_event_or_expr............................................................................ 95
5.9.1 Descripti on..................................................................................................................... 95
5.9.2 Class defi nition .............................................................................................................. 95
5.9.3 Constraints on usage...................................................................................................... 96
5.9.4 Operators........................................................................................................................ 96
5.10 sc_event ..................................................................................................................................... 97
5.10.1 Descripti on..................................................................................................................... 97
5.10.2 Class defi nition .............................................................................................................. 97
5.10.3 Constraints on usage...................................................................................................... 98
5.10.4 Constructors, destructor, and event naming.................................................................. 98
5.10.5 Functi ons f or nami ng and hi erarchy traversal .............................................................. 99
5.10.6 notif y and cancel .......................................................................................................... 100
5.10.7 Event l ists..................................................................................................................... 101
5.10.8 Mul tipl e event notif icati ons......................................................................................... 101
5.11 sc_time..................................................................................................................................... 101
5.11.1 Descripti on................................................................................................................... 101
5.11.2 Class defi nition ............................................................................................................ 101
5.11.3 Time resolution............................................................................................................ 102
5.11.4 Function sc_max_time................................................................................................. 103
5.11.5 Functions and operators............................................................................................... 103
5.11.6 SC_ZERO_TIME ........................................................................................................ 103
5.12 sc_port...................................................................................................................................... 104
5.12.1 Descripti on................................................................................................................... 104
5.12.2 Class defi nition ............................................................................................................ 104
5.12.3 Template parameters.................................................................................................... 105
5.12.4 Constraints on usage.................................................................................................... 106
5.12.5 Constructors................................................................................................................. 107
5.12.6 kind .............................................................................................................................. 107
5.12.7 Named port binding ..................................................................................................... 108
xi
Copyright 2012 IEEE. All rights reserved.
5.12.8 Member functi ons for bound ports and port-to-port binding....................................... 109
5.12.9 bef ore_end_of _el aboration, end_of_elaborati on, start_of _si mulati on,
end_of _simulati on ....................................................................................................... 112
5.13 sc_export .................................................................................................................................. 113
5.13.1 Descripti on................................................................................................................... 113
5.13.2 Class defi nition ............................................................................................................ 113
5.13.3 Template parameters.................................................................................................... 114
5.13.4 Constraints on usage.................................................................................................... 114
5.13.5 Constructors................................................................................................................. 114
5.13.6 kind .............................................................................................................................. 114
5.13.7 Export bindi ng ............................................................................................................. 115
5.13.8 Member functi ons for bound exports and export-to-export binding ........................... 116
5.13.9 bef ore_end_of _el aboration, end_of_elaborati on, start_of _si mulati on,
end_of _simulati on ....................................................................................................... 117
5.14 sc_i nterface.............................................................................................................................. 117
5.14.1 Descripti on................................................................................................................... 117
5.14.2 Class defi nition ............................................................................................................ 117
5.14.3 Constraints on usage.................................................................................................... 118
5.14.4 register_port ................................................................................................................. 118
5.14.5 def aul t_event ................................................................................................................ 119
5.15 sc_prim_channel ...................................................................................................................... 119
5.15.1 Descripti on................................................................................................................... 119
5.15.2 Class defi nition ............................................................................................................ 119
5.15.3 Constraints on usage.................................................................................................... 121
5.15.4 Constructors, destructor, and hierarchi cal names........................................................ 121
5.15.5 kind .............................................................................................................................. 121
5.15.6 request_update and update........................................................................................... 121
5.15.7 next_trigger and wait ................................................................................................... 123
5.15.8 bef ore_end_of _el aboration, end_of_elaborati on, start_of _si mulati on,
end_of _simulati on ....................................................................................................... 123
5.16 sc_obj ect .................................................................................................................................. 124
5.16.1 Descripti on................................................................................................................... 124
5.16.2 Class defi nition ............................................................................................................ 124
5.16.3 Constraints on usage.................................................................................................... 125
5.16.4 Constructors and destructor ......................................................................................... 126
5.16.5 name, basename, and ki nd........................................................................................... 126
5.16.6 pri nt and dump............................................................................................................. 127
5.16.7 Functi ons f or obj ect hi erarchy traversal ...................................................................... 127
5.16.8 Member f uncti ons f or attri butes .................................................................................. 129
5.17 Hi erarachi cal nami ng of obj ects and events............................................................................ 130
5.18 sc_attr_base.............................................................................................................................. 131
5.18.1 Descripti on................................................................................................................... 131
5.18.2 Class defi nition ............................................................................................................ 131
5.18.3 Member f unctions........................................................................................................ 132
5.19 sc_attribute............................................................................................................................... 132
5.19.1 Descripti on................................................................................................................... 132
5.19.2 Class defi nition ............................................................................................................ 132
5.19.3 Template parameters.................................................................................................... 132
5.19.4 Member f uncti ons and data members.......................................................................... 132
5.20 sc_attr_cl tn............................................................................................................................... 133
5.20.1 Descripti on................................................................................................................... 133
5.20.2 Class defi nition ............................................................................................................ 133
5.20.3 Constraints on usage.................................................................................................... 133
5.20.4 Iterators........................................................................................................................ 133
xii
Copyright 2012 IEEE. All rights reserved.
6. Predefi ned channel class def ini ti ons................................................................................................ 135
6.1 sc_si gnal_i n_i f ......................................................................................................................... 135
6.1.1 Descripti on................................................................................................................... 135
6.1.2 Class defi nition ............................................................................................................ 135
6.1.3 Member f unctions........................................................................................................ 135
6.2 sc_signal_in_if <bool > and sc_signal _i n_if <sc_dt::sc_logic>................................................. 136
6.2.1 Descripti on................................................................................................................... 136
6.2.2 Class defi nition ............................................................................................................ 136
6.2.3 Member f unctions........................................................................................................ 137
6.3 sc_si gnal_i nout_i f .................................................................................................................... 137
6.3.1 Descripti on................................................................................................................... 137
6.3.2 Class defi nition ............................................................................................................ 137
6.3.3 Member f unctions........................................................................................................ 138
6.4 sc_si gnal ................................................................................................................................... 139
6.4.1 Descripti on................................................................................................................... 139
6.4.2 Class defi nition ............................................................................................................ 139
6.4.3 Template parameter T.................................................................................................. 140
6.4.4 Reading and writing si gnal s......................................................................................... 140
6.4.5 Constructors................................................................................................................. 141
6.4.6 register_port ................................................................................................................. 141
6.4.7 Member f unctions f or reading ..................................................................................... 141
6.4.8 Member functi ons for wri ti ng...................................................................................... 142
6.4.9 Member f unctions f or events....................................................................................... 142
6.4.10 Di agnostic member f uncti ons...................................................................................... 143
6.4.11 operator<<.................................................................................................................... 143
6.5 sc_signal<bool,WRI TER_POLICY> and sc_signal<sc_dt::sc_logic,WRI TER_POLI CY> .. 144
6.5.1 Descripti on................................................................................................................... 144
6.5.2 Class defi nition ............................................................................................................ 144
6.5.3 Member f unctions........................................................................................................ 146
6.6 sc_buf fer .................................................................................................................................. 147
6.6.1 Descripti on................................................................................................................... 147
6.6.2 Class defi nition ............................................................................................................ 147
6.6.3 Constructors................................................................................................................. 147
6.6.4 Member f unctions........................................................................................................ 148
6.7 sc_cl ock ................................................................................................................................... 149
6.7.1 Descripti on................................................................................................................... 149
6.7.2 Class defi nition ............................................................................................................ 149
6.7.3 Characteri stic properties.............................................................................................. 150
6.7.4 Constructors................................................................................................................. 150
6.7.5 write............................................................................................................................. 151
6.7.6 Diagnostic member functi ons...................................................................................... 151
6.7.7 bef ore_end_of_elaborati on .......................................................................................... 151
6.7.8 sc_i n_clk ...................................................................................................................... 151
6.8 sc_i n......................................................................................................................................... 152
6.8.1 Descripti on................................................................................................................... 152
6.8.2 Class defi nition ............................................................................................................ 152
6.8.3 Member f unctions........................................................................................................ 153
6.8.4 Function sc_trace......................................................................................................... 153
6.8.5 end_of_elaboration ...................................................................................................... 153
6.9 sc_i n<bool > and sc_i n<sc_dt::sc_logic>................................................................................. 153
6.9.1 Descripti on................................................................................................................... 153
6.9.2 Class defi nition ............................................................................................................ 154
6.9.3 Member f unctions........................................................................................................ 155
xii i
Copyright 2012 IEEE. All rights reserved.
6.10 sc_i nout .................................................................................................................................... 156
6.10.1 Descripti on................................................................................................................... 156
6.10.2 Class defi nition ............................................................................................................ 156
6.10.3 Member f unctions........................................................................................................ 157
6.10.4 ini ti al ize ....................................................................................................................... 157
6.10.5 Function sc_trace......................................................................................................... 157
6.10.6 end_of_elaborati on ...................................................................................................... 158
6.10.7 Bindi ng......................................................................................................................... 158
6.11 sc_i nout<bool> and sc_inout<sc_dt::sc_l ogi c> ...................................................................... 158
6.11.1 Descripti on................................................................................................................... 158
6.11.2 Class defi nition ............................................................................................................ 158
6.11.3 Member f unctions........................................................................................................ 160
6.12 sc_out ....................................................................................................................................... 160
6.12.1 Descripti on................................................................................................................... 160
6.12.2 Class defi nition ............................................................................................................ 160
6.12.3 Member f unctions........................................................................................................ 161
6.13 sc_si gnal_resolved................................................................................................................... 161
6.13.1 Descripti on................................................................................................................... 161
6.13.2 Class defi nition ............................................................................................................ 161
6.13.3 Constructors................................................................................................................. 162
6.13.4 Resol ution semantics................................................................................................... 162
6.13.5 Member f unctions........................................................................................................ 163
6.14 sc_i n_resol ved ......................................................................................................................... 164
6.14.1 Descripti on................................................................................................................... 164
6.14.2 Class defi nition ............................................................................................................ 164
6.14.3 Member f unctions........................................................................................................ 165
6.15 sc_i nout_resolved .................................................................................................................... 165
6.15.1 Descripti on................................................................................................................... 165
6.15.2 Class defi nition ............................................................................................................ 165
6.15.3 Member f unctions........................................................................................................ 166
6.16 sc_out_resol ved ....................................................................................................................... 166
6.16.1 Descripti on................................................................................................................... 166
6.16.2 Class defi nition ............................................................................................................ 166
6.16.3 Member f unctions........................................................................................................ 167
6.17 sc_si gnal_rv ............................................................................................................................. 167
6.17.1 Descripti on................................................................................................................... 167
6.17.2 Class defi nition ............................................................................................................ 167
6.17.3 Semantics and member functi ons ................................................................................ 167
6.18 sc_i n_rv.................................................................................................................................... 168
6.18.1 Descripti on................................................................................................................... 168
6.18.2 Class defi nition ............................................................................................................ 168
6.18.3 Member f unctions........................................................................................................ 169
6.19 sc_i nout_rv............................................................................................................................... 169
6.19.1 Descripti on................................................................................................................... 169
6.19.2 Class defi nition ............................................................................................................ 169
6.19.3 Member f unctions........................................................................................................ 170
6.20 sc_out_rv.................................................................................................................................. 170
6.20.1 Descripti on................................................................................................................... 170
6.20.2 Class defi nition ............................................................................................................ 170
6.20.3 Member f unctions........................................................................................................ 171
6.21 sc_f if o_in_if ............................................................................................................................. 171
6.21.1 Descripti on................................................................................................................... 171
6.21.2 Class defi nition ............................................................................................................ 171
6.21.3 Member f unctions........................................................................................................ 172
xiv
Copyright 2012 IEEE. All rights reserved.
6.22 sc_f if o_out_if ........................................................................................................................... 172
6.22.1 Descripti on................................................................................................................... 172
6.22.2 Class defi nition ............................................................................................................ 172
6.22.3 Member f unctions........................................................................................................ 173
6.23 sc_f if o ...................................................................................................................................... 173
6.23.1 Descripti on................................................................................................................... 173
6.23.2 Class defi nition ............................................................................................................ 173
6.23.3 Template parameter T.................................................................................................. 174
6.23.4 Constructors................................................................................................................. 175
6.23.5 register_port ................................................................................................................. 175
6.23.6 Member f uncti ons f or reading ..................................................................................... 175
6.23.7 Member functi ons for wri ting...................................................................................... 176
6.23.8 The update phase ......................................................................................................... 176
6.23.9 Member f uncti ons f or events....................................................................................... 177
6.23.10Member f uncti ons for avail abl e values and f ree sl ots ................................................. 177
6.23.11Diagnostic member functi ons...................................................................................... 177
6.23.12operator<<.................................................................................................................... 177
6.24 sc_f if o_in ................................................................................................................................. 178
6.24.1 Descripti on................................................................................................................... 178
6.24.2 Class defi nition ............................................................................................................ 178
6.24.3 Member f unctions........................................................................................................ 179
6.25 sc_f if o_out ............................................................................................................................... 179
6.25.1 Descripti on................................................................................................................... 179
6.25.2 Class defi nition ............................................................................................................ 179
6.25.3 Member f unctions........................................................................................................ 180
6.26 sc_mutex_i f .............................................................................................................................. 182
6.26.1 Descripti on................................................................................................................... 182
6.26.2 Class defi nition ............................................................................................................ 182
6.26.3 Member f unctions........................................................................................................ 182
6.27 sc_mutex .................................................................................................................................. 182
6.27.1 Descripti on................................................................................................................... 182
6.27.2 Class defi nition ............................................................................................................ 182
6.27.3 Constructors................................................................................................................. 183
6.27.4 Member f unctions........................................................................................................ 183
6.28 sc_semaphore_if ...................................................................................................................... 184
6.28.1 Descripti on................................................................................................................... 184
6.28.2 Class defi nition ............................................................................................................ 184
6.28.3 Member f unctions........................................................................................................ 184
6.29 sc_semaphore........................................................................................................................... 185
6.29.1 Descripti on................................................................................................................... 185
6.29.2 Class defi nition ............................................................................................................ 185
6.29.3 Constructors................................................................................................................. 185
6.29.4 Member f unctions........................................................................................................ 185
6.30 sc_event_queue........................................................................................................................ 186
6.30.1 Descripti on................................................................................................................... 186
6.30.2 Class defi nition ............................................................................................................ 186
6.30.3 Constraints on usage.................................................................................................... 187
6.30.4 Constructors................................................................................................................. 187
6.30.5 kind .............................................................................................................................. 187
6.30.6 Member f unctions........................................................................................................ 187
7. SystemC data types.......................................................................................................................... 189
7.1 I ntroducti on.............................................................................................................................. 189
xv
Copyright 2012 IEEE. All rights reserved.
7.2 Common characteri stics........................................................................................................... 191
7.2.1 Ini ti al izati on and assi gnment operators....................................................................... 192
7.2.2 Precision of ari thmetic expressi ons............................................................................. 193
7.2.3 Base class default word length..................................................................................... 193
7.2.4 Word l ength ................................................................................................................. 194
7.2.5 Bit-select ...................................................................................................................... 194
7.2.6 Part-select..................................................................................................................... 195
7.2.7 Concatenati on .............................................................................................................. 196
7.2.8 Reduction operators..................................................................................................... 197
7.2.9 Integer conversi on........................................................................................................ 198
7.2.10 String input and output ................................................................................................ 198
7.2.11 Conversi on of appl icati on-def ined types in integer expressi ons ................................. 199
7.3 Stri ng l iterals............................................................................................................................ 199
7.4 sc_value_base........................................................................................................................ 201
7.4.1 Descripti on................................................................................................................... 201
7.4.2 Class defi nition ............................................................................................................ 201
7.4.3 Constraints on usage.................................................................................................... 201
7.4.4 Member f unctions........................................................................................................ 202
7.5 Li mited-preci si on i nteger types............................................................................................... 202
7.5.1 Type defi ni ti ons........................................................................................................... 202
7.5.2 sc_i nt_base................................................................................................................... 203
7.5.3 sc_uint_base................................................................................................................. 208
7.5.4 sc_i nt ............................................................................................................................ 213
7.5.5 sc_uint .......................................................................................................................... 215
7.5.6 Bit-selects..................................................................................................................... 217
7.5.7 Part-selects................................................................................................................... 222
7.6 Fi ni te-preci si on i nteger types................................................................................................... 227
7.6.1 Type defi ni ti ons........................................................................................................... 227
7.6.2 Constraints on usage.................................................................................................... 227
7.6.3 sc_signed...................................................................................................................... 227
7.6.4 sc_unsi gned.................................................................................................................. 234
7.6.5 sc_bigi nt ....................................................................................................................... 240
7.6.6 sc_biguint ..................................................................................................................... 242
7.6.7 Bit-selects..................................................................................................................... 244
7.6.8 Part-selects................................................................................................................... 248
7.7 I nteger concatenations ............................................................................................................. 253
7.7.1 Descripti on................................................................................................................... 253
7.7.2 Class defi nition ............................................................................................................ 253
7.7.3 Constraints on usage.................................................................................................... 255
7.7.4 Assi gnment operators .................................................................................................. 255
7.7.5 Implici t type conversion .............................................................................................. 255
7.7.6 Explici t type conversion .............................................................................................. 255
7.7.7 Other member functions .............................................................................................. 256
7.8 Generi c base proxy class.......................................................................................................... 256
7.8.1 Descripti on................................................................................................................... 256
7.8.2 Class defi nition ............................................................................................................ 256
7.8.3 Constraints on usage.................................................................................................... 256
7.9 Logic and vector types............................................................................................................. 257
7.9.1 Type defi ni ti ons........................................................................................................... 257
7.9.2 sc_l ogi c ........................................................................................................................ 257
7.9.3 sc_bv_base................................................................................................................... 262
7.9.4 sc_l v_base.................................................................................................................... 267
7.9.5 sc_bv ............................................................................................................................ 273
7.9.6 sc_l v ............................................................................................................................. 275
xvi
Copyright 2012 IEEE. All rights reserved.
7.9.7 Bit-selects..................................................................................................................... 277
7.9.8 Part-selects................................................................................................................... 280
7.9.9 Concatenati ons............................................................................................................. 286
7.10 Fi xed-poi nt types..................................................................................................................... 293
7.10.1 Fixed-point representati on ........................................................................................... 293
7.10.2 Fixed-point type conversi on ........................................................................................ 294
7.10.3 Fixed-point data types.................................................................................................. 295
7.10.4 Fixed-point expressions and operations....................................................................... 296
7.10.5 Bit and part selecti on ................................................................................................... 299
7.10.6 Variable-preci si on f ixed-point value li mits................................................................. 300
7.10.7 Fixed-poi nt word l ength and mode.............................................................................. 300
7.10.8 Conversi ons to character stri ng.................................................................................... 302
7.10.9 Finite word-l ength ef fects............................................................................................ 304
7.10.10sc_f xnum...................................................................................................................... 327
7.10.11sc_f xnum_f ast .............................................................................................................. 332
7.10.12sc_f xval ........................................................................................................................ 337
7.10.13sc_f xval_f ast ................................................................................................................ 341
7.10.14sc_f ix............................................................................................................................ 346
7.10.15sc_ufi x.......................................................................................................................... 349
7.10.16sc_f ix_fast .................................................................................................................... 352
7.10.17sc_ufi x_fast .................................................................................................................. 355
7.10.18sc_f ixed........................................................................................................................ 358
7.10.19sc_ufi xed...................................................................................................................... 360
7.10.20sc_f ixed_f ast ................................................................................................................ 362
7.10.21sc_ufi xed_f ast .............................................................................................................. 365
7.10.22Bit-selects..................................................................................................................... 367
7.10.23Part-sel ects................................................................................................................... 369
7.11 Contexts ................................................................................................................................... 375
7.11.1 sc_l ength_param.......................................................................................................... 375
7.11.2 sc_l ength_context ........................................................................................................ 377
7.11.3 sc_f xtype_params ........................................................................................................ 378
7.11.4 sc_f xtype_context ........................................................................................................ 380
7.11.5 sc_f xcast_switch .......................................................................................................... 381
7.11.6 sc_f xcast_context ......................................................................................................... 382
7.12 Control of stri ng representati on ............................................................................................... 383
7.12.1 Descripti on................................................................................................................... 383
7.12.2 Class defi nition ............................................................................................................ 383
7.12.3 Functions...................................................................................................................... 384
8. SystemC util ities.............................................................................................................................. 385
8.1 Trace fi les ................................................................................................................................ 385
8.1.1 Class defi ni ti on and f unction declarations................................................................... 385
8.1.2 sc_trace_fi le................................................................................................................. 385
8.1.3 sc_create_vcd_trace_f il e.............................................................................................. 386
8.1.4 sc_close_vcd_trace_f ile............................................................................................... 386
8.1.5 sc_write_comment ....................................................................................................... 386
8.1.6 sc_trace ........................................................................................................................ 386
8.2 sc_report................................................................................................................................... 388
8.2.1 Descripti on................................................................................................................... 388
8.2.2 Class defi nition ............................................................................................................ 388
8.2.3 Constraints on usage.................................................................................................... 389
8.2.4 sc_verbosi ty ................................................................................................................. 389
8.2.5 sc_severity ................................................................................................................... 389
xvii
Copyright 2012 IEEE. All rights reserved.
8.2.6 Copy constructor and assignment ................................................................................ 390
8.2.7 Member f unctions........................................................................................................ 390
8.3 sc_report_handl er..................................................................................................................... 391
8.3.1 Descripti on................................................................................................................... 391
8.3.2 Class defi nition ............................................................................................................ 391
8.3.3 Constraints on usage.................................................................................................... 393
8.3.4 sc_actions..................................................................................................................... 393
8.3.5 report ............................................................................................................................ 393
8.3.6 set_acti ons.................................................................................................................... 394
8.3.7 stop_af ter ..................................................................................................................... 395
8.3.8 get_count...................................................................................................................... 396
8.3.9 Verbosity l evel ............................................................................................................. 396
8.3.10 suppress and force........................................................................................................ 396
8.3.11 set_handler ................................................................................................................... 397
8.3.12 get_new_acti on_i d....................................................................................................... 398
8.3.13 sc_i nterrupt_here and sc_stop_here............................................................................. 398
8.3.14 get_cached_report and cl ear_cached_report................................................................ 398
8.3.15 set_l og_f il e_name and get_log_fi le_name.................................................................. 399
8.4 sc_exception............................................................................................................................. 399
8.4.1 Descripti on................................................................................................................... 399
8.4.2 Class defi nition ............................................................................................................ 399
8.5 sc_vector .................................................................................................................................. 400
8.5.1 Descripti on................................................................................................................... 400
8.5.2 Class defi nition ............................................................................................................ 400
8.5.3 Constraints on usage.................................................................................................... 403
8.5.4 Constructors and destructors........................................................................................ 403
8.5.5 ini t and create_element ................................................................................................ 404
8.5.6 kind, si ze, get_el ements............................................................................................... 405
8.5.7 operator[ ] and at ........................................................................................................... 406
8.5.8 Iterators........................................................................................................................ 406
8.5.9 bind .............................................................................................................................. 406
8.5.10 sc_assemble_vector ..................................................................................................... 408
8.6 Util ity f unctions....................................................................................................................... 410
8.6.1 Function declarations................................................................................................... 410
8.6.2 sc_abs........................................................................................................................... 411
8.6.3 sc_max ......................................................................................................................... 411
8.6.4 sc_mi n.......................................................................................................................... 411
8.6.5 Version and copyright.................................................................................................. 411
9. Overview of TLM-2.0...................................................................................................................... 413
9.1 Compl iance with the TLM-2.0 standard.................................................................................. 414
10. Introduction to TLM-2.0.................................................................................................................. 415
10.1 Background.............................................................................................................................. 415
10.2 Transaction-l evel modeli ng, use cases, and abstraction .......................................................... 415
10.3 Coding styles............................................................................................................................ 416
10.3.1 Unti med coding style................................................................................................... 416
10.3.2 Loosely-timed codi ng styl e and temporal decoupli ng................................................. 417
10.3.3 Synchronizati on i n l oosely-timed model s.................................................................... 418
10.3.4 Approximatel y-timed codi ng style .............................................................................. 418
10.3.5 Characterization of loosely-ti med and approximatel y-ti med coding styles ................ 419
10.3.6 Switchi ng between l oosely-timed and approximatel y-timed model ing ...................... 419
xviii
Copyright 2012 IEEE. All rights reserved.
10.3.7 Cycl e-accurate modeli ng ............................................................................................. 419
10.3.8 Blocking versus non-bl ocking transport i nterf aces ..................................................... 419
10.3.9 Use cases and codi ng styles......................................................................................... 420
10.4 I niti ators, targets, sockets, and transacti on bridges ................................................................. 420
10.5 DMI and debug transport interfaces ........................................................................................ 423
10.6 Combi ned interfaces and sockets............................................................................................. 423
10.7 Namespaces ............................................................................................................................. 423
10.8 Header fi les and versi on numbers............................................................................................ 424
10.8.1 Sof tware versi on i nf ormation ...................................................................................... 424
10.8.2 Defi niti ons ................................................................................................................... 424
10.8.3 Rules ............................................................................................................................ 425
11. TLM-2.0 core interf aces.................................................................................................................. 426
11.1 Transport i nterf aces ................................................................................................................. 426
11.1.1 Blocking transport i nterface......................................................................................... 426
11.1.2 Non-blocking transport i nterf ace................................................................................. 430
11.1.3 Timi ng annotati on wi th the transport i nterfaces.......................................................... 438
11.1.4 Mi grati on path from TLM-1........................................................................................ 442
11.2 Di rect memory interface.......................................................................................................... 442
11.2.1 Introduction.................................................................................................................. 442
11.2.2 Class defi nition ............................................................................................................ 443
11.2.3 get_di rect_mem_ptr method........................................................................................ 444
11.2.4 templ ate argument and tlm_generic_payload class..................................................... 445
11.2.5 tl m_dmi cl ass............................................................................................................... 445
11.2.6 invali date_direct_mem_ptr method ............................................................................. 448
11.2.7 DMI versus transport ................................................................................................... 449
11.2.8 DMI and temporal decoupl ing..................................................................................... 449
11.2.9 Opti mizati on using a DMI hi nt .................................................................................... 450
11.3 Debug transport i nterf ace......................................................................................................... 450
11.3.1 Introduction.................................................................................................................. 450
11.3.2 Class defi nition ............................................................................................................ 450
11.3.3 TRANS templ ate argument and tlm_generic_payl oad class....................................... 451
11.3.4 Rules ............................................................................................................................ 451
12. TLM-2.0 gl obal quantum................................................................................................................. 453
12.1 I ntroducti on.............................................................................................................................. 453
12.2 Header fi le................................................................................................................................ 453
12.3 Cl ass def ini tion ........................................................................................................................ 453
12.4 Cl ass tl m_gl obal _quantum ...................................................................................................... 454
13. Combined TLM-2.0 interf aces and sockets..................................................................................... 455
13.1 Combined interfaces ................................................................................................................ 455
13.1.1 Introduction.................................................................................................................. 455
13.1.2 Class defi nition ............................................................................................................ 455
13.2 I nitiator and target sockets....................................................................................................... 456
13.2.1 Introduction.................................................................................................................. 456
13.2.2 Class defi nition ............................................................................................................ 456
13.2.3 Classes tlm_base_ini ti ator_socket_b and tlm_base_target_socket_b.......................... 460
13.2.4 Classes tlm_base_ini tiator_socket and tl m_base_target_socket.................................. 460
13.2.5 Cl asses tlm_initiator_socket and tlm_target_socket .................................................... 461
xix
Copyright 2012 IEEE. All rights reserved.
14. TLM-2.0 generic payl oad ................................................................................................................ 465
14.1 I ntroducti on.............................................................................................................................. 465
14.2 Extensions and interoperabil ity ............................................................................................... 465
14.2.1 Use the generic payload di rectl y, wi th ignorable extensions....................................... 466
14.2.2 Defi ne a new protocol traits class containing a typedef f or tl m_generi c_payload...... 467
14.2.3 Defi ne a new protocol trai ts cl ass and a new transacti on type .................................... 467
14.3 Generic payl oad attri butes and methods.................................................................................. 467
14.4 Cl ass def ini tion ........................................................................................................................ 468
14.5 Generi c payload memory management ................................................................................... 470
14.6 Constructors, assi gnment, and destructor ................................................................................ 474
14.7 Default val ues and modif iabil ity of attributes ......................................................................... 474
14.8 Option attribute........................................................................................................................ 476
14.9 Command attri bute .................................................................................................................. 477
14.10Address attribute..................................................................................................................... 478
14.11Data pointer attribute.............................................................................................................. 479
14.12Data l ength attri bute................................................................................................................ 480
14.13Byte enabl e pointer attribute................................................................................................... 480
14.14Byte enabl e l ength attri bute.................................................................................................... 481
14.15Streaming width attri bute........................................................................................................ 482
14.16DMI all owed attri bute............................................................................................................. 482
14.17Response status attribute......................................................................................................... 483
14.17.1The standard error response......................................................................................... 484
14.18Endianness.............................................................................................................................. 487
14.18.1Introduction.................................................................................................................. 487
14.18.2Rules ............................................................................................................................ 488
14.19Helper f unctions to determine host endi anness ...................................................................... 490
14.19.1Introduction.................................................................................................................. 490
14.19.2Defi ni ti on..................................................................................................................... 490
14.19.3Rules ............................................................................................................................ 491
14.20Helper f unctions f or endi anness conversion........................................................................... 491
14.20.1Introduction.................................................................................................................. 491
14.20.2Defi ni ti on..................................................................................................................... 492
14.20.3Rules ............................................................................................................................ 492
14.21Generi c payload extensions.................................................................................................... 494
14.21.1Introduction.................................................................................................................. 494
14.21.2Rati onal e...................................................................................................................... 494
14.21.3Extensi on pointers, objects and transacti on bri dges.................................................... 495
14.21.4Rules ............................................................................................................................ 495
15. TLM-2.0 base protocol and phases.................................................................................................. 500
15.1 Phases....................................................................................................................................... 500
15.1.1 Introduction.................................................................................................................. 500
15.1.2 Class defi nition ............................................................................................................ 500
15.1.3 Rules ............................................................................................................................ 501
15.2 Base protocol ........................................................................................................................... 502
15.2.1 Introduction.................................................................................................................. 502
15.2.2 Class defi nition ............................................................................................................ 503
15.2.3 Base protocol phase sequences.................................................................................... 503
15.2.4 Permi tted phase transitions.......................................................................................... 505
15.2.5 Ignorable phases .......................................................................................................... 508
15.2.6 Base protocol timi ng parameters and fl ow control ...................................................... 510
15.2.7 Base protocol rul es concerning ti ming annotati on ...................................................... 514
xx
Copyright 2012 IEEE. All rights reserved.
15.2.8 Base protocol rules concerni ng b_transport................................................................. 514
15.2.9 Base protocol rul es concerning request and response ordering................................... 515
15.2.10Base protocol rul es for switching between b_transport and nb_transport ................... 516
15.2.11Other base protocol rules............................................................................................. 517
15.2.12Summary of base protocol transaction ordering rules................................................. 517
15.2.13Guideli nes for creati ng base-protocol-compli ant components.................................... 517
16. TLM-2.0 util iti es.............................................................................................................................. 521
16.1 Conveni ence sockets................................................................................................................ 521
16.1.1 Introduction.................................................................................................................. 521
16.1.2 Simpl e sockets............................................................................................................. 523
16.1.3 Tagged si mple sockets................................................................................................. 529
16.1.4 Multi-sockets ............................................................................................................... 532
16.2 Quantum keeper ....................................................................................................................... 537
16.2.1 Introduction.................................................................................................................. 537
16.2.2 Header f il e.................................................................................................................... 537
16.2.3 Class defi nition ............................................................................................................ 537
16.2.4 General gui del ines f or processes usi ng temporal decoupli ng...................................... 538
16.2.5 Class tlm_quantumkeeper ............................................................................................ 539
16.3 Payload event queue ................................................................................................................ 541
16.3.1 Introduction.................................................................................................................. 541
16.3.2 Header f il e.................................................................................................................... 542
16.3.3 Class defi nition ............................................................................................................ 542
16.3.4 Rules ............................................................................................................................ 543
16.4 I nstance-speci fi c extensi ons .................................................................................................... 544
16.4.1 Introduction.................................................................................................................. 544
16.4.2 Header f il e.................................................................................................................... 544
16.4.3 Class defi nition ............................................................................................................ 544
17. TLM-1 Message passi ng i nterf ace and anal ysis ports..................................................................... 546
17.1 Put, get, peek, and transport interfaces.................................................................................... 546
17.1.1 Descripti on................................................................................................................... 546
17.1.2 Class Def inition ........................................................................................................... 546
17.1.3 Blocking versus non-bl ocking interf aces..................................................................... 548
17.1.4 Blocking put, get, peek, and transport ......................................................................... 549
17.1.5 Non-blocking i nterf ace methods.................................................................................. 549
17.1.6 Argument passing and transaction li fetime ................................................................. 550
17.1.7 Constraints on the transacti on data type...................................................................... 551
17.2 TLM-1 fi fo interfaces .............................................................................................................. 551
17.2.1 Descripti on................................................................................................................... 551
17.2.2 Cl ass Defi ni ti on ........................................................................................................... 551
17.2.3 Member f uncti ons........................................................................................................ 552
17.3 tlm_f if o .................................................................................................................................... 552
17.3.1 Descripti on................................................................................................................... 552
17.3.2 Class Def inition ........................................................................................................... 553
17.3.3 Template parameter T .................................................................................................. 554
17.3.4 Constructors and destructor ......................................................................................... 554
17.3.5 Member f uncti ons........................................................................................................ 554
17.3.6 Delta cycle semanti cs................................................................................................... 556
17.4 Analysis interface and analysi s ports....................................................................................... 558
17.4.1 Class defi nition ............................................................................................................ 558
17.4.2 Rules ............................................................................................................................ 559
xxi
Copyright 2012 IEEE. All rights reserved.
Annex A (informati ve) I ntroducti on to SystemC ........................................................................................ 562
Annex B (inf ormati ve) Glossary.................................................................................................................. 566
Annex C (informati ve) Deprecated f eatures................................................................................................ 583
Annex D (informati ve) Changes between IEEE Std 1666-2005 and I EEE Std 1666-2011........................ 585
I ndex ............................................................................................................................................................ 589
1
Copyright 2012 IEEE. All rights reserved.
IEEE Standard for Standard
SystemC
Language Reference
Manual
I MPORTANT NOTI CE: This standard is not intended to ensure safety, security, health, or
environmental protection. I mplementers of the standard are responsible for determining appropriate
safety, security, environmental, andhealthpracticesor regulatoryrequirements.
ThisI EEE document ismadeavailablefor use subject to important noticesandlegal disclaimers. These
noticesanddisclaimersappear in all publicationscontainingthisdocument andmaybefoundunder the
heading"I mportant Notice" or "Important NoticesandDisclaimersConcerningIEEE Documents." They
can alsobeobtainedonrequest fromI EEE or viewedat http://standards.ieee.org/I PR/disclaimers.html.
1. Overview
1.1 Scope
This standard defi nes SystemC
1
with Transacti on Level Modeli ng (TLM) asan ANSI standard C++ class
li brary for systemandhardwaredesi gn.
1.2 Purpose
The general purpose of thi s standard i s to provi dea C++-based standard for designers and archi tects who
need to address complex systemsthat areahybrid between hardwareand software.
The speci fi c purpose of this standard i sto provide aprecise and complete defi ni ti on of the SystemC class
li brary including aTLM l ibrary so that a SystemC implementation can be developed wi th referenceto thi s
standard alone. This standard is not intended to serve as a users guide or to provide an introduction to
SystemC, but i t doescontai n useful i nformation for end users.
1
SystemC
sc_fxnum_bi tr ef
sc_ui nt_subref
sc_bi tref
sc_fxnum_fast_bi tref
sc_ui nt_subref_r
sc_bi tref_r
sc_fxnum_fast_subr ef
sc_si gned_subr ef
sc_unsi gned_bi tr ef
sc_concatr ef
sc_fxnum_subr ef
sc_concr ef
sc_i nt_bi tr ef
sc_subr ef
sc_unsi gned_subref
sc_concr ef_r
sc_subr ef_r
sc_unsi gned_subref_r
sc_context_begi n
sc_i nt_subref
sc_swi tch
sc_val ue_base
sc_event_and_expr
sc_i nt_subref_r
sc_ui nt_bi tr ef
sc_vector _i ter
sc_event_or _expr
sc_sensi ti ve
(see5.4).
Al though these rul es al low for considerable flexi bil ity in i nstantiati ng the module hi erarchy, it is strongl y
recommended that, wherever possibl e, module, port, export, and primitive channel i nstances be data
members of a module or thei r addresses be stored in data members of a module. Moreover, the names of
thosedatamembersshoul d matchthestring namesof theinstanceswherever possi bl e.
NOTE 1The four classes sc_module, sc_port, sc_export, and sc_prim_channel are derived from acommon base
classsc_object, and thus, they havesomemember functionsin common (see5.16).
NOTE 2Objects of classes derived from sc_object but not derived fromoneof thesefour classes may beinstantiated
during elaboration or simulation, asmay objectsof user-defined classes.
Exampl e:
#include"systemc.h"
struct Mod: sc_modul e
{
SC_CTOR(Mod) { }
} ;
struct S
{
Mod m; // Unusual codi ng styl e- modul ei nstancewi thi nstruct
S(char* name_) : m(name_) { }
} ;
struct Top: sc_modul e // Fivei nstancesof moduleMod exi st within modul eTop.
{
Mod m1; // Recommended codi ng styl e
Mod *m2; // Recommended codi ng styl e
Ss1;
SC_CTOR(Top)
: m1("m1"), // m1.name() returns"top.m1"
s1("s1") // s1.m.name() returns"top.s1"
{
m2 = new Mod("m2"); // m2->name() returns"top.m2"
f();
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
SC_BIND_PROXY_NIL;
class sc_module
: publi c sc_object
{
publ ic:
virtual ~sc_module();
virtual const char* kind() const;
void operator() ( const sc_bi nd_proxy
& p001,
const sc_bi nd_proxy
sensitive;
void dont_initialize();
void set_stack_size( si ze_t );
void next_trigger();
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
sensitive;
This subcl ause descri bes the static sensi ti vity of an unspawned process. Static sensi ti vi ty for a spawned
process is created usi ng member function set_sensitivity of class sc_spawn_options(see 5.5).
Data member sensitive of class sc_module can be used to create the stati c sensiti vity of an unspawned
process i nstance usi ng operator<< of cl ass sc_sensi ti ve
& p001,
const sc_bi nd_proxy
, the parameter type of operator(), may provi de user-def i ned conversi ons i n the form of
two constructors, one havi ng a parameter type of sc_interface, and the other a parameter type of sc_port_base.
NOTE 3The actual argument cannot be an export, because thi s woul d requi re the C++ compi l er to perf orm two
i mpl i ci t conversi ons. However, i t i s possibl e to pass an export as an actual argument by expl i ci tl y cal l i ng the user-
defi ned conversi on sc_export::operator I F&. I t i s al so possi bl e to bi nd a port to an export usi ng named port bi ndi ng.
Exampl e:
SC_MODULE(M1)
{
sc_inout<i nt> P, Q, R; // Ports
...
} ;
SC_MODULE(Top1)
{
sc_i nout <i nt> A, B;
sc_signal <int> C;
M1 m1; // Module instance
SC_CTOR(Top1)
: m1("m1")
{
m1(A, B, C); // Binds P-to-A, Q-to-B, R-to-C
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
{
publ ic:
sc_sensi ti ve
.
Cl ass sc_module shal l have a data member named sensitive of type sc_sensi ti ve
{
publ ic:
oper ator const sc_event_and_l ist & () const;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
, sc_event const& );
sc_event_and_expr
{
publ ic:
oper ator const sc_event _or _li st & () const;
// Other members
i mpl ementati on-defi ned
} ;
sc_event_or _expr
, sc_event const& );
sc_event_or _expr
or sc_event_or _expr
. An
appl icati on wishi ng to create expl ici t event l ist obj ects should use the classes sc_event_and_li st and
sc_event_or _li st.
Cl asses sc_event_and_expr
are the return types of oper ator & and oper ator |,
respectivel y, of cl asses sc_event, sc_event _and_li st, and sc_event _or _li st .
The existence of the type conversi on operators from type sc_event_and_expr
to type const
sc_event_and_li st & and fromtypesc_event_or _expr
and
sc_event_or _expr
aretemporaries returned by oper ator & or oper ator | in an event expressi on, and would
bedestroyed automati call y after thecal l to wait or next _tr igger . Theimpl ementation shal l deletetheevent
li st object when the process instanceresumes or i s tri ggered as adi rect result of the notification of one or
more events in the event expression. In other words, the impl ementation shal l be responsible for the
creati on, deleti on, and memory management of event li st objects returned fromthe above type conversion
operators.
5.9.4 Operators
oper ator const sc_event _and_l ist & () const;
oper ator const sc_event _or _li st & () const;
Each of thesetypeconversion operators shall return areferenceto an event l ist object equivalent to
the event l ist expressi on represented by the current obj ect * thi s, equivalent i n the sense that the
event l ist object shal l contai n references to thesameset of eventsastheevent l ist expression.
sc_event_and_expr
, sc_event const& );
sc_event_and_expr
, sc_event const& );
sc_event_or _expr
. I n such a case, the appl ication shall override thi s f unction in the
channel in questi on to return a reference to an event to whi ch the process instance wil l be made sensi ti ve.
I f this f uncti on is call ed by the i mpl ementation but not overri dden by the appli cation, the i mplementati on
may generate a warning.
Exampl e:
struct my_i f
: vi rtual sc_i nterf ace
{
virtual i nt read() = 0;
} ;
class my_ch
: publi c my_i f, publ ic sc_modul e
{
publ ic:
virtual int read() { return m_val; }
virtual const sc_event& def ault_event() const { return m_ev; }
pri vate:
int m_val ;
sc_event m_ev;
...
} ;
5.15 sc_prim_channel
5.15.1 Description
sc_prim_channel is the base cl ass f or all primitive channels and provides such channels with uni que access
to the update phase of the scheduler. In common with hi erarchical channel s, a pri mitive channel may
provide publ ic member f uncti ons that can be cal led usi ng the i nterf ace method call paradi gm.
This standard provi des a number of predef ined pri mitive channels to model common communication
mechanisms (see Cl ause 6).
5.15.2 Class definition
namespace sc_core {
class sc_prim_channel
: publi c sc_object
{
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
provides a common base class f or all SystemC l imited-preci si on i ntegers and fi nite-
precision integers. I t provides a set of vi rtual methods that may be call ed by an i mplementati on to perform
concatenation operations.
7.4.2 Class definition
namespace sc_dt {
class sc_val ue_base
{
f ri end cl ass sc_concatr ef
;
pri vate:
virtual void concat_clear _data( bool to_ones=f al se );
virtual bool concat_get_ctr l( i mpl ementati on-defi ned* dst_p , int l ow_i ) const;
virtual bool concat_get_data( i mpl ementati on-defi ned* dst_p , int l ow_i ) const;
virtual uint64 concat_get_uint64() const;
virtual i nt concat_length( bool* xz_present_p=0 ) const;
virtual void concat_set( i nt64 src , i nt low_i );
virtual void concat_set( const sc_si gned& src , int l ow_i );
virtual void concat_set( const sc_unsi gned& src , i nt l ow_i );
virtual void concat_set( ui nt64 src , int low_i );
} ;
} // namespace sc_dt
7.4.3 Constraints on usage
An appli cati on should not create an object of type sc_val ue_base
parent.
I f an appl icati on-def ined cl ass deri ved from the generi c base proxy class templ ate sc_gener ic_base is also
derived f rom sc_val ue_base
object as a C++
unsi gned integer havi ng a word length of exactl y 64-bi ts.
virtual int concat_length( bool* xz_present_p=0 ) const;
Member f unction concat_length shal l return the number of bi ts in the sc_val ue_base
object. The
val ue of the obj ect associ ated wi th the optional argument shal l be set to true if any bits have the
val ue ' X' ' or ' Z' .
virtual void concat_set( i nt64 src , i nt low_i );
virtual void concat_set( const sc_si gned& src , i nt l ow_i );
virtual void concat_set( const sc_unsi gned& src , i nt l ow_i );
virtual void concat_set( ui nt64 src , int low_i );
Member functi on concat_set shall set the value of the sc_val ue_base
{
f ri end cl ass sc_ui nt_bi tr ef_r
;
f ri end cl ass sc_ui nt_bi tr ef
;
f ri end cl ass sc_ui nt_subref_r
;
f ri end cl ass sc_ui nt_subref
;
publ ic:
// Constructors
expl icit sc_int_base( i nt w = sc_l ength_param().len() );
sc_int_base( i nt_type v , i nt w );
sc_int_base( const sc_int_base& a );
templ ate< typename T >
expl icit sc_int_base( const sc_generi c_base<T>& a );
expl icit sc_int_base( const sc_i nt_subref_r
& a );
expl icit sc_int_base( const sc_si gned& a );
expl icit sc_int_base( const sc_unsi gned& a );
expl icit sc_int_base( const sc_bv_base& v );
expl icit sc_int_base( const sc_lv_base& v );
expl icit sc_int_base( const sc_ui nt_subref_r
& v );
expl icit sc_int_base( const sc_si gned_subr ef_r
& v );
expl icit sc_int_base( const sc_unsi gned_subref_r
& v );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
& a );
templ ate<cl ass T>
sc_i nt_base& oper ator = ( const sc_generi c_base<T>& a );
sc_i nt_base& oper ator = ( const sc_si gned& a );
sc_i nt_base& oper ator = ( const sc_unsigned& a );
sc_i nt_base& oper ator = ( const sc_fxval& a );
sc_i nt_base& oper ator = ( const sc_fxval_fast& a );
sc_i nt_base& oper ator = ( const sc_fxnum& a );
sc_i nt_base& oper ator = ( const sc_fxnum_fast& a );
sc_i nt_base& oper ator = ( const sc_bv_base& a );
sc_i nt_base& oper ator = ( const sc_lv_base& a );
sc_i nt_base& oper ator = ( const char* a );
sc_i nt_base& oper ator = ( unsigned long a );
sc_i nt_base& oper ator = ( l ong a );
sc_i nt_base& oper ator = ( unsigned int a );
sc_i nt_base& oper ator = ( i nt a );
sc_i nt_base& oper ator = ( ui nt64 a );
sc_i nt_base& oper ator = ( double a );
// Prefi x and postf ix increment and decrement operators
sc_i nt_base& oper ator ++ (); // Prefi x
const sc_i nt_base oper ator ++ ( i nt ); // Postf ix
sc_i nt_base& oper ator-- (); // Prefi x
const sc_i nt_base oper ator-- ( i nt ); // Postf ix
// Bit selecti on
sc_i nt_bi tr ef
oper ator [] ( i nt i );
sc_i nt_bi tr ef_r
{
f ri end cl ass sc_ui nt_bi tr ef_r
;
f ri end cl ass sc_ui nt_bi tr ef
;
f ri end cl ass sc_ui nt_subref_r
;
f ri end cl ass sc_ui nt_subref
;
publ ic:
// Constructors
expl icit sc_uint_base( i nt w = sc_l ength_param().len() );
sc_uint_base( ui nt_type v , int w );
sc_uint_base( const sc_uint_base& a );
expl icit sc_uint_base( const sc_ui nt_subref_r
& a );
templ ate <class T>
expl icit sc_uint_base( const sc_generi c_base<T>& a );
expl icit sc_uint_base( const sc_bv_base& v );
expl icit sc_uint_base( const sc_lv_base& v );
expl icit sc_uint_base( const sc_i nt_subref_r
& v );
expl icit sc_uint_base( const sc_si gned_subr ef_r
& v );
expl icit sc_uint_base( const sc_unsi gned_subref_r
& v );
expl icit sc_uint_base( const sc_si gned& a );
expl icit sc_uint_base( const sc_unsigned& a );
// Destructor
~sc_uint_base();
// Assi gnment operators
sc_uint_base& oper ator = ( ui nt_type v );
sc_uint_base& oper ator = ( const sc_uint_base& a );
sc_uint_base& oper ator = ( const sc_ui nt_subref_r
& a );
templ ate <class T>
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
oper ator [] ( i nt i );
sc_ui nt_bi tr ef_r
& a );
templ ate <class T>
sc_int( const sc_generi c_base<T>& a );
sc_int( const sc_si gned& a );
sc_int( const sc_unsigned& a );
expl icit sc_int( const sc_fxval& a );
expl icit sc_int( const sc_fxval_fast& a );
expl icit sc_int( const sc_fxnum& a );
expl icit sc_int( const sc_fxnum_fast& a );
sc_int( const sc_bv_base& a );
sc_int( const sc_lv_base& a );
sc_int( const char* a );
sc_int( unsigned long a );
sc_int( l ong a );
sc_int( unsigned i nt a );
sc_int( i nt a );
sc_int( ui nt64 a );
sc_int( double a );
// Assi gnment operators
sc_i nt<W>& oper ator = ( i nt_type v );
sc_i nt<W>& oper ator = ( const sc_int_base& a );
sc_int<W>& oper ator = ( const sc_i nt_subref_r
& a );
sc_i nt<W>& oper ator = ( const sc_int<W>& a );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
& a );
templ ate <class T>
sc_uint( const sc_generi c_base<T>& a );
sc_uint( const sc_si gned& a );
sc_uint( const sc_unsigned& a );
expl icit sc_uint( const sc_fxval& a );
expl icit sc_uint( const sc_fxval _fast& a );
expl icit sc_uint( const sc_fxnum& a );
expl icit sc_uint( const sc_fxnum_fast& a );
sc_uint( const sc_bv_base& a );
sc_uint( const sc_lv_base& a );
sc_uint( const char* a );
sc_uint( unsigned l ong a );
sc_uint( l ong a );
sc_uint( unsigned i nt a );
sc_uint( i nt a );
sc_uint( i nt64 a );
sc_uint( double a );
// Assi gnment operators
sc_uint<W>& oper ator = ( ui nt_type v );
sc_uint<W>& oper ator = ( const sc_uint_base& a );
sc_uint<W>& oper ator = ( const sc_ui nt_subref_r
& a );
sc_uint<W>& oper ator = ( const sc_ui nt<W>& a );
templ ate <class T>
sc_uint<W>& oper ator = ( const sc_generi c_base<T>& a );
sc_uint<W>& oper ator = ( const sc_si gned& a );
sc_uint<W>& oper ator = ( const sc_unsigned& a );
sc_uint<W>& oper ator = ( const sc_fxval & a );
sc_uint<W>& oper ator = ( const sc_fxval_fast& a );
sc_uint<W>& oper ator = ( const sc_fxnum& a );
sc_uint<W>& oper ator = ( const sc_fxnum_fast& a );
sc_uint<W>& oper ator = ( const sc_bv_base& a );
sc_uint<W>& oper ator = ( const sc_lv_base& a );
sc_uint<W>& oper ator = ( const char* a );
sc_uint<W>& oper ator = ( unsigned l ong a );
sc_uint<W>& oper ator = ( l ong a );
sc_uint<W>& oper ator = ( unsigned i nt a );
sc_uint<W>& oper ator = ( i nt a );
sc_uint<W>& oper ator = ( i nt64 a );
sc_uint<W>& oper ator = ( doubl e a );
// Prefi x and postf ix increment and decrement operators
sc_uint<W>& oper ator ++ (); // Prefi x
const sc_ui nt<W> oper ator ++ ( i nt ); // Postfi x
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
{
f riend cl ass sc_int_base;
publ ic:
// Copy constructor
sc_i nt_bi tr ef_r
& a );
// Destructor
virtual ~sc_i nt_bi tr ef_r
();
// Capacity
int length() const;
// Impl icit conversi on to ui nt64
oper ator uint64 () const;
bool oper ator ! () const;
bool oper ator ~ () const;
Table 9sc_uint arithmetic and bitwise operations
Expr ession Retur n type Oper ation
U += u sc_ui nt<W>& sc_ui nt assi gn sum
U -= u sc_ui nt<W>& sc_ui nt assi gn di f f erence
U * = u sc_ui nt<W>& sc_ui nt assi gn product
U /= u sc_ui nt<W>& sc_ui nt assi gn quoti ent
U %= u sc_ui nt<W>& sc_ui nt assi gn remai nder
U & = u sc_ui nt<W>& sc_ui nt assi gn bitwi se and
U |= u sc_ui nt<W>& sc_ui nt assi gn bi twi se or
U ^= u sc_ui nt<W>& sc_ui nt assi gn bitwi se excl usi ve or
U <<= u sc_ui nt<W>& sc_ui nt assi gn lef t-shi ft
U >>= u sc_ui nt<W>& sc_ui nt assi gn ri ght-shi f t
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
();
pri vate:
// Di sabl ed
sc_i nt_bi tr ef_r
& );
} ;
// -------------------------------------------------------------
class sc_i nt_bi tr ef
{
f riend cl ass sc_int_base;
publ ic:
// Copy constructor
sc_i nt_bi tr ef
& a );
// Assi gnment operators
sc_i nt_bi tr ef
& b );
sc_i nt_bi tr ef
& b );
sc_i nt_bi tr ef
();
} ;
// -------------------------------------------------------------
class sc_ui nt_bi tr ef_r
: publi c sc_val ue_base
{
f riend cl ass sc_ui nt_base;
publ ic:
// Copy constructor
sc_ui nt_bi tr ef_r
& a );
// Destructor
virtual ~sc_ui nt_bi tr ef_r
();
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
();
pri vate:
// Di sabl ed
sc_ui nt_bi tr ef_r
& );
} ;
// -------------------------------------------------------------
class sc_ui nt_bi tr ef
{
f riend cl ass sc_ui nt_base;
publ ic:
// Copy constructor
sc_ui nt_bi tr ef
& a );
// Assi gnment operators
sc_ui nt_bi tr ef
& b );
sc_ui nt_bi tr ef
& b );
sc_ui nt_bi tr ef
();
} ;
} // namespace sc_dt
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
represents a si gned integer part-sel ect f rom an sc_int_base used as an l val ue.
Class sc_ui nt_subr ef_r
{
f riend cl ass sc_int_base;
f ri end cl ass sc_i nt_subref
;
publ ic:
// Copy constructor
sc_i nt_subref_r
& a );
// Destructor
virtual ~sc_i nt_subref_r
();
// Capacity
int length() const;
// Reduce methods
bool and_r educe() const;
bool nand_r educe() const;
bool or_r educe() const;
bool nor_reduce() const;
bool xor_reduce() const;
bool xnor _reduce() const;
// Impl icit conversi on to ui nt_type
oper ator uint_type() const;
// Expl icit conversions
int to_int() const;
unsi gned int to_uint() const;
long to_long() const;
unsi gned long to_ulong() const;
int64 to_int64() const;
uint64 to_uint64() const;
doubl e to_double() const;
// Expl icit conversion to character stri ng
const std::string to_str ing( sc_numrep numrep = SC_DEC ) const;
const std::string to_str ing( sc_numrep numrep , bool w_pref ix ) const;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
();
pri vate:
// Di sabl ed
sc_i nt_subref_r
& );
} ;
// -------------------------------------------------------------
class sc_i nt_subref
{
f riend cl ass sc_int_base;
publ ic:
// Copy constructor
sc_i nt_subref
& a );
// Assi gnment operators
sc_i nt_subref
& a );
sc_i nt_subref
& a );
templ ate< cl ass T >
sc_i nt_subref
();
} ;
// -------------------------------------------------------------
class sc_ui nt_subref_r
{
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
;
publ ic:
// Copy constructor
sc_ui nt_subref_r
& a );
// Destructor
virtual ~sc_uint_subref_r ();
// Capacity
int length() const;
// Reduce methods
bool and_r educe() const;
bool nand_r educe() const;
bool or_r educe() const;
bool nor_reduce() const;
bool xor_reduce() const;
bool xnor _reduce() const;
// Impl icit conversi on to ui nt_type
operator uint_type() const;
// Expl icit conversions
int to_int() const;
unsi gned int to_uint() const;
long to_long() const;
unsi gned long to_ulong() const;
int64 to_int64() const;
uint64 to_uint64() const;
doubl e to_double() const;
// Expl icit conversion to character stri ng
const std::string to_str ing( sc_numrep numrep = SC_DEC ) const;
const std::string to_str ing( sc_numrep numrep , bool w_pref ix ) const;
// Other methods
void pr int( std::ostream& os = std::cout ) const;
protected:
sc_ui nt_subref_r
();
pri vate:
// Di sabl ed
sc_uint_subref_r& oper ator = ( const sc_uint_subref_r& );
} ;
// -------------------------------------------------------------
class sc_ui nt_subref
{
f riend cl ass sc_ui nt_base;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
& a );
// Assi gnment operators
sc_ui nt_subref
();
} ;
} // namespace sc_dt
7.5.7.3 Constraints on usage
I nteger part-select objects shall only be created using the part-sel ect operators of an sc_int_base or
sc_uint_base object (or an i nstance of a cl ass deri ved f rom sc_int_base or sc_uint_base), as descri bed in
7.2.6.
An appl ication shall not expli citl y create an instance of any integer part-sel ect cl ass.
An appl ication should not declare a reference or pointer to any i nteger part-select object.
I t shal l be an error if the l ef t-hand i ndex of a li mited-preci si on integer part-select i s less than the ri ght-hand
index.
I t i s strongly recommended that an appli cation avoi d the use of a part-select as the return type of a functi on
because the li feti me of the obj ect to which the part-select refers may not extend beyond the functi on return
statement.
Exampl e:
sc_dt::sc_i nt_subref get_byte(sc_int_base i b, i nt pos) {
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
{
f ri end cl ass sc_concatr ef
;
f ri end cl ass sc_si gned_bi tref_r
;
f ri end cl ass sc_si gned_bi tref
;
f ri end cl ass sc_si gned_subr ef_r
;
f ri end cl ass sc_si gned_subr ef
;
f riend cl ass sc_unsigned;
f riend cl ass sc_unsigned_subref;
publ ic:
// Constructors
expl icit sc_signed( i nt nb = sc_length_param().l en() );
sc_signed( const sc_si gned& v );
sc_signed( const sc_unsigned& v );
templ ate<cl ass T>
expl icit sc_signed( const sc_generi c_base<T>& v );
expl icit sc_signed( const sc_bv_base& v );
expl icit sc_signed( const sc_lv_base& v );
expl icit sc_signed( const sc_int_subref_r& v );
expl icit sc_signed( const sc_uint_subref _r& v );
expl icit sc_signed( const sc_si gned_subref _r& v );
expl icit sc_signed( const sc_unsigned_subref_r& v );
// Assi gnment operators
sc_signed& oper ator = ( const sc_si gned& v );
sc_signed& oper ator = ( const sc_si gned_subr ef_r
& a );
templ ate< cl ass T >
sc_signed& oper ator = ( const sc_generi c_base<T>& a );
sc_signed& oper ator = ( const sc_unsigned& v );
sc_signed& oper ator = ( const sc_unsi gned_subref_r
& a );
sc_signed& oper ator = ( const char* v );
sc_signed& oper ator = ( i nt64 v );
sc_signed& oper ator = ( ui nt64 v );
sc_signed& oper ator = ( l ong v );
sc_signed& oper ator = ( unsigned long v );
sc_signed& oper ator = ( i nt v );
sc_signed& oper ator = ( unsigned int v );
sc_signed& oper ator = ( double v );
sc_signed& oper ator = ( const sc_int_base& v );
sc_signed& oper ator = ( const sc_ui nt_base& v );
sc_signed& oper ator = ( const sc_bv_base& );
sc_signed& oper ator = ( const sc_lv_base& );
sc_signed& oper ator = ( const sc_fxval & );
sc_signed& oper ator = ( const sc_fxval _fast& );
sc_signed& oper ator = ( const sc_fxnum& );
sc_signed& oper ator = ( const sc_fxnum_fast& );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
oper ator [] ( i nt i );
sc_si gned_bi tref_r
operator [] ( i nt i ) const;
// Part selection
sc_si gned_subr ef
r ange( i nt i , i nt j );
sc_si gned_subr ef_r
r ange( i nt i , i nt j ) const;
sc_si gned_subr ef
{
f ri end cl ass sc_concatr ef
;
f ri end cl ass sc_unsi gned_bi tr ef_r
;
f ri end cl ass sc_unsi gned_bi tr ef
;
f ri end cl ass sc_unsi gned_subref_r
;
f ri end cl ass sc_unsi gned_subref
;
f riend cl ass sc_si gned;
f ri end cl ass sc_si gned_subr ef
;
publ ic:
// Constructors
expl icit sc_unsigned( i nt nb = sc_length_param().l en() );
sc_unsigned( const sc_unsigned& v );
sc_unsigned( const sc_si gned& v );
templ ate<cl ass T>
expl icit sc_unsigned( const sc_generi c_base<T>& v );
expl icit sc_unsigned( const sc_bv_base& v );
expl icit sc_unsigned( const sc_lv_base& v );
expl icit sc_unsigned( const sc_int_subref_r& v );
expl icit sc_unsigned( const sc_uint_subref_r& v );
expl icit sc_unsigned( const sc_si gned_subref _r& v );
expl icit sc_unsigned( const sc_unsigned_subref_r& v );
// Assi gnment operators
sc_unsi gned& oper ator = ( const sc_unsigned& v);
sc_unsi gned& oper ator = ( const sc_unsi gned_subref_r
& a );
templ ate<cl ass T>
sc_unsi gned& oper ator = ( const sc_generi c_base<T>& a );
sc_unsi gned& oper ator = ( const sc_si gned& v );
sc_unsi gned& oper ator = ( const sc_si gned_subr ef_r
& a );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
oper ator [] ( i nt i );
sc_unsi gned_bi tr ef_r
r ange ( i nt i , int j );
sc_unsi gned_subref_r
r ange( i nt i , i nt j ) const;
sc_unsi gned_subref
oper ator () ( i nt i , i nt j );
sc_unsi gned_subref_r
& v );
templ ate< cl ass T >
sc_bigint( const sc_generi c_base<T>& a );
sc_bigint( const sc_unsigned& v );
sc_bigint( const sc_unsi gned_subref
& v );
sc_bigint( const char* v );
sc_bigint( i nt64 v );
sc_bigint( ui nt64 v );
sc_bigint( l ong v );
sc_bigint( unsigned long v );
sc_bigint( i nt v );
sc_bigint( unsigned int v );
sc_bigint( double v );
sc_bigint( const sc_bv_base& v );
sc_bigint( const sc_lv_base& v );
expl icit sc_bigint( const sc_fxval & v );
expl icit sc_bigint( const sc_fxval _fast& v );
expl icit sc_bigint( const sc_fxnum& v );
expl icit sc_bigint( const sc_fxnum_fast& v );
// Destructor
~sc_bigint();
// Assi gnment operators
sc_bigi nt<W>& oper ator = ( const sc_bi gint<W>& v );
sc_bigi nt<W>& oper ator = ( const sc_si gned& v );
sc_bigi nt<W>& oper ator = (const sc_si gned_subr ef
& v );
templ ate< cl ass T >
sc_bigi nt<W>& oper ator = ( const sc_generi c_base<T>& a );
sc_bigi nt<W>& oper ator = ( const sc_unsigned& v );
sc_bigi nt<W>& oper ator = ( const sc_unsi gned_subref
& v );
sc_bigi nt<W>& oper ator = ( const char* v );
sc_bigi nt<W>& oper ator = ( i nt64 v );
sc_bigi nt<W>& oper ator = ( ui nt64 v );
sc_bigi nt<W>& oper ator = ( l ong v );
sc_bigi nt<W>& oper ator = ( unsigned long v );
sc_bigi nt<W>& oper ator = ( i nt v );
sc_bigi nt<W>& oper ator = ( unsigned int v );
sc_bigi nt<W>& oper ator = ( double v );
sc_bigi nt<W>& oper ator = ( const sc_bv_base& v );
sc_bigi nt<W>& oper ator = ( const sc_lv_base& v );
sc_bigi nt<W>& oper ator = ( const sc_int_base& v );
sc_bigi nt<W>& oper ator = ( const sc_ui nt_base& v );
sc_bigi nt<W>& oper ator = ( const sc_fxval & v );
sc_bigi nt<W>& oper ator = ( const sc_fxval_fast& v );
sc_bigi nt<W>& oper ator = ( const sc_fxnum& v );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
& v );
templ ate< cl ass T >
sc_biguint( const sc_generi c_base<T>& a );
sc_biguint( const sc_si gned& v );
sc_biguint( const sc_si gned_subr ef
& v );
sc_biguint( const char* v );
sc_biguint( i nt64 v );
sc_biguint( ui nt64 v );
sc_biguint( l ong v );
sc_biguint( unsigned l ong v );
sc_biguint( i nt v );
sc_biguint( unsigned int v );
sc_biguint( double v );
sc_biguint( const sc_bv_base& v );
sc_biguint( const sc_lv_base& v );
expl icit sc_biguint( const sc_fxval& v );
expl icit sc_biguint( const sc_fxval_fast& v );
expl icit sc_biguint( const sc_fxnum& v );
expl icit sc_biguint( const sc_fxnum_fast& v );
// Destructor
~sc_biguint();
// Assi gnment operators
sc_biguint<W>& oper ator = ( const sc_bi gui nt<W>& v );
sc_biguint<W>& oper ator = ( const sc_unsigned& v );
sc_biguint<W>& oper ator = ( const sc_unsi gned_subref
& v );
templ ate< cl ass T >
sc_biguint<W>& oper ator = ( const sc_generi c_base<T>& a );
sc_biguint<W>& oper ator = ( const sc_si gned& v );
sc_biguint<W>& oper ator = ( const sc_si gned_subr ef
& v );
sc_biguint<W>& oper ator = ( const char* v );
sc_biguint<W>& oper ator = ( i nt64 v );
sc_biguint<W>& oper ator = ( ui nt64 v );
sc_biguint<W>& oper ator = ( l ong v );
sc_biguint<W>& oper ator = ( unsigned long v );
sc_biguint<W>& oper ator = ( i nt v );
sc_biguint<W>& oper ator = ( unsigned int v );
sc_biguint<W>& oper ator = ( double v );
sc_biguint<W>& oper ator = ( const sc_bv_base& v );
sc_biguint<W>& oper ator = ( const sc_lv_base& v );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
{
f riend cl ass sc_si gned;
f ri end cl ass sc_si gned_bi tref
;
publ ic:
// Copy constructor
sc_si gned_bi tref_r
& a );
// Destructor
virtual ~sc_si gned_bi tref_r
();
// Capacity
int length() const;
// Impl icit conversi on to ui nt64
oper ator uint64 () const;
bool oper ator ! () const;
bool oper ator ~ () const;
// Expl icit conversions
bool to_bool() const;
// Other methods
void pr int( std::ostream& os = std::cout ) const;
protected:
sc_si gned_bi tref_r
();
pri vate:
// Di sabl ed
sc_si gned_bi tref_r
& );
} ;
// -----------------------------------------------------------------
class sc_si gned_bi tref
{
f riend cl ass sc_si gned;
publ ic:
// Copy constructor
sc_si gned_bi tref
& a );
// Assi gnment operators
sc_si gned_bi tref
& );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
& );
sc_si gned_bi tref
();
} ;
// -----------------------------------------------------------------
class sc_unsi gned_bi tr ef_r
: publi c sc_val ue_base
{
f riend cl ass sc_unsigned;
publ ic:
// Copy constructor
sc_unsi gned_bi tr ef_r
& a );
// Destructor
virtual ~sc_unsi gned_bi tr ef_r
();
// Capacity
int length() const;
// Impl icit conversi on to ui nt64
oper ator uint64 () const;
bool oper ator ! () const;
bool oper ator ~ () const;
// Expl icit conversions
bool to_bool() const;
// Other methods
void pr int( std::ostream& os = std::cout ) const;
protected:
sc_unsi gned_bi tr ef_r
();
pri vate:
// Di sabl ed
sc_unsi gned_bi tr ef_r
& );
} ;
// -----------------------------------------------------------------
class sc_unsi gned_bi tr ef
& a );
// Assi gnment operators
sc_unsi gned_bi tr ef
& );
sc_unsi gned_bi tr ef
& );
sc_unsi gned_bi tr ef
();
} ;
} // namespace sc_dt
7.6.7.3 Constraints on usage
Bit-select objects shal l only be created usi ng the bi t-sel ect operators of an sc_signed or sc_unsigned object
(or an i nstance of a class deri ved from sc_signed or sc_unsigned).
An appl ication shall not expli citl y create an i nstance of any bi t-sel ect class.
An appl ication should not decl are a reference or pointer to any bit-sel ect obj ect.
I t is strongly recommended that an appl ication avoi d the use of a bi t-sel ect as the return type of a f unction
because the l if etime of the obj ect to whi ch the bi t-select ref ers may not extend beyond the f uncti on return
statement.
Exampl e:
sc_dt::sc_signed_bi tref get_bit_n(sc_si gned iv, int n) {
return iv[n] ; // Unsafe: returned bi t-sel ect ref erences local vari abl e
}
7.6.7.4 Assignment operators
Overl oaded assi gnment operators f or the lvalue bi t-sel ects shall provide conversi on from bool val ues.
Assi gnment operators f or rvalue bi t-sel ects shall be declared as pri vate to prevent their use by an
appl ication.
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
represents a si gned integer part-sel ect f rom an sc_signed used as an l val ue.
Cl ass sc_unsi gned_subref_r
: publ ic sc_val ue_base
{
f riend cl ass sc_si gned;
f riend cl ass sc_unsigned;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
& a );
// Destructor
virtual ~sc_unsi gned_subref_r
();
// Capacity
int length() const;
// Impl icit conversion to sc_unsigned
oper ator sc_unsigned () const;
// Expl icit conversions
int to_int() const;
unsi gned int to_uint() const;
long to_long() const;
unsi gned long to_ulong() const;
int64 to_int64() const;
uint64 to_uint64() const;
doubl e to_double() const;
// Expl icit conversion to character stri ng
const std::string to_str ing( sc_numrep numrep = SC_DEC ) const;
const std::string to_str ing( sc_numrep numrep, bool w_pref i x ) const;
// Reduce methods
bool and_r educe() const;
bool nand_r educe() const;
bool or_r educe() const;
bool nor_reduce() const;
bool xor_reduce() const;
bool xnor _reduce() const;
// Other methods
void pr int( std::ostream& os = std::cout ) const;
protected:
sc_si gned_subr ef_r
();
pri vate:
// Di sabl ed
sc_si gned_subr ef_r
& );
} ;
// --------------------------------------------------------------
class sc_si gned_subr ef
{
f riend cl ass sc_si gned;
publ ic:
// Copy constructor
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
& a );
// Assi gnment operators
sc_si gned_subr ef
& a );
sc_si gned_subr ef
& a );
sc_si gned_subr ef
& a );
sc_si gned_subr ef
();
} ;
// --------------------------------------------------------------
class sc_unsi gned_subref_r
{
f riend cl ass sc_si gned;
f riend cl ass sc_unsigned;
publ ic:
// Copy constructor
sc_unsi gned_subref_r
& a );
// Destructor
virtual ~sc_unsi gned_subref_r
();
// Capacity
int length() const;
// Impl icit conversion to sc_unsigned
oper ator sc_unsigned () const;
// Expl icit conversions
int to_int() const;
unsi gned int to_uint() const;
long to_long() const;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
();
pri vate:
// Di sabl ed
sc_unsi gned_subref _r& oper ator = ( const sc_unsi gned_subref_r
& );
} ;
// --------------------------------------------------------------
class sc_unsi gned_subref
: publi c sc_unsi gned_subref_r
{
f riend cl ass sc_unsigned;
publ ic:
// Copy constructor
sc_unsi gned_subref
& a );
// Assi gnment operators
sc_unsi gned_subref
& a );
sc_unsi gned_subref
& a );
sc_unsi gned_subref
();
} ;
} // namespace sc_dt
7.6.8.3 Constraints on usage
I nteger part-select objects shal l only be created using the part-select operators of an sc_signed or
sc_unsigned obj ect (or an i nstance of a class derived f rom sc_signed or sc_unsigned), as descri bed i n 7.2.6.
An appl ication shall not expli citl y create an instance of any integer part-sel ect cl ass.
An appl ication should not declare a reference or pointer to any i nteger part-select object.
I t i s strongly recommended that an appli cation avoi d the use of a part-select as the return type of a functi on
because the li feti me of the obj ect to which the part-select refers may not extend beyond the functi on return
statement.
Exampl e:
sc_dt::sc_signed_subref get_byte(sc_signed s, int pos) {
return s(pos+7,pos); // Unsafe: returned part-select ref erences l ocal vari abl e
}
NOTEThe left-hand index of a finite-precisi on i nteger part-sel ect may be l ess than the ri ght-hand i ndex. The bi t order
i n the part-sel ect i s then the reverse of that i n the ori gi nal i nteger.
7.6.8.4 Assignment operators
Overl oaded assi gnment operators shall provide conversion f rom SystemC data types and the nati ve C++
integer representation to lval ue integer part-sel ects. I f the size of a data type or stri ng li teral operand dif fers
f rom the i nteger part-sel ect word l ength, truncation, zero-extensi on, or sign-extensi on shall be used, as
descri bed in 7.2.1.
Assi gnment operators for rvalue integer part-selects shal l be decl ared as pri vate to prevent their use by an
appl ication.
7.6.8.5 Implicit type conversion
sc_si gned_subr ef_r
represents a concatenation of bits f rom one or more objects whose concatenati on base
types are SystemC integers.
7.7.2 Class definition
namespace sc_dt {
class sc_concatr ef
: publi c sc_generic_base<sc_concatr ef
{
publ ic:
// Destructor
virtual ~sc_concatr ef
();
// Capacity
unsi gned int length() const;
// Expl icit conversions
int to_int() const;
unsi gned int to_uint() const;
long to_long() const;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
& v );
const sc_concatr ef
( const sc_concatr ef
& );
~sc_concatr ef
();
} ;
sc_concatr ef
& b );
const sc_concatr ef
& b );
const sc_concatr ef
& a, bool b );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
& b );
sc_concatr ef
& b );
const sc_concatr ef
& b );
const sc_concatr ef
& a , bool b );
const sc_concatr ef
& b );
} // namespace sc_dt
7.7.3 Constraints on usage
I nteger concatenati on objects shall only be created using the concat functi on (or oper ator,) accordi ng to the
rul es in 7.2.7.
At least one of the concatenation arguments shall be an object wi th a SystemC integer concatenati on base
type, that is, an i nstance of a class derived directly or i ndi rectly f rom class sc_val ue_base
.
A si ngl e concatenation argument (that is, one of the two arguments to the concat function or oper ator,) may
be a bool value, a reference to a sc_core::sc_signal<bool,WRI TER_POLI CY> channel, or a reference to a
sc_core::sc_in<bool>, sc_core::sc_inout<bool>, or sc_core::sc_out<bool> port.
An appli cation shall not expl icitly create an i nstance of any i nteger concatenation class. An appl ication shall
not impl icitly create an instance of any integer concatenation cl ass by using it as a f uncti on argument or as a
f uncti on return val ue.
An appl ication should not declare a ref erence or poi nter to any i nteger concatenation object.
7.7.4 Assignment operators
Overl oaded assi gnment operators shall provide conversion f rom SystemC data types and the nati ve C++
integer representation to lvalue integer concatenati ons. If the size of a data type or string li teral operand
dif fers f rom the integer concatenation word l ength, truncation, zero-extension, or sign-extension shall be
used, as descri bed in 7.2.1.
Assi gnment operators f or rval ue integer concatenations shall not be cal led by an appl icati on.
7.7.5 Implicit type conversion
oper ator uint64 () const;
oper ator const sc_unsigned& () const;
Operators uint64 and sc_unsigned shal l provide impl ici t unsigned type conversion f rom an i nteger
concatenation to a nati ve C++ unsigned i nteger having exactly 64 bits or a an sc_unsigned obj ect
wi th a length equal to the total number of bi ts contained wi thin the obj ects referenced by the
concatenation.
NOTEEnables the use of standard C++ and SystemC bitwi se logi cal and ari thmeti c operators wi th i nteger
concatenati on obj ects.
7.7.6 Explicit type conversion
const std::string to_str ing( sc_numrep numrep = SC_DEC ) const;
const std::string to_str ing( sc_numrep numrep , bool w_pref ix ) const;
Member f unction to_str ing shal l convert the object to an std::str ing representation, as described in
7.2.11. Cal li ng the to_str ing function with a single argument is equivalent to call ing the to_str ing
f uncti on with two arguments, where the second argument i s true. Call ing the to_str ing f unction wi th
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
< X>& a );
templ ate <class T1, class T2>
sc_bv_base( const sc_concr ef_r
<T1,T2> & a );
sc_bv_base( const sc_lv_base& a );
sc_bv_base( const sc_bv_base& a );
// Destructor
virtual ~sc_bv_base();
// Assi gnment operators
templ ate <cl ass X>
sc_bv_base& oper ator = ( const sc_subr ef_r
< X>& a );
templ ate <class T1, class T2>
sc_bv_base& oper ator = ( const sc_concr ef_r
< T1,T2>& a );
sc_bv_base& oper ator = ( const sc_bv_base& a );
sc_bv_base& oper ator = ( const sc_lv_base& a );
sc_bv_base& oper ator = ( const char* a );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
< X>& a );
templ ate <class T1, class T2> sc_bv_base( const sc_concr ef_r
< T1,T2>& a );
sc_bv_base( const sc_lv_base& a );
sc_bv_base( const sc_bv_base& a );
Constructor sc_bv_base shall create an sc_bv_base obj ect wi th the same word length and value as
a.
NOTEAn implementation may provide a different set of constructors to create an sc_bv_base obj ect f rom an
sc_subr ef_r
< T1,T2> , or sc_lv_base obj ect, for exampl e, by provi di ng a cl ass templ ate that i s used
as a common base cl ass f or all these types.
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
< T> , or
sc_concr ef_r
< T1,T2> or integer type int, long, unsigned int, unsigned long, sc_signed,
sc_unsigned, sc_int_base, or sc_uint_base.
i represents an obj ect of integer type int.
A represents an array obj ect with el ements of type char , bool, or sc_logic.
The operands may al so be of any other cl ass that i s derived from those just given.
Binary bi twise operators shal l return a result wi th a word length that i s equal to the word length of the
longest operand.
The lef t shi ft operator shal l return a resul t with a word length that i s equal to the word l ength of its
sc_bv_base operand pl us the right (integer) operand. Bits added on the ri ght-hand si de of the resul t shal l be
set to zero.
The right shif t operator returns a resul t wi th a word length that is equal to the word l ength of its sc_bv_base
operand. Bits added on the l ef t-hand side of the resul t shall be set to zero.
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
< X>& a );
templ ate <class T1, class T2>
sc_lv_base( const sc_concr ef_r
<T1,T2>& a );
sc_lv_base( const sc_bv_base& a );
sc_lv_base( const sc_lv_base& a );
// Destructor
virtual ~sc_lv_base();
// Assi gnment operators
templ ate <cl ass X>
sc_l v_base& oper ator = ( const sc_subr ef_r
< T1,T2>& a );
sc_l v_base& oper ator = ( const sc_bv_base& a );
sc_l v_base& oper ator = ( const sc_lv_base& a );
sc_l v_base& oper ator = ( const char* a );
sc_l v_base& oper ator = ( const bool* a );
sc_lv_base& oper ator = ( const sc_logic* a );
sc_l v_base& oper ator = ( const sc_unsigned& a );
sc_l v_base& oper ator = ( const sc_si gned& a );
sc_l v_base& oper ator = ( const sc_ui nt_base& a );
sc_l v_base& oper ator = ( const sc_int_base& a );
sc_l v_base& oper ator = ( unsi gned long a );
sc_l v_base& oper ator = ( l ong a );
sc_l v_base& oper ator = ( unsi gned int a );
sc_l v_base& oper ator = ( i nt a );
sc_l v_base& oper ator = ( uint64 a );
sc_l v_base& oper ator = ( i nt64 a );
// Bitwise rotati ons
sc_l v_base& lr otate( i nt n );
sc_l v_base& r rotate( i nt n );
// Bitwise reverse
sc_l v_base& reverse();
// Bit selecti on
sc_bi tref
< T> , or
sc_concr ef_r
< T1,T2>, or integer type int, long, unsigned int, unsigned long, sc_signed,
sc_unsigned, sc_int_base, or sc_uint_base.
i represents an obj ect of integer type int.
A represents an array obj ect with el ements of type char , bool, or sc_logic.
The operands may al so be of any other cl ass that i s derived from those just given.
Binary bi twise operators shal l return a result wi th a word length that i s equal to the word length of the
longest operand.
The lef t shi ft operator shal l return a resul t with a word length that i s equal to the word l ength of its
sc_lv_base operand plus the right (i nteger) operand. Bi ts added on the ri ght-hand si de of the resul t shall be
set to zero.
The ri ght shi ft operator shal l return a resul t wi th a word length that i s equal to the word length of i ts
sc_lv_base operand. Bits added on the l eft-hand side of the result shall be set to zero.
I t is an error i f the ri ght operand of a shif t operator i s negative.
sc_l v_base& lr otate( i nt n );
Member f uncti on lr otate shall rotate an sc_lv_base obj ect n places to the left.
sc_l v_base& r rotate( i nt n );
Member f uncti on r rotate shal l rotate an sc_lv_base object n places to the ri ght.
sc_l v_base& reverse();
Member f uncti on reverse shall reverse the bi t order in an sc_lv_base obj ect.
NOTEAn implementation i s requi red to suppl y overl oaded operators on sc_lv_base obj ects to sati sf y the
requi rements of this subcl ause. I t i s unspeci f i ed whether these operators are members of sc_lv_base, gl obal operators, or
provi ded i n some other way.
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
< X>& a );
templ ate <class T1, class T2>
sc_bv<W>& oper ator = ( const sc_concr ef_r
< T1,T2>& a );
sc_bv<W>& oper ator = ( const sc_bv_base& a );
sc_bv<W>& oper ator = ( const sc_lv_base& a );
sc_bv<W>& oper ator = ( const sc_bv<W>& a );
sc_bv<W>& oper ator = ( const char* a );
sc_bv<W>& oper ator = ( const bool* a );
sc_bv<W>& oper ator = ( const sc_logic* a );
sc_bv<W>& oper ator = ( const sc_unsigned& a );
sc_bv<W>& oper ator = ( const sc_si gned& a );
sc_bv<W>& oper ator = ( const sc_ui nt_base& a );
sc_bv<W>& oper ator = ( const sc_int_base& a );
sc_bv<W>& oper ator = ( unsi gned long a );
sc_bv<W>& oper ator = ( l ong a );
sc_bv<W>& oper ator = ( unsi gned int a );
sc_bv<W>& oper ator = ( i nt a );
sc_bv<W>& oper ator = ( uint64 a );
sc_bv<W>& oper ator = ( i nt64 a );
} ;
} // namespace sc_dt
7.9.5.3 Constraints on usage
Attempti ng to assign the sc_logic_value_t val ues hi gh-impedance or unknown to any el ement of an sc_bv
object shall be an error.
The result of assigning an array of bool or an array of sc_logic to an sc_bv obj ect havi ng a greater word
length than the number of array el ements is undef ined.
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
< T1,T2>, sc_bv_base, or sc_lv_base obj ect, for example, by provi ding a cl ass
templ ate that i s used as a common base cl ass f or al l these types.
7.9.5.5 Assignment operators
Overl oaded assi gnment operators shall provide conversion f rom SystemC data types and the nati ve C++
integer representati on to sc_bv, usi ng truncation or zero-extension, as descri bed i n 7.2.1. The excepti on is
assignment of an array of bool or an array of sc_logic to an sc_bv object, as descri bed in 7.9.5.4.
7.9.6 sc_lv
7.9.6.1 Description
Class template sc_lv represents a f inite word-l ength bi t vector. I t can be treated as an array of
sc_logic_value_t val ues. The word l ength shal l be specif ied by a template argument.
Any publi c member functions of the base cl ass sc_lv_base that are overri dden in cl ass sc_lv shall have the
same behavior in the two cl asses. Any publ ic member f uncti ons of the base class not overridden i n this way
shall be publi cl y i nherited by cl ass sc_lv.
7.9.6.2 Class definition
namespace sc_dt {
templ ate <i nt W>
class sc_lv
: publi c sc_l v_base
{
publ ic:
// Constructors
sc_lv();
expl icit sc_lv( const sc_logic& i ni t_value );
expl icit sc_lv( bool i ni t_value );
expl icit sc_lv( char ini t_val ue );
sc_lv( const char* a );
sc_lv( const bool * a );
sc_lv( const sc_logic* a );
sc_lv( const sc_unsi gned& a );
sc_lv( const sc_si gned& a );
sc_lv( const sc_uint_base& a );
sc_lv( const sc_int_base& a );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
< X>& a );
template <class T1, cl ass T2>
sc_lv( const sc_concr ef_r
< T1,T2>& a );
sc_lv( const sc_bv_base& a );
sc_lv( const sc_lv_base& a );
sc_lv( const sc_lv<W>& a );
// Assi gnment operators
templ ate <cl ass X>
sc_lv<W>& oper ator = ( const sc_subr ef_r
< T1,T2>, sc_bv_base, or sc_lv_base obj ect, for example, by provi ding a cl ass
templ ate that i s used as a common base cl ass f or al l these types.
7.9.6.5 Assignment operators
Overl oaded assi gnment operators shall provide conversion f rom SystemC data types and the nati ve C++
integer representation to sc_lv, using truncation or zero-extensi on, as described in 7.2.1. The excepti on is
assignment f rom an array of bool or an array of sc_logic to an sc_lv obj ect, as descri bed in 7.9.6.4.
7.9.7 Bit-selects
7.9.7.1 Description
Class template sc_bi tref_r
{
f riend cl ass sc_bv_base;
f riend cl ass sc_lv_base;
publ ic:
// Copy constructor
sc_bi tref_r
< T>& a );
// Bitwise compl ement
const sc_l ogi c oper ator ~ () const;
// Impl icit conversi on to sc_logic
oper ator const sc_logic() const;
// Expl icit conversions
bool is_01() const;
bool to_bool() const;
char to_char() const;
// Common methods
int length() const;
// Other methods
void pr int( std::ostream& os = std::cout ) const;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
();
sc_bi tref_r
< T>
{
f riend cl ass sc_bv_base;
f riend cl ass sc_lv_base;
publ ic:
// Copy constructor
sc_bi tref
< T>& a );
// Assi gnment operators
sc_bi tref
< T>& a );
sc_bi tref
< T>& a );
sc_bi tref
< T>& a );
sc_bi tref
< T>& a );
sc_bi tref
{
publ ic:
// Copy constructor
sc_subr ef_r
< T>& a );
// Bit selecti on
sc_bi tref_r
<sc_subr ef_r
< sc_subref_r
< sc_subref_r
();
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
< T>& );
} ;
// -------------------------------------------------------------
templ ate <class T>
class sc_subr ef
< T>
{
publ ic:
// Copy constructor
sc_subr ef
( const sc_subr ef
< T>& a );
// Assi gnment operators
templ ate <class T>
sc_subr ef
< T1,T2>& a );
sc_subr ef
< T>& a );
sc_subr ef
< sc_subref
< sc_subref
< sc_subref
();
} ;
} // namespace sc_dt
7.9.8.3 Constraints on usage
Part-sel ect objects shall only be created using the part-select operators of an sc_bv_base or sc_lv_base
object (or an i nstance of a class derived from sc_bv_base or sc_lv_base) or a part-sel ect or concatenati on
thereof , as described in 7.2.6.
An appl ication shall not expli citl y create an i nstance of any part-select class.
An appl ication should not decl are a reference or pointer to any part-sel ect obj ect.
An rvalue part-select shal l not be used to modif y the vector wi th which it is associ ated.
I t i s strongly recommended that an appli cation avoi d the use of a part-select as the return type of a functi on
because the li feti me of the obj ect to which the part-select refers may not extend beyond the functi on return
statement.
Exampl e:
sc_dt::sc_subref<sc_bv_base> get_byte(sc_bv_base bv, i nt pos) {
return bv(pos+7,pos); // Unsafe: returned part-select ref erences l ocal vari abl e
}
7.9.8.4 Assignment operators
Overl oaded assi gnment operators shall provide conversion f rom SystemC data types and the nati ve C++
integer representation to l val ue part-selects. If the size of a data type or string l iteral operand dif fers from the
part-sel ect word l ength, truncation or zero-extensi on shall be used, as described in 7.2.1. If an array of bool
or array of sc_logic is assi gned to a part-sel ect and i ts number of elements i s less than the part-select word
length, the val ue of the part-sel ect shall be undefi ned.
The default assi gnment operator for an rvalue part-select i s pri vate to prevent its use by an appl ication.
7.9.8.5 Explicit type conversion
const std::string to_str ing() const;
const std::string to_str ing( sc_numrep ) const;
const std::string to_str ing( sc_numrep , bool ) const;
Member f unction to_str ing shal l convert to an std::str ing representation, as described i n 7.2.11.
Call ing the to_str ing f uncti on with a single argument is equi valent to call ing the to_str ing f uncti on
wi th two arguments, where the second argument i s true. Attempti ng to cal l the si ngl e or doubl e
argument to_str ing function for a part-select wi th one or more elements set to the hi gh-impedance
or unknown state shall be an error.
Call ing the to_str ing function with no arguments shall create a logic val ue stri ng wi th a single '1',
'0' , 'Z ' , or 'X ' corresponding to each bit. Thi s string shall not pref ixed by " 0b" or a leadi ng zero.
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
< T>, or
sc_concr ef_r
< T1,T2>, or i nteger type int, l ong, unsi gned int, unsi gned long, sc_signed,
sc_unsi gned, sc_i nt_base, or sc_uint_base.
i represents an obj ect of integer type int.
A represents an array obj ect with el ements of type char , bool , or sc_l ogi c.
The operands may al so be of any other cl ass that i s derived from those just given.
Table 26sc_subref_r
< T> ,
members of sc_subr ef
{
publ ic:
// Copy constructor
sc_concr ef_r
< T1,T2>& a );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
();
// Bit selecti on
sc_bi tref_r
<sc_concr ef_r
();
sc_concr ef_r
< T1,T2>& );
} ;
// -------------------------------------------------------------
templ ate <class T1, class T2>
class sc_concr ef
<T1,T2>
{
publ ic:
// Copy constructor
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
( const sc_concr ef
< T1,T2>& a );
// Assi gnment operators
templ ate <class T>
sc_concr ef
<T> & a );
templ ate <class T1, class T2>
sc_concr ef
< T1,T2>& a );
sc_concr ef
< T1,T2>& a );
sc_concr ef
< sc_concr ef
< sc_concr ef
< sc_concr ef
();
} ;
// r-val ue concatenation operators and functi ons
templ ate <typename C1, typename C2>
sc_concr ef_r
< T>, or
sc_concr ef_r
< T1,T2>, or i nteger type int, long, unsigned int, unsigned long, sc_signed,
sc_unsigned, sc_int_base, or sc_uint_base.
i represents an obj ect of integer type int.
A represents an array obj ect with el ements of type char , bool, or sc_logic.
The operands may al so be of any other cl ass that i s derived from those just given.
Binary bi twise operators shal l return a result wi th a word length that i s equal to the word length of the
longest operand.
The lef t shi ft operator shal l return a resul t with a word length that i s equal to the word l ength of its
concatenation operand plus the ri ght (i nteger) operand. Bi ts added on the ri ght-hand side of the resul t shal l
be set to zero.
The ri ght shi ft operator shal l return a resul t wi th a word length that i s equal to the word length of i ts
concatenation operand. Bits added on the lef t-hand side of the resul t shal l be set to zero.
sc_concr ef
< T1,T2> obj ects to sati sf y the requi rements of thi s subcl ause. I t i s unspeci f ied whether these operators are
members of sc_concr ef_r
< T>
Table 31sc_concref_r
< T>
sc_concr ef_r
< T1,T2>
const sc_bv_base&
const sc_l v_base&
Argument C2 has one of the types j ust gi ven or a type i n the f oll owing li st:
sc_bi tref
<T>
sc_subr ef
< T>
sc_concr ef
<T1,T2>
sc_bv_base&
sc_l v_base&
Additional templ ate special izations for rval ue concatenati ons shal l be provi ded f or the cases where a si ngl e
argument has type bool, const char * , or const sc_logic& . Thi s argument shal l be impl icitly converted to an
equi val ent si ngl e-bit const sc_lv_base obj ect.
A template speci ali zati on f or l val ue concatenations shall be provi ded for all combinati ons of concatenation
argument types C1 and C2, where each argument has a type in the foll owing li st:
sc_bi tref
<T>
sc_subr ef
< T>
sc_concr ef
<T1,T2>
sc_bv_base&
sc_l v_base&
7.10 Fixed-point types
This subclause descri bes the f ixed-point types and the operations and conventions imposed by these types.
7.10.1 Fixed-point representation
I n the SystemC binary fi xed-poi nt representation, a number shall be represented by a sequence of bits wi th a
specif ied positi on f or the bi nary point. Bi ts to the l eft of the binary point shal l represent the i nteger part of
the number, and bi ts to the ri ght of the bi nary poi nt shal l represent the f racti onal part of the number.
A SystemC fi xed-point type shal l be characterized by the fol lowing:
The word length (wl), whi ch shal l be the total number of bits i n the number representation.
The integer word length (iwl), whi ch shall be the number of bits in the integer part (the position of
the binary poi nt rel ative to the left-most bit).
The bit encoding (which shall be signed, twos compliment, or unsigned).
The ri ght-most bi t of the number shal l be the l east signif icant bi t (LSB), and the left-most bit shall be the
most signif icant bi t (MSB).
The bi nary poi nt may be located outside of the data bits. That is, the binary point may be a number of bit
posi ti ons to the ri ght of the LSB or it may be a number of bit positions to the l ef t of the MSB.
The f ixed-point representati on can be interpreted accordi ng to the f oll owing three cases:
wl < iwl
There are (iwl-wl) zeros between the LSB and the binary poi nt. See index 1 in Table 32 f or an
exampl e of this case.
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
2
n1
(= MI N) <= x <= (2
n1
1) (= MAX)
Table 40Overflow modes
Overflow mode Name
Saturation SC_SAT
Saturationtozero SC_SAT_ZERO
Symmetrical saturation SC_SAT_SYM
Wrap-around
a
a
With 0 or n_bitssaturated bits(n_bits> 0). The default valuefor n_bits
is0.
SC_WRAP
Signmagnitudewrap-around
a
SC_WRAP_SM
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
;
f ri end cl ass sc_fxnum_subr ef
;
f ri end cl ass sc_fxnum_fast_bi tref
;
f ri end cl ass sc_fxnum_fast_subr ef
;
publ ic:
// Unary operators
const sc_f xval oper ator- () const;
const sc_f xval oper ator + () const;
// Binary operators
#def ine DECL_BI N_OP_T( op , tp ) \
f riend const sc_f xval operator op ( const sc_f xnum& , tp ); \
f riend const sc_f xval operator op ( tp , const sc_f xnum& );
#def ine DECL_BI N_OP_OTHER( op ) \
DECL_BIN_OP_T( op , int64 ) \
DECL_BIN_OP_T( op , uint64 ) \
DECL_BIN_OP_T( op , const sc_int_base& ) \
DECL_BIN_OP_T( op , const sc_uint_base& ) \
DECL_BIN_OP_T( op , const sc_signed& ) \
DECL_BIN_OP_T( op, const sc_unsi gned& )
#def ine DECL_BI N_OP( op , dummy ) \
f riend const sc_f xval operator op ( const sc_fxnum& , const sc_f xnum& ); \
DECL_BIN_OP_T( op , int ) \
DECL_BIN_OP_T( op , unsigned i nt ) \
DECL_BIN_OP_T( op , long ) \
DECL_BIN_OP_T( op , unsigned l ong ) \
DECL_BIN_OP_T( op , fl oat ) \
DECL_BIN_OP_T( op , double ) \
DECL_BIN_OP_T( op, const char* ) \
DECL_BIN_OP_T( op , const sc_f xval &) \
DECL_BIN_OP_T( op , const sc_f xval_f ast& ) \
DECL_BIN_OP_T( op , const sc_f xnum_f ast& ) \
DECL_BIN_OP_OTHER( op )
DECL_BI N_OP( * , mul t )
DECL_BIN_OP( + , add )
DECL_BIN_OP( - , sub )
DECL_BIN_OP( / , div )
#undef DECL_BI N_OP_T
#undef DECL_BI N_OP_OTHER
#undef DECL_BI N_OP
f riend const sc_f xval oper ator << ( const sc_fxnum& , int );
f riend const sc_f xval oper ator >> ( const sc_fxnum& , int );
// Relati onal (including equali ty) operators
#def ine DECL_REL _OP_T( op , tp ) \
f riend bool operator op ( const sc_fxnum& , tp ); \
f riend bool operator op ( tp , const sc_fxnum& ); \
DECL_REL_OP_T( op , int64 ) \
DECL_REL_OP_T( op , uint64 ) \
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
oper ator [] ( i nt );
// Part selection
const sc_fxnum_subr ef
r ange( i nt , int );
const sc_fxnum_subr ef
r ange() const;
sc_fxnum_subr ef
r ange();
// Impl icit conversion
operator double() const;
// Expl icit conversi on to primiti ve types
short to_shor t() const;
unsi gned short to_ushor t() const;
int to_int() const;
unsi gned int to_uint() const;
long to_long() const;
unsi gned long to_ulong() const;
int64 to_int64() const;
uint64 to_uint64() const;
fl oat to_float() const;
doubl e to_double() const;
// Expl icit conversion to character stri ng
const std::string to_str ing() const;
const std::string to_str ing( sc_numrep ) const;
const std::string to_str ing( sc_numrep , bool ) const;
const std::string to_str ing( sc_f mt ) const;
const std::string to_str ing( sc_numrep , sc_f mt ) const;
const std::string to_str ing( sc_numrep , bool , sc_fmt ) const;
const std::string to_dec() const;
const std::string to_bin() const;
const std::string to_oct() const;
const std::string to_hex() const;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
;
f ri end cl ass sc_fxnum_subr ef
;
f ri end cl ass sc_fxnum_fast_bi tref
;
f ri end cl ass sc_fxnum_fast_subr ef
;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
oper ator [] ( i nt );
// Part selection
const sc_fxnum_fast_subr ef
r ange( i nt , int );
const sc_fxnum_fast_subr ef
r ange() const;
sc_fxnum_fast_subr ef
r ange();
// Impl icit conversion
operator double() const;
// Expl icit conversi on to primiti ve types
short to_shor t() const;
unsi gned short to_ushor t() const;
int to_int() const;
unsi gned int to_uint() const;
long to_long() const;
unsi gned long to_ulong() const;
int64 to_int64() const;
uint64 to_uint64() const;
fl oat to_float() const;
doubl e to_double() const;
// Expl icit conversion to character stri ng
const std::string to_str ing() const;
const std::string to_str ing( sc_numrep ) const;
const std::string to_str ing( sc_numrep , bool ) const;
const std::string to_str ing( sc_f mt ) const;
const std::string to_str ing( sc_numrep , sc_f mt ) const;
const std::string to_str ing( sc_numrep , bool , sc_fmt ) const;
const std::string to_dec() const;
const std::string to_bin() const;
const std::string to_oct() const;
const std::string to_hex() const;
// Query val ue
bool is_neg() const;
bool is_zer o() const;
bool quantization_flag() const;
bool over flow_flag() const;
const sc_f xval _f ast value() const;
// Query parameters
int wl() const;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
{
f riend cl ass sc_fxnum;
f ri end cl ass sc_fxnum_fast_bi tref
;
publ ic:
// Copy constructor
sc_fxnum_bi tr ef
( const sc_fxnum_bi tr ef
& );
// Assi gnment operators
#def ine DECL_ASN_OP_T( op , tp ) \
sc_fxnum_bi tr ef
& operator op ( tp );
#def ine DECL_ASN_OP( op ) \
DECL_ASN_OP_T( op , const sc_fxnum_bi tref
& ) \
DECL_ASN_OP_T( op , const sc_fxnum_fast_bi tref
& ) \
DECL_ASN_OP_T( op , bool )
DECL_ASN_OP( = )
DECL_ASN_OP( & = )
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
( sc_fxnum& , int );
sc_fxnum_bi tr ef
();
} ;
// -------------------------------------------------------------
class sc_fxnum_fast_bi tref
{
f riend cl ass sc_fxnum_fast;
f ri end cl ass sc_fxnum_bi tr ef
;
publ ic:
// Copy constructor
sc_fxnum_fast_bi tref
( const sc_fxnum_fast_bi tr ef
& );
// Assi gnment operators
#def ine DECL_ASN_OP_T( op , tp ) \
sc_fxnum_fast_bi tref
& operator op ( tp );
#def ine DECL_ASN_OP( op ) \
DECL_ASN_OP_T( op , const sc_fxnum_bi tref
& ) \
DECL_ASN_OP_T( op , const sc_fxnum_fast_bi tref
& ) \
DECL_ASN_OP_T( op , bool )
DECL_ASN_OP( = )
DECL_ASN_OP( & = )
DECL_ASN_OP( |= )
DECL_ASN_OP( ^= )
#undef DECL_ASN_OP_T
#undef DECL_ASN_OP
// Impl icit conversion
oper ator bool() const;
// Pri nt or dump content
void pr int( std::ostream& = std::cout ) const;
void scan( std::i stream& = std::cin );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
( sc_fxnum_f ast& , i nt );
sc_fxnum_fast_bi tref
();
} ;
} // namespace sc_dt
7.10.22.3 Constraints on usage
Bit-select obj ects shal l only be created using the bi t-select operators of an i nstance of a class derived f rom
sc_fxnum or sc_fxnum_fast.
An appl ication shall not expli citl y create an i nstance of any bi t-sel ect class.
An appl ication should not decl are a reference or pointer to any bit-sel ect obj ect.
7.10.22.4 Assignment operators
Overl oaded assi gnment operators shall provide conversi on f rom bool val ues.
7.10.22.5 Implicit type conversion
oper ator bool() const;
Operator bool can be used for i mpli ci t type conversi on from a bi t-sel ect to the native C++ bool
representation.
7.10.23 Part-selects
7.10.23.1 Description
Cl ass sc_fxnum_subr ef
{
f riend cl ass sc_fxnum;
f ri end cl ass sc_fxnum_fast_subr ef
;
publ ic:
// Copy constructor
sc_fxnum_subr ef
( const sc_fxnum_subr ef
& );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
();
// Assi gnment operators
#def ine DECL_ASN_OP_T( tp ) \
sc_fxnum_subr ef
& )
DECL_ASN_OP_T( const sc_fxnum_fast_subr ef
& )
DECL_ASN_OP_T( const sc_bv_base& )
DECL_ASN_OP_T( const sc_l v_base& )
DECL_ASN_OP_T( const char* )
DECL_ASN_OP_T( const bool* )
DECL_ASN_OP_T( const sc_signed& )
DECL_ASN_OP_T( const sc_unsigned& )
DECL_ASN_OP_T( const sc_i nt_base& )
DECL_ASN_OP_T( const sc_ui nt_base& )
DECL_ASN_OP_T( int64 )
DECL_ASN_OP_T( uint64 )
DECL_ASN_OP_T( i nt )
DECL_ASN_OP_T( unsi gned int )
DECL_ASN_OP_T( long )
DECL_ASN_OP_T( unsi gned long )
DECL_ASN_OP_T( char )
#undef DECL_ASN_OP_T
#def ine DECL_ASN_OP_T_A( op , tp ) \
sc_fxnum_subr ef
& operator op ## = ( tp );
#def ine DECL_ASN_OP_A( op ) \
DECL_ASN_OP_T_A( op , const sc_fxnum_subr ef
& ) \
DECL_ASN_OP_T_A( op , const sc_fxnum_fast_subr ef
& ) \
DECL_ASN_OP_T_A( op , const sc_bv_base& ) \
DECL_ASN_OP_T_A( op , const sc_l v_base& )
DECL_ASN_OP_A( & )
DECL_ASN_OP_A( | )
DECL_ASN_OP_A( ^ )
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
& , tp ); \
f riend bool operator op ( tp , const sc_fxnum_subr ef
& );
#def ine DECL_REL _OP( op ) \
f riend bool operator op ( const sc_fxnum_subr ef
& ); \
f riend bool operator op ( const sc_fxnum_subr ef
& ); \
DECL_REL_OP_T( op , const sc_bv_base& ) \
DECL_REL_OP_T( op , const sc_l v_base& ) \
DECL_REL_OP_T( op , const char* ) \
DECL_REL_OP_T( op , const bool* ) \
DECL_REL_OP_T( op , const sc_signed& ) \
DECL_REL_OP_T( op , const sc_unsi gned& ) \
DECL_REL_OP_T( op , i nt ) \
DECL_REL_OP_T( op , unsi gned int ) \
DECL_REL_OP_T( op , l ong ) \
DECL_REL_OP_T( op , unsi gned long )
DECL_REL_OP( == )
DECL_REL_OP( ! = )
#undef DECL_REL_OP_T
#undef DECL_REL_OP
// Reduce f unctions
bool and_r educe() const;
bool nand_r educe() const;
bool or_r educe() const;
bool nor_reduce() const;
bool xor_reduce() const;
bool xnor _reduce() const;
// Query parameter
int length() const;
// Expl icit conversions
int to_int() const;
unsi gned int to_uint() const;
long to_long() const;
unsi gned long to_ulong() const;
int64 to_int64() const;
uint64 to_uint64() const;
const std::string to_str ing() const;
const std::string to_str ing( sc_numrep ) const;
const std::string to_str ing( sc_numrep , bool ) const;
// Impl icit conversion
operator sc_bv_base() const;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
( sc_fxnum& , int , i nt );
sc_fxnum_subr ef
();
} ;
// -------------------------------------------------------------
class sc_fxnum_fast_subr ef
{
f riend cl ass sc_fxnum_fast;
f ri end cl ass sc_fxnum_subr ef
;
publ ic:
// Copy constructor
sc_fxnum_fast_subr ef
( const sc_fxnum_fast_subr ef
& );
// Destructor
~sc_fxnum_fast_subr ef
();
// Assi gnment operators
#def ine DECL_ASN_OP_T( tp ) \
sc_fxnum_fast_subr ef
& operator= ( tp );
DECL_ASN_OP_T( const sc_fxnum_subr ef
& )
DECL_ASN_OP_T( const sc_fxnum_fast_subr ef
& )
DECL_ASN_OP_T( const sc_bv_base& )
DECL_ASN_OP_T( const sc_l v_base& )
DECL_ASN_OP_T( const char* )
DECL_ASN_OP_T( const bool* )
DECL_ASN_OP_T( const sc_signed& )
DECL_ASN_OP_T( ( const sc_unsigned& )
DECL_ASN_OP_T( const sc_i nt_base& )
DECL_ASN_OP_T( const sc_ui nt_base& )
DECL_ASN_OP_T( int64 )
DECL_ASN_OP_T( uint64 )
DECL_ASN_OP_T( i nt )
DECL_ASN_OP_T( unsi gned int )
DECL_ASN_OP_T( long )
DECL_ASN_OP_T( unsi gned long )
DECL_ASN_OP_T( char )
#undef DECL_ASN_OP_T
#def ine DECL_ASN_OP_T_A( op , tp ) \
sc_f xnum_f ast_subref& operator op ## = ( tp );
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
& ) \
DECL_ASN_OP_T_A( op , const sc_fxnum_fast_subr ef
& ) \
DECL_ASN_OP_T_A( op , const sc_bv_base& ) \
DECL_ASN_OP_T_A( op , const sc_l v_base& )
DECL_ASN_OP_A( & )
DECL_ASN_OP_A( | )
DECL_ASN_OP_A( ^ )
#undef DECL_ASN_OP_T_A
#undef DECL_ASN_OP_A
// Relati onal operators
#def ine DECL_REL _OP_T( op , tp ) \
f riend bool operator op ( const sc_fxnum_fast_subr ef
& , tp ); \
f riend bool operator op ( tp , const sc_fxnum_fast_subr ef
& );
#def ine DECL_REL _OP( op ) \
f riend bool operator op ( const sc_fxnum_fast_subr ef
& ); \
f riend bool operator op ( const sc_fxnum_fast_subr ef
& ); \
DECL_REL_OP_T( op , const sc_bv_base& ) \
DECL_REL_OP_T( op , const sc_l v_base& ) \
DECL_REL_OP_T( op , const char* ) \
DECL_REL_OP_T( op , const bool* ) \
DECL_REL_OP_T( op , const sc_signed& ) \
DECL_REL_OP_T( op , const sc_unsi gned& ) \
DECL_REL_OP_T( op , i nt ) \
DECL_REL_OP_T( op , unsi gned int ) \
DECL_REL_OP_T( op , l ong ) \
DECL_REL_OP_T( op , unsi gned long )
DECL_REL_OP( == )
DECL_REL_OP( ! = )
#undef DECL_REL_OP_T
#undef DECL_REL_OP
// Reduce f unctions
bool and_r educe() const;
bool nand_r educe() const;
bool or_r educe() const;
bool nor_reduce() const;
bool xor_reduce() const;
bool xnor _reduce() const;
// Query parameter
int length() const;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
( sc_fxnum_fast& , int , i nt );
sc_fxnum_fast_subr ef
();
} ;
} // namespace sc_dt
7.10.23.3 Constraints on usage
Fixed-point part-sel ect objects shal l onl y be created usi ng the part-sel ect operators of an instance of a cl ass
derived from sc_fxnum or sc_fxnum_fast.
An appl ication shall not expli citl y create an instance of any fixed-point part-select class.
An appl ication should not declare a ref erence or poi nter to any fi xed-point part-select object.
No ari thmeti c operators are provided f or f ixed-poi nt part-sel ects.
7.10.23.4 Assignment operators
Overl oaded assi gnment operators shall provide conversion f rom SystemC data types and the nati ve C++
integer representation to f ixed-point part-sel ects. If the si ze of a data type or string l iteral operand di ff ers
f rom the f ixed-point part-sel ect word l ength, truncati on, zero-extensi on, or sign-extensi on shal l be used, as
descri bed in 7.2.1.
7.10.23.5 Bitwise operators
Overl oaded bi twi se operators shal l be provided for f ixed-point part-select, bit-vector, and l ogi c-vector
operands.
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
= SC_NOW );
~sc_length_context();
void begin();
void end();
stati c const sc_length_param& default_value();
const sc_l ength_param& value() const;
} ;
} // namespace sc_dt
7.11.2.3 Public constructor
expl icit sc_length_context( const sc_length_param& , sc_context_begi n
= SC_NOW );
Constructor sc_length_context shall create an sc_length_context obj ect. The fi rst argument shall
be the length parameter to use. The second argument, if suppl ied, shall have the value SC_NOW or
SC_LATER.
7.11.2.4 Public member functions
void begin();
Member f uncti on begin shal l set the current length context, as descri bed i n 7.2.3.
stati c const sc_l ength_param& default_value();
Member f uncti on default_value shall return the l ength parameter currently in context.
void end();
Member f unction end shal l deacti vate the length context and shall remove it from the top of the
length context stack, as described in 7.2.3.
const sc_l ength_param& value() const;
Member f uncti on value shall return the l ength parameter.
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
= SC_NOW );
~sc_fxtype_context();
void begin();
void end();
stati c const sc_f xtype_params& default_value();
const sc_f xtype_params& value() const;
} ;
} // namespace sc_dt
7.11.4.3 Public constructor
expl icit sc_fxtype_context( const sc_fxtype_params& , sc_context_begi n
= SC_NOW );
Constructor sc_fxtype_context shal l create an sc_fxtype_context obj ect. The fi rst argument shall
be the f ixed-point length parameter to use. The second argument (if suppl ied) shall have the val ue
SC_NOW or SC_LATER.
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
);
sc_fxcast_switch( const sc_fxcast_swi tch& );
// Operators
sc_f xcast_swi tch& oper ator = ( const sc_fxcast_swi tch& );
f riend bool oper ator == ( const sc_fxcast_swi tch& , const sc_fxcast_swi tch& );
f riend bool oper ator != ( const sc_fxcast_switch& , const sc_fxcast_swi tch& );
// Methods
const std::string to_str ing() const;
void pr int( std::ostream& = std::cout ) const;
void dump( std::ostream& = std::cout ) const;
} ;
} // namespace sc_dt
7.11.5.3 Public constructors
sc_fxcast_switch ();
sc_fxcast_switch ( sc_swi tch
);
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
= SC_NOW );
sc_fxcast_context();
void begin();
void end();
stati c const sc_fxcast_swi tch& default_value();
const sc_f xcast_switch& value() const;
} ;
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
= SC_NOW );
Constructor sc_fxcast_context shall create an sc_fxcast_context obj ect. I ts fi rst argument shal l be
the floati ng-point cast switch to use. The second argument (i f suppli ed) shal l have the val ue
SC_NOW or SC_LATER.
7.11.6.4 Public member functions
void begin();
Member f uncti on begin shal l set the current fl oating-point cast context, as descri bed in 7.10.7.
stati c const sc_fxcast_swi tch& default_value();
Member f uncti on default_value shall return the cast swi tch currently in context.
void end();
Member functi on end shall deactivate the fl oating-point cast context and remove it f rom the top of
the fl oating-point cast context stack.
const sc_f xcast_switch& value() const;
Member f uncti on value shall return the cast swi tch.
7.12 Control of string representation
7.12.1 Description
Type sc_numr ep is used to control the formatting of number representati ons as character stri ngs when
passed as an argument to the to_str ing member f uncti on of a data type object.
7.12.2 Class definition
namespace sc_dt {
enum sc_numr ep
{
SC_NOBASE = 0,
SC_BIN = 2,
SC_OCT = 8,
SC_DEC = 10,
SC_HEX = 16,
SC_BIN_US,
SC_BIN_SM,
SC_OCT_US,
SC_OCT_SM,
SC_HEX_US,
SC_HEX_SM,
SC_CSD
IEEE Std 1666-2011
IEEE Standard for Standard SystemC
<T> iterator;
typedef sc_vector_i ter