1、 IEC 61691-7 Edition 1.0 2009-12 INTERNATIONAL STANDARD Behavioural languages Part 7: SystemC Language Reference Manual IEC 61691-7:2009(E) IEEE Std 1666-2005(E) IEEE Std 1666 THIS PUBLICATION IS COPYRIGHT PROTECTED Copyright 2009 IEEE All rights reserved. IEEE is a registered trademark in the U.S.
2、Patent & Trademark Office, owned by the Institute of Electrical and Electronics Engineers, Inc. Unless otherwise specified, no part of this publication may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying and microfilm, without permission in wri
3、ting from the IEC Central Office. Any questions about IEEE copyright should be addressed to the IEEE. Enquiries about obtaining additional rights to this publication and other information requests should be addressed to the IEC or your local IEC member National Committee. IEC Central Office Institut
4、e of Electrical and Electronics Engineers, Inc 3, rue de Varemb 3 Park Avenue CH-1211 Geneva 20 New York, NY10016-5997 Switzerland USA Email: inmailiec.ch Email: stds.iprieee.org Web: www.iec.ch Web: www.ieee.org About the IEC The International Electrotechnical Commission (IEC) is the leading global
5、 organization that prepares and publishes International Standards for all electrical, electronic and related technologies. About IEC publications The technical content of IEC publications is kept under constant review by the IEC. Please make sure that you have the latest edition, a corrigenda or an
6、amendment might have been published. Catalogue of IEC publications: www.iec.ch/searchpub The IEC on-line Catalogue enables you to search by a variety of criteria (reference number, text, technical committee,). It also gives information on projects, withdrawn and replaced publications. IEC Just Publi
7、shed: www.iec.ch/online_news/justpub Stay up to date on all new IEC publications. Just Published details twice a month all new publications released. Available on-line and also by email. Electropedia: www.electropedia.org The worlds leading online dictionary of electronic and electrical terms contai
8、ning more than 20 000 terms and definitions in English and French, with equivalent terms in additional languages. Also known as the International Electrotechnical Vocabulary online. Customer Service Centre: www.iec.ch/webstore/custserv If you wish to give us your feedback on this publication or need
9、 further assistance, please visit the Customer Service Centre FAQ or contact us: Email: csciec.ch Tel.: +41 22 919 02 11 IEC 61691-7 Edition 1.0 2009-12 INTERNATIONAL STANDARD Behavioural languages Part 7: SystemC Language Reference Manual INTERNATIONAL ELECTROTECHNICAL COMMISSION XP ICS 25.040, 35.
10、060 PRICE CODE ISBN 2-8318-1069-4IEEE Std 1666 Foreword.xi IEEE Introduction .xvi 1. Overview 1 1.1 Scope 1 1.2 Purpose. 1 1.3 Subsets . 1 1.4 Relationship with C+. 1 1.5 Guidance for readers 2 2. References 3 3. Terminology and conventions used in this standard 4 3.1 Terminology. 4 3.1.1 Shall, sho
11、uld, may, can. 4 3.1.2 Implementation, application. 4 3.1.3 Call, called from, derived from 4 3.1.4 Specific technical terms . 4 3.2 Syntactical conventions . 6 3.2.1 Implementation-defined. 6 3.2.2 Disabled . 6 3.2.3 Ellipsis (.). 6 3.2.4 Class names 6 3.2.5 Embolded text7 3.3 Semantic conventions
12、7 3.3.1 Class definitions and the inheritance hierarchy . 7 3.3.2 Function definitions and side-effects . 7 3.3.3 Functions whose return type is a reference or a pointer. 7 3.3.4 Namespaces and internal naming. 9 3.3.5 Non-compliant applications and errors 9 3.4 Notes and examples . 10 4. Elaboratio
13、n and simulation semantics . 11 4.1 Elaboration. 11 4.1.1 Instantiation . 11 4.1.2 Process macros. 13 4.1.3 Port binding and export binding 13 4.1.4 Setting the time resolution . 14 4.2 Simulation 14 4.2.1 The scheduling algorithm 15 4.2.2 Cycles in the scheduling algorithm 17 4.3 Running elaboratio
14、n and simulation 18 4.3.1 Function declarations. 18 4.3.2 Function sc_elab_and_sim. 18 4.3.3 Functions sc_argc and sc_argv 19 4.3.4 Running under application control using functions sc_main and sc_start. 19 4.3.5 Running under control of the kernel 20 4.4 Elaboration and simulation callbacks 20 4.4.
15、1 before_end_of_elaboration 21 4.4.2 end_of_elaboration 22 4.4.3 start_of_simulation 23 CONTENTSPublished by IEC under licence from IEEE. 2005 IEEE. All rights reserved. IEC 61691-7:2009(E) IEEE Std 1666-2005(E) i 4.4.4 end_of_simulation . 23 4.5 Other functions related to the scheduler 24 4.5.1 Fun
16、ction declarations . 24 4.5.2 Function sc_stop, sc_set_stop_mode, and sc_get_stop_mode. 24 4.5.3 Function sc_time_stamp. 25 4.5.4 Function sc_delta_count. 26 4.5.5 Function sc_is_running 26 5. Core language class definitions . 27 5.1 Class header files . 27 5.1.1 #include “systemc“. 27 5.1.2 #includ
17、e “systemc.h“ 27 5.2 sc_module 29 5.2.1 Description . 29 5.2.2 Class definition.29 5.2.3 Constraints on usage. 31 5.2.4 kind. 31 5.2.5 SC_MODULE 31 5.2.6 Constructors .32 5.2.7 SC_CTOR 32 5.2.8 SC_HAS_PROCESS 33 5.2.9 SC_METHOD, SC_THREAD, SC_CTHREAD. 33 5.2.10 Method process 34 5.2.11 Thread and cl
18、ocked thread processes. 35 5.2.12 Clocked thread processes and reset_signal_is 36 5.2.13 sensitive 37 5.2.14 dont_initialize. 38 5.2.15 set_stack_size. 39 5.2.16 next_trigger 39 5.2.17 wait. 41 5.2.18 Positional port binding . 43 5.2.19 before_end_of_elaboration, end_of_elaboration, start_of_simulat
19、ion, end_of_simulation 44 5.2.20 get_child_objects 45 5.2.21 sc_gen_unique_name . 45 5.2.22 sc_behavior and sc_channel. 46 5.3 sc_module_name . 47 5.3.1 Description. 47 5.3.2 Class definition 47 5.3.3 Constraints on usage 47 5.3.4 Module hierarchy . 48 5.3.5 Member functions 48 5.4 sc_sensitive 50 5
20、.4.1 Description. 50 5.4.2 Class definition 50 5.4.3 Constraints on usage 50 5.4.4 operator 50 5.5 sc_spawn_options and sc_spawn. 52 5.5.1 Description. 52 5.5.2 Class definition 52 5.5.3 Constraints on usage 53 5.5.4 Constructors .53 5.5.5 Member functions 53Published by IEC under licence from IEEE.
21、 2005 IEEE. All rights reserved. IEC 61691-7:2009(E) IEEE Std 1666-2005(E) ii5.5.6 sc_spawn 54 5.5.7 SC_FORK and SC_JOIN. 56 5.6 sc_process_handle . 58 5.6.1 Description . 58 5.6.2 Class definition.58 5.6.3 Constraints on usage 59 5.6.4 Constructors .59 5.6.5 Member functions 59 5.6.6 sc_get_current
22、_process_handle 61 5.7 sc_event_finder and sc_event_finder_t . 62 5.7.1 Description . 62 5.7.2 Class definition.62 5.7.3 Constraints on usage. 62 5.8 sc_event_and_listand sc_event_or_list. 65 5.8.1 Description . 65 5.8.2 Class definition.65 5.8.3 Constraints on usage. 65 5.8.4 Event lists . 65 5.9 s
23、c_event . 66 5.9.1 Description . 66 5.9.2 Class definition.66 5.9.3 Constraints on usage. 66 5.9.4 notify and cancel 66 5.9.5 Event lists . 67 5.9.6 Multiple event notifications . 67 5.10 sc_time . 68 5.10.1 Description . 68 5.10.2 Class definition. 68 5.10.3 Time resolution 69 5.10.4 Functions and
24、operators . 69 5.10.5 SC_ZERO_TIME. 69 5.11 sc_port 71 5.11.1 Description. 71 5.11.2 Class definition 71 5.11.3 Template parameters 72 5.11.4 Constraints on usage 73 5.11.5 Constructors . 74 5.11.6 kind 74 5.11.7 Named port binding . 74 5.11.8 Member functions for bound ports and port-to-port bindin
25、g. 75 5.11.9 before_end_of_elaboration, end_of_elaboration, start_of_simulation, end_of_simulation 79 5.12 sc_export 80 5.12.1 Description . 80 5.12.2 Class definition. 80 5.12.3 Template parameters 81 5.12.4 Constraints on usage. 81 5.12.5 Constructors . 81 5.12.6 kind. 81 5.12.7 Export binding82 5
26、.12.8 Member functions for bound exports and export-to-export binding 83 5.12.9 before_end_of_elaboration, end_of_elaboration, start_of_simulation, end_of_simulation 84Published by IEC under licence from IEEE. 2005 IEEE. All rights reserved. IEC 61691-7:2009(E) IEEE Std 1666-2005(E) iii 5.13 sc_inte
27、rface 85 5.13.1 Description . 85 5.13.2 Class definition. 85 5.13.3 Constraints on usage. 85 5.13.4 register_port . 86 5.13.5 default_event 86 5.14 sc_prim_channel 88 5.14.1 Description . 88 5.14.2 Class definition. 88 5.14.3 Constraints on usage 89 5.14.4 Constructors . 89 5.14.5 kind. 89 5.14.6 re
28、quest_update and update . 89 5.14.7 next_trigger and wait 90 5.14.8 before_end_of_elaboration, end_of_elaboration, start_of_simulation, end_of_simulation 90 5.15 sc_object 92 5.15.1 Description . 92 5.15.2 Class definition. 92 5.15.3 Constraints on usage. 93 5.15.4 Constructors and hierarchical name
29、s 93 5.15.5 name, basename, and kind 94 5.15.6 print and dump . 95 5.15.7 Functions for object hierarchy traversal. 95 5.15.8 Member functions for attributes. 97 5.16 sc_attr_base 99 5.16.1 Description. 99 5.16.2 Class definition 99 5.16.3 Member functions 99 5.17 sc_attribute. 100 5.17.1 Descriptio
30、n 100 5.17.2 Class definition 100 5.17.3 Template parameters 100 5.17.4 Member functions and data members 100 5.18 sc_attr_cltn. 101 5.18.1 Description .101 5.18.2 Class definition. 101 5.18.3 Constraints on usage. 101 5.18.4 Iterators. 101 6. Predefined channel class definitions 103 6.1 sc_signal_i
31、n_if . 103 6.1.1 Description . 103 6.1.2 Class definition. 103 6.1.3 Member functions 103 6.2 sc_signal_in_if and sc_signal_in_if. 104 6.2.1 Description . 104 6.2.2 Class definition. 104 6.2.3 Member functions 105 6.3 sc_signal_inout_if 106 6.3.1 Description . 106 6.3.2 Class definition. 106 6.3.3 w
32、rite 106Published by IEC under licence from IEEE. 2005 IEEE. All rights reserved. IEC 61691-7:2009(E) IEEE Std 1666-2005(E) iv6.4 sc_signal. 107 6.4.1 Description. 107 6.4.2 Class definition 107 6.4.3 Template parameter T 108 6.4.4 Reading and writing signals. 108 6.4.5 Constructors . 109 6.4.6 regi
33、ster_port . 109 6.4.7 Member functions for reading . 109 6.4.8 Member functions for writing 110 6.4.9 Member functions for events . 110 6.4.10 Diagnostic member functions 110 6.4.11 operator and sc_signal 113 6.5.1 Description . 113 6.5.2 Class definition. 113 6.5.3 Member functions 114 6.6 sc_buffe
34、r 116 6.6.1 Description. 116 6.6.2 Class definition 116 6.6.3 Constructors . 116 6.6.4 Member functions 117 6.7 sc_clock . 119 6.7.1 Description. 119 6.7.2 Class definition 119 6.7.3 Characteristic properties 120 6.7.4 Constructors . 120 6.7.5 write . 120 6.7.6 Diagnostic member functions 120 6.7.7
35、before_end_of_elaboration 121 6.7.8 sc_in_clk 121 6.8 sc_in . 122 6.8.1 Description. 122 6.8.2 Class definition 122 6.8.3 Member functions 123 6.8.4 Function sc_trace . 123 6.8.5 end_of_elaboration 123 6.9 sc_in and sc_in. 124 6.9.1 Description . 124 6.9.2 Class definition. 124 6.9.3 Member function
36、s 126 6.10 sc_inout 127 6.10.1 Description.127 6.10.2 Class definition 127 6.10.3 Member functions 128 6.10.4 initialize 128 6.10.5 Function sc_trace . 128 6.10.6 end_of_elaboration 129 6.10.7 Binding. 129 6.11 sc_inout and sc_inout 130 6.11.1 Description.130 6.11.2 Class definition 130 6.11.3 Membe
37、r functions 132 6.12 sc_out . 133 6.12.1 Description .133Published by IEC under licence from IEEE. 2005 IEEE. All rights reserved. IEC 61691-7:2009(E) IEEE Std 1666-2005(E) v 6.12.2 Class definition. 133 6.12.3 Member functions 133 6.13 sc_signal_resolved . 134 6.13.1 Description.134 6.13.2 Class de
38、finition 134 6.13.3 Constructors . 134 6.13.4 Resolution semantics . 135 6.13.5 Member functions 136 6.14 sc_in_resolved . 137 6.14.1 Description.137 6.14.2 Class definition 137 6.14.3 Member functions 137 6.15 sc_inout_resolved 138 6.15.1 Description .138 6.15.2 Class definition. 138 6.15.3 Member
39、functions 138 6.16 sc_out_resolved . 139 6.16.1 Description .139 6.16.2 Class definition. 139 6.16.3 Member functions. 139 6.17 sc_signal_rv . 140 6.17.1 Description.140 6.17.2 Class definition 140 6.17.3 Semantics and member functions 140 6.18 sc_in_rv 142 6.18.1 Description.142 6.18.2 Class defini
40、tion 142 6.18.3 Member functions 142 6.19 sc_inout_rv. 143 6.19.1 Description .143 6.19.2 Class definition. 143 6.19.3 Member functions 143 6.20 sc_out_rv 145 6.20.1 Description .145 6.20.2 Class definition. 145 6.20.3 Member functions 145 6.21 sc_fifo_in_if. 146 6.21.1 Description .146 6.21.2 Class
41、 definition. 146 6.21.3 Member functions 146 6.22 sc_fifo_out_if. 148 6.22.1 Description.148 6.22.2 Class definition 148 6.22.3 Member functions 148 6.23 sc_fifo 150 6.23.1 Description .150 6.23.2 Class definition. 150 6.23.3 Template parameter T 151 6.23.4 Constructors . 151 6.23.5 register_port .1
42、52 6.23.6 Member functions for reading 152 6.23.7 Member functions for writing 152 6.23.8 The update phase 153 6.23.9 Member functions for events 153Published by IEC under licence from IEEE. 2005 IEEE. All rights reserved. IEC 61691-7:2009(E) IEEE Std 1666-2005(E) vi 6.23.10 Member functions for ava
43、ilable values and free slots 153 6.23.11 Diagnostic member functions. 154 6.23.12 operator 154 6.24 sc_fifo_in . 156 6.24.1 Description .156 6.24.2 Class definition. 156 6.24.3 Member functions 156 6.25 sc_fifo_out . 157 6.25.1 Description .157 6.25.2 Class definition. 157 6.25.3 Member functions 15
44、7 6.26 sc_mutex_if 160 6.26.1 Description.160 6.26.2 Class definition 160 6.26.3 Member functions 160 6.27 sc_mutex 161 6.27.1 Description.161 6.27.2 Class definition 161 6.27.3 Constructors . 161 6.27.4 Member functions 162 6.28 sc_semaphore_if 163 6.28.1 Description.163 6.28.2 Class definition 163
45、 6.28.3 Member functions 163 6.29 sc_semaphore. 164 6.29.1 Description.164 6.29.2 Class definition 164 6.29.3 Constructors . 164 6.29.4 Member functions 165 6.30 sc_event_queue 166 6.30.1 Description .166 6.30.2 Class definition. 166 6.30.3 Constraints on usage. 166 6.30.4 Constructors . 166 6.30.5
46、kind. 167 6.30.6 Member functions 167 7. Data types 169 7.1 Introduction 169 7.2 Common characteristics. 172 7.2.1 Initialization and assignment operators 172 7.2.2 Precision of arithmetic expressions 173 7.2.3 Base class default word length. 174 7.2.4 Word length 175 7.2.5 Bit-select. 175 7.2.6 Par
47、t-select. 175 7.2.7 Concatenation. 176 7.2.8 Reduction operators 178 7.2.9 Integer conversion 178 7.2.10 String input and output. 178 7.2.11 Conversion of application-defined types in integer expressions 179 7.3 String literals 180 7.4 sc_value_base 182Published by IEC under licence from IEEE. 2005
48、IEEE. All rights reserved. IEC 61691-7:2009(E) IEEE Std 1666-2005(E) vii 7.4.1 Description. 182 7.5 Limited-precision integer types . 184 7.5.1 Type definitions 184 7.5.2 sc_int_base . 185 7.5.3 sc_uint_base . 190 7.5.4 sc_int 194 7.5.5 sc_uint 197 7.5.6 Bit-selects. 199 7.5.7 Part-selects .203 7.6
49、Finite-precision integer types. 209 7.6.1 Type definitions . 209 7.6.2 Constraints on usage 209 7.6.3 sc_signed209 7.6.4 sc_unsigned 216 7.6.5 sc_bigint. 223 7.6.6 sc_biguint.225 7.6.7 Bit-selects. 227 7.6.8 Part-selects .231 7.7 Integer concatenations . 236 7.7.1 Description . 236 7.7.2 Class definition. 236 7.7.3 Constraints on usage. 237 7.7.4 Assignment operators. 238 7.7.5 Implicit type conversion. 238 7.7.6 Explicit type conversion. 238 7.7.7 Other member functions. 238 7.8 Generic base proxy class 239 7.8.1 Desc