ts ten con - university of california, irvinedoemer/publications/ir3.pdf · 2016. 2. 22. · the sp...

263

Upload: others

Post on 27-Jan-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

  • The SpecC Internal RepresentationRainer DomerInternal Technical ReportVersion as of January 19, 1999, SpecC V 2.0.3Department of Information and Computer ScienceUniversity of California, IrvineIrvine, CA 92697-3425, [email protected] report describes the data structure and the application procedural interface (API) of the SpecCInternal Representation (SIR). The SIR data structure is used by the SpecC compiler and the SpecCre�nement tools to read, write, store, maintain and modify designs speci�ed with the SpecC language.For import and export, the SIR data structure can be stored in external �les in both readable text andbinary format. This report contains the documentation for the external binary SIR �le format, as well asthe detailed description of the API to the internal representation which is implemented with C++ classes.For each object class, its data �elds and the public methods are listed and briey documented. In addition,this reports contains example programs which use the SIR API to build, modify and store SpecC designexamples.

  • 2

  • Contents1 Introduction 12 The external SIR �le format 32.1 The program ow of the SpecC compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 The program ow of the SpecC re�nement tools . . . . . . . . . . . . . . . . . . . . . . . . . 33 The internal design representation 53.1 The design trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.2 The base classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.3 The API layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 The SIR object classes 114.1 Class SIR Argument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.2 Class SIR Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.3 Class SIR ArgVar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.4 Class SIR ArgVars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.5 Class SIR Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.6 Class SIR Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234.7 Class SIR BhvrInst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254.8 Class SIR BhvrInsts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.9 Class SIR BitSlice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.10 Class SIR BitSlices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334.11 Class SIR Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354.12 Class SIR Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374.13 Class SIR ChnlInst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39i

  • 4.14 Class SIR ChnlInsts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434.15 Class SIR Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454.16 Class SIR Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494.17 Class SIR Constraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554.18 Class SIR Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594.19 Class SIR De�nition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614.20 Class SIR Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654.21 Class SIR Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734.22 Class SIR Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 754.23 Class SIR Exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 774.24 Class SIR Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 814.25 Class SIR Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 834.26 Class SIR Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874.27 Class SIR FileInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 894.28 Class SIR FileList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 914.29 Class SIR Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 934.30 Class SIR Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 994.31 Class SIR ImplIf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1014.32 Class SIR ImplIfs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1034.33 Class SIR Import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1054.34 Class SIR ImportList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1074.35 Class SIR Initializer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1094.36 Class SIR Initials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1114.37 Class SIR Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1134.38 Class SIR Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115ii

  • 4.39 Class SIR Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1194.40 Class SIR Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1214.41 Class SIR Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1234.42 Class SIR LineInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1254.43 Class SIR List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1274.44 Class SIR ListElem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1314.45 Class SIR Member . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1334.46 Class SIR Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1354.47 Class SIR Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1374.48 Class SIR Note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1394.49 Class SIR Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1414.50 Class SIR Parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1434.51 Class SIR Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1454.52 Class SIR Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1474.53 Class SIR Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1494.54 Class SIR PortMap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1514.55 Class SIR PortMaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1534.56 Class SIR PortVar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1554.57 Class SIR PortVars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1594.58 Class SIR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1614.59 Class SIR Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1674.60 Class SIR Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1694.61 Class SIR Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1734.62 Class SIR SymbolPtr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1754.63 Class SIR SymbolPtrs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177iii

  • 4.64 Class SIR Transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1794.65 Class SIR Transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1834.66 Class SIR Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1854.67 Class SIR Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1894.68 Class SIR TypePtr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1914.69 Class SIR TypePtrs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1934.70 Class SIR Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1954.71 Class SIR UserType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1974.72 Class SIR UserTypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1994.73 Class SIR Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2014.74 Class SIR Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2055 The SIR module 2075.1 The SIR header �les . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2075.2 The SIR library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2076 Error handling 2117 Example programs 2137.1 The HelloWorld program using API layer 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2137.2 The HelloWorld program using API layer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2257.3 The Behaviors program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2328 Conclusion 2478.1 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2478.2 Future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2479 References 24910 Index 250iv

  • List of Figures1 Program ow of the SpecC compiler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Generic SIR design tree of level 1 classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Generic SIR design tree of level 2 classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 SIR API layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 SIR header �les and their dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2086 SIR level 1 of the HelloWorld example: root tree . . . . . . . . . . . . . . . . . . . . . . . . . 2157 SIR level 1 of the HelloWorld example: behavior 'Main' . . . . . . . . . . . . . . . . . . . . . 2168 SIR level 1 of the HelloWorld example: method 'main' . . . . . . . . . . . . . . . . . . . . . . 2179 SIR level 2 of the HelloWorld example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23010 SIR level 2 of the Behaviors example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

    v

  • vi

  • List of Listingsclass SIR Argument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11class SIR Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13class SIR ArgVar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15class SIR ArgVars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17class SIR Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19class SIR Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23class SIR BhvrInst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25class SIR BhvrInsts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29class SIR BitSlice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31class SIR BitSlices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33class SIR Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35class SIR Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37class SIR ChnlInst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39class SIR ChnlInsts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43class SIR Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45class SIR Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49class SIR Constraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55class SIR Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59class SIR De�nition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61class SIR Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65class SIR Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73class SIR Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75class SIR Exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77vii

  • class SIR Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81class SIR Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83class SIR Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87class SIR FileInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89class SIR FileList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91class SIR Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93class SIR Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99class SIR ImplIf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101class SIR ImplIfs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103class SIR Import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105class SIR ImportList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107class SIR Initializer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109class SIR Initials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111class SIR Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113class SIR Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115class SIR Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119class SIR Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121class SIR Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123class SIR LineInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125class SIR List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127class SIR ListElem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131class SIR Member . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133class SIR Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135class SIR Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137class SIR Note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139viii

  • class SIR Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141class SIR Parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143class SIR Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145class SIR Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147class SIR Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149class SIR PortMap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151class SIR PortMaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153class SIR PortVar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155class SIR PortVars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159class SIR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161class SIR Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167class SIR Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169class SIR Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173class SIR SymbolPtr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175class SIR SymbolPtrs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177class SIR Transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179class SIR Transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183class SIR Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185class SIR Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189class SIR TypePtr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191class SIR TypePtrs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193class SIR Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195class SIR UserType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197class SIR UserTypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199class SIR Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201ix

  • class SIR Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205Test for Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211HelloWorld example in SpecC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213HelloWorld.cc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218GeneratedHelloWorld.sc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224HelloWorld2.cc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225GeneratedHelloWorld2.sc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229Behaviors example in SpecC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232Behaviors.cc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234GeneratedBehaviors.sc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242

    x

  • 1 IntroductionIn [1, 2, 3], the SpecC language [5] was introducedas a system-level language for specifying and mod-eling embedded systems. The methodology behindthe SpecC design environment, as described in [4],is based on one common design representation tobe used by all SpecC tools for their design mod-els. This common design representation is calledthe SpecC Internal Representation (SIR). This re-port documents the data structure and the applica-tion procedural interface (API) of the SpecC Inter-nal Representation in detail.The SpecC compiler and all other SpecC tools usethe SIR as their internal data structure to store,maintain and modify the design models. Also, theSIR is used to read and write designs from/to ex-ternal �les which can be in readable text or binaryformat. Readable text �les containing SpecC sourcecode usually end with .sc, whereas binary SpecC�les have the su�x .sir and therefore are simply re-ferred to as SIR �les. In Section 2, the program owof the SpecC compiler is described, which involvesboth the internal SIR data structure and externalSIR �les.Section 3 takes a closer look at the SIR data struc-ture by introducing the tree of class objects whichcontains all data of a design. In Section 4, the C++object classes, which build the API to the SIR datastructure, are listed and explained in detail. Foreach class, the C++ class de�nition including pub-lic members and methods is listed, along with a briefdescription of the purpose and usage of the class and

    its API methods.In order to help understanding the SIR API, Sec-tion 7 describes detailed program examples han-dling simple SpecC designs. In particular, the mainportions of the SIR data structure are shown graph-ically for each example. Also, the C++ programcode is listed demonstrating how the SIR API canbe used to easily construct, modify and store SpecCdesigns.Finally, Section 8 concludes this report with a briefsummary and discussion of future work.

    1

  • 2

  • 2 The external SIR �le formatThe SpecC Internal Representation can be storedexternally in a SIR �le which usually is named withthe su�x .sir. Basically, such a �le contains abinary dump of the SIR data structure that is keptin the memory. This section describes how the SIR�le is used with the SpecC compiler and the SpecCre�nement tools to represent the design model beingworked on.2.1 The program ow of the SpecC com-pilerFigure 1 shows the program ow of scc, the SpecCcompiler. The default ow starts on the top of thegraph. A �le with su�x .sc (Design.sc) contain-ing the SpecC source code of a design is processed bythe Preprocessor producing a .si �le (Design.si)which is then fed into the SpecC Parser. From thepreprocessed SpecC code, the Parser builds the SIRdata structure in memory which then can be ac-cessed with the SIR API.By default, the SIR data structure is used by theTranslator to generate a C++ description for sim-ulation (Design.cc and Design.h) which then isfed into the C++ Compiler (producing Design.o)and the Linker which �nally builds an executable�le (Design).The Exporter can be used to create a binary SIR�le (Design.sir) from the internal representation.The Importer, on the other hand, reads a SIR �leand rebuilds the internal data structure in memory.

    Since a SIR �le is a binary �le, it cannot be vieweddirectly. In order to create a readable text �le, a.sir �le must be read by the Importer and then beprocessed by the Deparser which regenerates SpecCsource code (Design.sc).2.2 The program ow of the SpecC re-�nement toolsAs indicated in Figure 1, the program ow of anySpecC re�nement tool is based on the SIR datastructure as design representation. Every re�ne-ment tool reads a design model stored in a SIR �lewith the help of the Importer and performs its re-�nement using the SIR API. When done, the re�neddesign model is written to a new SIR �le using theExporter.The advantage of using the SIR as the only designrepresentation for all SpecC tools is obvious. Everytool can read every other tools output and there-fore tools can be applied in any order to a design.Furthermore, at any time, the design representationcan be converted to readable SpecC source code, sothat the user can inspect the design in detail andcan even manually change it if necessary.The next section describes in detail the contents ofthe central container, the SIR data structure andits API.3

  • Deparser

    Design.scSpecC Source Code

    Preprocessor

    Design.si

    Design.cc

    Design.o

    Design

    Design.h

    Parser

    Translator

    Linker

    C/C++ Object Code

    Executable

    Design.sirSIR File

    Design.sirSIR file C++ Code

    Exporter

    Importer

    Preprocessed Code

    SIRData Structure

    Design.scSpecC Code

    Refinement Tool

    C++ Compiler

    Figure 1: Program ow of the SpecC compiler.4

  • 3 The internal design representa-tionThe internal representation of a SpecC design is acomplex data structure, which can be viewed asa graph. The nodes of the graph are representedby C++ class objects, whereas the edges are repre-sented by C++ pointers.The nodes in the SIR graph are of di�erent types.For example, a node representing a behavior dec-laration is of type SIR Behavior, whereas nodesrepresenting statements and expressions are of typeSIR Statement and SIR Expression, respectively.For each node type, a C++ class de�nes the datamembers and API methods available for the node.These SIR classes are described in detail in Sec-tion 4.Furthermore, the nodes in any SIR graph can beclassi�ed into two groups called levels. The nodesat level 1 contain all basic data contained in a SIR�le, whereas the level 2 nodes represent a higher-level view of the SIR data. In other words, theSIR classes at level 1 contain every information theSpecC language can express, whereas the level 2classes o�er an additional, more abstract view of theinformation. For example, the behavioral hierarchyin a SpecC program, which is not obviously visi-ble at level 1, is represented directly at level 2 (byclasses SIR Behavior, SIR BhvrInst, etc.). Level 2classes are built automatically on top of the level 1classes. As such, they rely on the data stored atlevel 1.As shown below, Figure 2 lists the classes of SIR

    level 1, whereas the level 2 classes are listed in Fig-ure 3.The edges of a SIR graph, representing relationsamong the nodes, can also be classi�ed into twogroups, which will be called pointers and links. Al-though all edges are implemented as standard C++pointers, it is important to distinguish them in theSIR data structure.A pointer represents a containment relation of twoobjects. For example, a compound statement con-tains a list of statements and therefore there existsa pointer from the compound statement object tothe header of the statement list (and also from theheader of the list to the elements of the list).A link represents a (loose) connection between twoobjects, that does not imply any containment. Forexample, expressions and symbols have a link to anode representing their type.3.1 The design treesThe classi�cation of SIR nodes into two levels andthe separation between pointers and links allows toview the SpecC data structure as a generic tree. TheSIR graph becomes a tree, if the edges classi�ed aslinks are ignored and only pointer edges build thearcs between the nodes. Such a graph is called adesign tree.Using the level classi�cation for the nodes, the twogeneric SIR design trees are shown in Figure 2(level 1) and Figure 3 (level 2). The roots ofboth trees are represented by an object of class5

  • SIR_Design

    SIR_FileList

    SIR_Types

    SIR_Symbols

    SIR_Notes

    SIR_FileInfo

    SIR_Import

    SIR_Type

    SIR_TypePtrs

    SIR_TypePtr

    SIR_UserTypes

    SIR_Symbol

    SIR_Note

    SIR_Constant

    SIR_Initializer

    SIR_Parameters

    SIR_Symbols...

    SIR_Labels

    SIR_Statement

    SIR_SymbolPtrs

    SIR_Notes

    ...

    SIR_Constant

    SIR_Initializer

    ...

    SIR_Parameter

    ...

    SIR_Label

    SIR_Notes

    ...

    SIR_SymbolPtr

    SIR_UserType

    SIR_Members

    SIR_Member

    SIR_Symbols

    ...

    SIR_Notes

    ...

    SIR_Constant

    SIR_Expression

    SIR_Statement

    ...

    SIR_Symbols

    ...

    SIR_Statements

    SIR_Statement

    ...

    SIR_SymbolPtrs

    ...

    SIR_Exceptions

    SIR_Constraints

    SIR_Exception

    SIR_Transitions

    SIR_Transition

    SIR_Constraint

    SIR_Expression

    ...

    SIR_SymbolPtrs

    SIR_Statement

    ...

    ...

    SIR_Constant

    SIR_Statement

    SIR_PortMaps

    SIR_PortMap

    SIR_BitSlices

    SIR_BitSlice

    SIR_ImportList

    SIR_Initials

    ...

    SIR_Expressions

    SIR_Expression

    ...

    SIR_Expression

    SIR_Constant

    Figure 2: Generic SIR design tree of level 1 classes6

  • SIR_Design

    SIR_Behaviors

    SIR_Behavior

    SIR_ChnlInsts

    SIR_BhvrInsts

    SIR_ChnlInst

    SIR_BhvrInst

    SIR_Channels

    SIR_Channel

    SIR_PortVars

    SIR_Ports

    SIR_ImplIfs

    SIR_Port

    SIR_PortVar

    SIR_ImplIf

    ...

    ...

    SIR_Variables

    SIR_Functions

    SIR_ChnlInsts

    SIR_BhvrInsts

    SIR_ChnlInst

    SIR_BhvrInst

    SIR_PortVars

    SIR_Ports

    SIR_ImplIfs

    SIR_Port

    SIR_PortVar

    SIR_ImplIf

    ...

    ...

    SIR_Variables

    SIR_Functions

    ...

    SIR_Functions

    SIR_Interfaces

    SIR_Interface

    SIR_Variables

    SIR_Variable

    SIR_Functions

    SIR_Function

    SIR_Arguments

    SIR_Argument

    SIR_ArgVars

    SIR_ArgVar

    ...

    SIR_Variables

    SIR_Channel

    Figure 3: Generic SIR design tree of level 2 classes7

  • SIR Design, which is the only class belonging toboth levels.For level 1, the root object contains a listof source �les (SIR FileList), a list of im-ported binary �les (SIR ImportList), the globaltype table (SIR Types), the global symbol table(SIR Symbols), and optionally a list of global an-notations (SIR Notes).For level 2, the design consists of a list ofbehaviors (SIR Behaviors), a list of chan-nels (SIR Channels), a list of interfaces(SIR Interfaces), a list of global variables(SIR Variables), and a list of global functions(SIR Functions).In both cases, the lists then can contain list ele-ments, which again can contain objects, and so on.The design trees are used mainly for two purposes.First, whenever some sort of traversal is performedover the SIR data structure, the traversal is doneon the design tree. All iterators provided by theclasses operate on the design tree only (they followall pointers, but never follow a link). For exam-ple, when reading or writing a SIR �le with the Im-porter or Exporter, as described in Section 2, it isthe level 1 design tree1 that is traversed (in depth-�rst-search order). Then for every node, its contentsare (re-)stored from/into the external �le, so that itis assured that each object exists exactly once in theSIR �le.1SIR �les only contain data from level 1 classes. Sinceall level 2 classes can be constructed automatically from thelevel 1 classes, there is no need to store them in a SIR �le.

    Second, many methods o�ered by the classes oper-ate not only on the object itself, but also on thesubtree below. For example, all Delete() meth-ods (and the underlying destructors) behave thisway. So when, for example, a behavior (an object ofclass SIR Behavior) is deleted, all its local variablesand functions including their contents are deleted aswell. In particular, when the root node of a design(class SIR Design) is deleted, all the memory oc-cupied by the SIR data structure for this design isfreed.3.2 The base classesIn order to keep the amount of source code for theSIR data structure implementation minimal, baseclasses are used whenever the same functionality isprovided by di�erent standard classes.Almost all classes in the design trees are de-rived from the template classes SIR List orSIR ListElem. SIR List represents (a header of)a double-linked list containing objects of classSIR ListElem.For level 1, all classes are derived from classSIR Unit which provides basic services for binaryinput and output. Furthermore, almost all level 1classes are based on class SIR Node which allowsto store source code location information (�le nameand line number) with each object.For level 2, almost all classes are derived from classSIR Definition which provides basic support forcreation, deletion and renaming of objects. Fur-thermore, behaviors and channels are based on class8

  • SIR Class, and behavior and channel instances arederived from class SIR Instance.For more details on these base classes, please referto Section 4.3.3 The API layersAs shown in Figure 4, the SpecC system consistsof several layers of design representations and in-terfaces. At the highest level, a Graphical User In-terface (GUI) is used for interaction with the user.Alternatively, a Command Line Interface (CLI) tothe SpecC tools is available which, for the advanceduser, allows direct control of the tools and the useof skript languages (shells). Both of these interfacesoperate on external design representations, namelySIR �les.Internally, for the in-memory representation, theSIR provides an Application Procedural Interface(API), as mentioned earlier. As shown in Figure 4,this SIR API consists of two layers, namely the Ker-nel (layer 1) and the Hierarchy Layer (layer 2).The Kernel, as the innermost design representation,represents the lowest level of abstraction in termsof API methods. Use of these methods requiresvery detailed knowledge about the internals of theSIR data structure. No semantic or syntactic er-ror checking is performed. The user is in full re-sponsibility for memory allocation/deallocation, in-sertion/removal of objects, and pointer consistency.Due to these issues, direct use of kernel methodsshould be avoided whenever possible.

    Tools

    System

    "Kernel"

    "Application Layer"

    "Transformation Layer"

    "Hierarchy Layer"Layer 2

    Layer 1

    GUI

    CLI

    SIR API

    Figure 4: SIR API layersFor the SpecC tool programmer, the HierarchyLayer and its API provides the right level of ab-straction. Here, the API layer 2 o�ers easy-to-usemethods which guarantee consistency of the datastructure after each call (even in case of errors).Guaranteed consistency means that the design isa valid and legal SpecC model at any time. Syn-tactic and semantic checking is performed for ev-ery call. If an operation fails, an error is reportedto the caller and the SIR data structure is left un-modi�ed (unless otherwise documented). Memoryallocation/deallocation is automatically performedwith the creation and deletion of objects.Since the API layer 2 is to be used by SpecC tool de-velopers, the lower-level API layer 1 is not describedin this documentation. In the following section,9

  • which lists and describes all classes of the SIR datastructure in alphabetical order, only API methodsof layer 2 are included.Also, please note that in the next section every classis listed with all data members. Although some ofthese represent very low-level information, most ofthem help in understanding the SIR data structure.

    10

  • 4 The SIR object classesIn this section, a complete list of the classes used in the SpecC Internal Representation is given, along witha brief description of the purpose and the contents of each class.4.1 Class SIR ArgumentThe class SIR Argument is part of SIR level 2 and is declared in �le IntRep/Argument.h.4.1.1 Declaration:1 class SIR Argument : /� argument c l a s s in hierarchy tree �/2 public SIR ListElem /� i s a l i s t element �/3 f4 public :5 s i r t y p e p t r �TypePtr ; /� l i nk to type pointer at l e v e l 1 �/6 s i r a r g v a r �ArgVariable ; /� l i nk to argument va r i a b l e ( or NULL) �/789 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//101112 /� ( i n t e rna l ) �/131415 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//161718 static s i r argument � Create ( /� create a new argument for a funct ion �/19 s i r t yp e �Type , /� ( re turns NULL i f SIR Error ) �/20 s i r f u n c t i o n �Function ,21 s i r argument � In se r tBe fo r e = NULL) ; /� de f au l t : append �/2223 s i r argument �Copy( /� create an exact copy ( exc lud ing arg . var . ) �/24 s i r f u n c t i o n �Function , /� for that funct ion �/25 s i r argument � In se r tBe fo r e = NULL) ; /� ( re turns NULL i f SIR Error )�/2627 ERROR Delete ( /� de l e t e t h i s argument ( inc lud ing arg . var . ) �/28 s i r f u n c t i o n �Function ) ;293031 s i r t yp e �GetType (void ) ; /� obta in the type of t h i s argument �/32 g ; 11

  • 4.1.2 Purpose:An object of class SIR Argument represents an argument type of a function or a method.4.1.3 Notes:� The link TypePtr points to the type of this argument.� The link ArgVariable points to the argument variable de�ned with this argument. It is NULL if noargument variable is de�ned.� The method Create creates a new argument of type Type for the function Function. The argumentis inserted before InsertBefore, or appended if InsertBefore is NULL.� The method Copy copies an argument from some function (without its argument variable) and in-serts/appends it for the Function.� The method Delete deletes this argument from the Function if it is not used.� The method GetType obtains the type of this argument.

    12

  • 4.2 Class SIR ArgumentsThe class SIR Arguments is part of SIR level 2 and is declared in �le IntRep/Argument.h.4.2.1 Declaration:1 class SIR Arguments : /� argument c l a s s e s l i s t �/2 public SIR List /� i s s imply a l i s t of arguments �/3 f /� with add i t i ona l methods �/4 public :56 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//789 /� ( i n t e rna l ) �/101112 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//131415 s i r argument � Find ( /� f ind the n�th argument (#1 ) �/16 unsigned int Number) ; /� ( re turns NULL i f not found ) �/1718 s i r argument � Find ( /� f ind argument with type (#2 ) �/19 s i r t yp e �Type ) ; /� ( re turns NULL i f not found ) �/20 g ;4.2.2 Purpose:An object of class SIR Arguments represents a list head. The list contains objects of type SIR Argument.4.2.3 Notes:� The list of arguments is sorted by declaration order and can be traversed with the standard listoperations.� The methods Find search for an argument in this list by Number or Type, respectively. NULL (but noerror) is returned if no argument is found.13

  • 14

  • 4.3 Class SIR ArgVarThe class SIR ArgVar is part of SIR level 2 and is declared in �le IntRep/Argument.h.4.3.1 Declaration:1 class SIR ArgVar : /� argument va r i a b l e c l a s s in hierarchy tree �/2 public SIR ListElem, /� i s a l i s t element �/3 public SIR De f in i t i on /� and a d e f i n i t i o n �/4 f5 public :6 s i r argument �Argument ; /� l i nk to i t s argument entry �/7 s i r paramete r �ParamPtr ; /� l i nk to parameter at l e v e l 1 �/8910 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//111213 /� ( i n t e rna l ) �/141516 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//171819 static s i r a r g v a r � Create ( /� create a new argument va r i a b l e �/20 const char �Name, /� ( re turns NULL i f SIR Error ) �/21 s i r argument �Argument ,22 s i r f u n c t i o n �Function ) ;2324 s i r a r g v a r �Copy( /� create an exact copy ( inc lud ing argument ) �/25 const char �Name = NULL, /� ( re turns NULL i f SIR Error ) �/26 s i r f u n c t i o n �Function = NULL, /� for that funct ion ( d e f au l t : t h i s ) �/27 s i r argument � In se r tBe fo r e = NULL) ; /� de f au l t : append �/2829 ERROR Rename( /� rename t h i s argument va r i a b l e �/30 const char �Name) ;3132 ERROR Delete (void ) ; /� de l e t e t h i s arg . v a r i a b l e ( l eav ing arg . ) �/333435 s i r a r g v a r s � GetList (void ) ; /� obta in a pointer to the va r i a b l e l i s t �/3637 s i r f u n c t i o n � GetFunction (void ) ; /� obta in a pointer to i t s funct ion �/383940 BOOL FindDependant ( /� f ind expr ./ stmnt . depending on t h i s arg . �/41 s i r e x p r e s s i o n ��DepExpr = NULL, /� return expre s s ion found �/42 s i r s ta t ement ��DepStmnt = NULL) ; /� return statement found �/43 g ; 15

  • 4.3.2 Purpose:An object of class SIR ArgVar represents an argument variable (a variable declared in the list of argumentsof a function or a method).4.3.3 Notes:� The link Argument points to the argument object of this argument variable.� The link ParamPtr points down to the parameter at level 1 of this argument variable.� The method Create creates a new argument variable with name Name for the Argument of theFunction.� The method Copy copies this argument variable including its argument object for the Function. Thecopy is inserted before InsertBefore, or appended if InsertBefore is NULL.� The method Rename changes the name of this argument variable to Name.� The method Delete deletes this argument variable if it is not used. Its argument object is not deleted.� The method GetList obtains a pointer to the list head of this argument variable.� The method GetFunction obtains a pointer to the function in which this argument variable is de�ned.� The method FindDependant searches for objects that depend on this argument variable. The methodreturns whether any object was found and, if requested, stores a pointer to the dependent expressionin DepExpr and/or statement in DepStmnt.

    16

  • 4.4 Class SIR ArgVarsThe class SIR ArgVars is part of SIR level 2 and is declared in �le IntRep/Argument.h.4.4.1 Declaration:1 class SIR ArgVars : /� argument va r i a b l e c l a s s e s l i s t �/2 public SIR List /� i s s imply a l i s t of arg . vars . �/3 f /� with add i t i ona l methods �/4 public :56 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//789 /� ( i n t e rna l ) �/101112 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//131415 s i r a r g v a r � Find ( /� f ind an arg . var . with t h i s name �/16 const char �Name) ; /� ( re turns NULL i f not found ) �/17 g ;4.4.2 Purpose:An objects of class SIR ArgVars represents a list head. The list contains objects of type SIR ArgVar.4.4.3 Notes:� The list of argument variables is sorted in alphabetical order and can be traversed with the standardlist operations.� The method Find searches for an argument variable in this list by Name. NULL (but no error) is returnedif no argument variable is found.17

  • 18

  • 4.5 Class SIR BehaviorThe class SIR Behavior is part of SIR level 2 and is declared in �le IntRep/Behavior.h.4.5.1 Declaration:1 class SIR Behavior : /� behavior c l a s s in hierarchy tree �/2 public SIR ListElem, /� i s a l i s t element �/3 public SIR Class /� and a c l a s s �/4 f5 public :6 SIR BHVR CLASS BehaviorClass ; /� behavior c l a s s i f i c a t i o n ( see above ) �/7 s i r f u n c t i o n �MainMethod ; /� l i nk to main method ( or NULL) �/8 s i r s ta t ement �FirstBhvrCal l ; /� l i nk to f i r s t subbehavior c a l l ( or NULL) �/9 s i r s ta t ement �BehaviorCal l s ; /� l i nk to cmpnd. stmnt . with behavior c a l l s �/10 /� ( i f SEQ or PAR or PIPE, e l s e NULL) �/11 s i r t r a n s i t i o n s �Trans i t i ons ; /� l i nk to t r an s i t i on s ( i f FSM, e l s e NULL) �/12 s i r e x c e p t i o n s �Exceptions ; /� l i nk to excep t i ons ( i f TRY, e l s e NULL) �/131415 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//161718 /� ( i n t e rna l ) �/192021 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//222324 static s i r b ehav i o r � Create ( /� create a new behavior �/25 const char �Name, /� ( re turns NULL i f SIR Error ) �/26 s i r d e s i g n �Design ,27 BOOL Inte rna l = FALSE) ; /� de f au l t : wi thout body �/2829 s i r b ehav i o r �Copy( /� create an exact copy with new name �/30 const char �Name, /� ( re turns NULL i f SIR Error ) �/31 BOOL Str ip = TRUE) ;3233 ERROR Rename( /� rename t h i s behavior �/34 const char �Name) ;3536 ERROR Delete (void ) ; /� de l e t e t h i s behavior �/373839 s i r b ehav i o r s � GetList (void ) ; /� obta in a pointer to the behavior l i s t �/4041 SIR BHVR CLASS GetClass (void ) ; /� obta in t h i s behaviors c l a s s i f i c a t i o n �/4243 19

  • 44 BOOL FindInstance ( /� f ind an ins tance of t h i s behavior �/45 s i r b hv r i n s t ��BhvrInst = NULL, /� return ins tance found �/46 s i r b hv r i n s t � LastInstance = NULL) ; /� continue search here �/474849 ERROR CreateBody (void ) ; /� create a minimal behavior body �/50 /� ( so that i t becomes an in t e rna l behavior ) �/5152 ERROR DeleteBody (void ) ; /� de l e t e the behavior body �/53 /� ( so that i t becomes an ex t e rna l behavior ) �/5455 ERROR MakeMainMethod( /� generates a main method ( template ) �/56 SIR BHVR CLASS BehaviorClass , /� intended behavior c l a s s �/57 s i r b hv r i n s t �FirstBhvr = NULL) ; /� f i r s t subbehavior �/58 g ;4.5.2 Purpose:An object of class SIR Behavior represents a behavior declaration or de�nition.4.5.3 Notes:� The member BehaviorClass classi�es this behavior as one of the following: SIR BHVR EXTERN,SIR BHVR LEAF, SIR BHVR SEQ, SIR BHVR PAR, SIR BHVR PIPE, SIR BHVR FSM, SIR BHVR TRY, SIR BHVR OTHER.This value is automatically updated whenever changes are made to the behavior through the APIlayer 2.� The link MainMethod points to the mandatory main method of this behavior. It is NULL forSIR BHVR EXTERN.� The link FirstBhvrCall points to the �rst statement containing a function call to the main methodof a sub-behavior. It is NULL if such a statement does not exist.� The link BehaviorCalls points to the compound statement containing the list of function callstatements to the instantiated sub-behaviors. This link is valid for SIR BHVR SEQ, SIR BHVR PAR, orSIR BHVR PIPE. For all other cases, it is NULL.� The link Transitions points to the list of state transitions for SIR BHVR FSM. For all other cases, it isNULL.� The link Exceptions points to the list of exception handlers for SIR BHVR TRY. For all other cases, it isNULL. 20

  • � The method Create creates a new behavior with name Name for the Design. The behavior will be ade�nition if Internal is TRUE, otherwise a declaration.� The method Copy creates a copy of this behavior named Name. Source line information is strippedfrom the copy if Strip is TRUE.� The method Rename changes the name of this behavior to Name.� The method Delete deletes this behavior if it is not used.� The method GetList obtains a pointer to the list head of this behavior.� The method GetClass looks up the classi�cation of this behavior (stored in BehaviorClass).� The method FindInstance searches for an instance of this behavior. The method returns whetherany instance was found and, if requested, stores a pointer to the instance in BhvrInst.If LastInstance is speci�ed (not NULL), the search for instances starts after the last one found.� The method CreateBody generates a minimal body for this behavior. An already existing body willbe replaced. The behavior will be an internal behavior (a de�nition) after this method is applied.� The method DeleteBody removes the body from this behavior. If none exists, nothing changes. Thebehavior will be an external behavior (a declaration) after this method is applied.� The method MakeMainMethod generates a function body for this behaviors main method. Any exist-ing body will be replaced. BehaviorClass speci�es the intended behavior classi�cation. FirstBhvroptionally speci�es the �rst sub-behavior to call.� Please refer to Section 7.3 for a detailed program example.

    21

  • 22

  • 4.6 Class SIR BehaviorsThe class SIR Behaviors is part of SIR level 2 and is declared in �le IntRep/Behavior.h.4.6.1 Declaration:1 class SIR Behaviors : /� behavior c l a s s e s l i s t �/2 public SIR List /� i s s imply a l i s t of behaviors �/3 f /� with add i t i ona l methods �/4 public :56 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//789 /� ( i n t e rna l ) �/101112 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//131415 s i r b ehav i o r � Find ( /� f ind a behavior with t h i s name �/16 const char �Name) ; /� ( re turns NULL i f not found ) �/17 g ;4.6.2 Purpose:An object of class SIR Behaviors represents a list head. The list contains objects of type SIR Behavior.4.6.3 Notes:� The list of behaviors is sorted in alphabetical order and can be traversed with the standard listoperations.� The method Find searches for a behavior in this list by Name. NULL (but no error) is returned if nobehavior is found.23

  • 24

  • 4.7 Class SIR BhvrInstThe class SIR BhvrInst is part of SIR level 2 and is declared in �le IntRep/BhvrInst.h.4.7.1 Declaration:1 class SIR BhvrInst : /� behavior ins tance in the hierarchy tree �/2 public SIR ListElem, /� i s a l i s t element �/3 public SIR Instance /� and an ins tance �/4 f5 public :6 s i r b ehav i o r �Behavior ; /� l i nk to i t s behavior c l a s s �/789 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//101112 /� ( i n t e rna l ) �/131415 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//161718 static s i r b hv r i n s t � Create ( /� create a new behavior i n s t a n t i a t i o n �/19 const char �Name, /� ( re turns NULL i f SIR Error ) �/20 s i r b ehav i o r �BhvrType ,21 s i r c l a s s �Parent ,22 s i r portmaps �NewPortMapList = NULL) ; /� de f au l t : no ports �/2324 s i r b hv r i n s t �Copy( /� create an exact copy with new name �/25 const char �Name, /� ( re turns NULL i f SIR Error ) �/26 BOOL Str ip = TRUE) ;2728 ERROR Rename( /� rename t h i s behavior ins tance �/29 const char �Name) ;3031 ERROR Delete (void ) ; /� de l e t e t h i s behavior ins tance �/323334 BOOL IsBehaviorMember ( /� i s a member of a behavior �/35 s i r b ehav i o r ��BhvrReturn = NULL) ; /� return the behavior �/3637 BOOL IsChannelMember ( /� i s a member of a channel �/38 s i r channe l ��ChnlReturn = NULL) ; /� return the channel �/394041 s i r b hv r i n s t s � GetList (void ) ; /� obta in a pointer to the ins tance l i s t �/4243 25

  • 44 BOOL FindDependant ( /� f ind o b j e c t s depending on t h i s ins tance �/45 SIR DEPENDENCY �Reason = NULL, /� return type of dependency �/46 s i r f u n c t i o n ��DepFct = NULL, /� return funct ion found �/47 s i r s ta t ement ��DepStmnt = NULL, /� return statement found �/48 s i r e x p r e s s i o n ��DepExpr = NULL, /� return expre s s ion found �/49 s i r f u n c t i o n �LastFound = NULL) ; /� continue search here �/505152 ERROR ChangeType ( /� change the type of t h i s behavior ins tance �/53 s i r b ehav i o r �BehaviorType ) ; /� replacement type �/54 g ;4.7.2 Purpose:An object of class SIR BhvrInst represents an instantiation of a behavior in another behavior or channel.4.7.3 Notes:� The link Behavior points to the behavior class of this instance. It should be followed for a traversalof the instantiation tree.� The method Create creates a new behavior instance of type BhvrType with name Name in behavioror channel Parent. If the BhvrType has ports, a suitable port mapping list NewPortMapList must besupplied which will be consumed by this method.� The method Copy creates a copy of this behavior instance named Name. Source line information isstripped from the copy if Strip is TRUE.� The method Rename changes the name of this behavior instance to Name.� The method Delete deletes this behavior instance if it is not used.� The method IsBehaviorMember determines whether this instance belongs to a behavior and, if re-quested, stores a pointer to the behavior in BhvrReturn.� The method IsChannelMember determines whether this instance belongs to a channel and, if requested,stores a pointer to the channel in ChnlReturn.� The method GetList obtains a pointer to the list head of this behavior instance.� The method FindDependant searches for objects that depend on this behavior instance. The methodreturns whether any object was found and, if requested, stores the reason for the dependency in Reason.26

  • Reason is either SIR DEP EXPRESSION or SIR DEP STATEMENT. For SIR DEP EXPRESSION, the depen-dent function is stored in DepFct, the statement in DepStmnt and the expression in DepExpr. ForSIR DEP STATEMENT, the dependent function is stored in DepFct and the statement in DepStmnt.If LastFound is speci�ed (not NULL), the search for dependants starts after the last found DepFct.� The method ChangeType changes the type of the behavior instance to BehaviorType. In other words,the behavior of this instance is replaced with a new one. Obviously, this method only succeeds forcompatible behaviors.

    27

  • 28

  • 4.8 Class SIR BhvrInstsThe class SIR BhvrInsts is part of SIR level 2 and is declared in �le IntRep/BhvrInst.h.4.8.1 Declaration:1 class SIR BhvrInsts : /� behavior ins tances l i s t �/2 public SIR List /� i s s imply a l i s t of BhvrInsts �/3 f /� with add i t i ona l methods �/4 public :56 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//789 /� ( i n t e rna l ) �/101112 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//131415 s i r b hv r i n s t � Find ( /� f ind an ins tance with t h i s name �/16 const char �Name) ; /� ( re turns NULL i f not found ) �/17 g ;4.8.2 Purpose:An object of class SIR BhvrInsts represents a list head. The list contains objects of type SIR BhvrInst.4.8.3 Notes:� The list of behavior instances is sorted in alphabetical order and can be traversed with the standardlist operations.� The method Find searches for a behavior instance in this list by Name. NULL (but no error) is returnedif no behavior instance is found.29

  • 30

  • 4.9 Class SIR BitSliceThe class SIR BitSlice is part of SIR level 1 and is declared in �le IntRep/PortMap.h.4.9.1 Declaration:1 class SIR Bi tS l i c e : /� b i t s l i c e in port mapping �/2 public SIR ListElem /� i s a l i s t element �/3 f4 public :5 s i r symbo l �Symbol ; /� l i nk to symbol t a b l e entry �/6 int LeftBound , /� bounds of s l i c e ( i f BITVECTOR, e l s e 0 ) �/7 RightBound ;8910 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//111213 /� ( i n t e rna l ) �/141516 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//171819 static s i r b i t s l i c e �New( /� create a new b i t s l i c e (#1 ) �/20 s i r d e f i n i t i o n �Mapping , /� ( re turns NULL i f SIR Error ) �/21 int LeftBound = 0 , /� bounds for b i t v e c t o r s �/22 int RightBound = 0 ) ;2324 s i r b i t s l i c e �Copy(void ) ; /� create a copy of t h i s b i t s l i c e �/2526 void Delete (void ) ; /� de l e t e t h i s b i t s l i c e �/27 g ;4.9.2 Purpose:An object of class SIR BitSlice represents either a direct mapping of an instance port onto a variable,channel or port, or, a partial mapping of an instance port onto a slice of a bit vector variable or port.4.9.3 Notes:� The link Symbol points to the symbol onto which this slice is mapped.� The members LeftBound and RightBound determine the left and right bounds of this slice. For amapped symbol of non-bitvector type, LeftBound and RightBound are invalid and should be set to 0.31

  • � The method New creates a new bitslice object for use as argument to consuming methods. Mappingspeci�es the target variable, channel or port. For sliced mappings, LeftBound and RightBound specifythe left and right bounds of the slice.� The method Copy creates a copy of this bitslice for use as argument to consuming methods.� The method Delete deletes this bitslice. This method must not be used if the bitslice is alreadyinserted in the SIR data structure (that is, if it was used as argument to a consuming method).

    32

  • 4.10 Class SIR BitSlicesThe class SIR BitSlices is part of SIR level 1 and is declared in �le IntRep/PortMap.h.4.10.1 Declaration:1 class SIR Bi tS l i c e s : /� l i s t of ( concatenated ) b i t s l i c e s �/2 public SIR List /� i s s imply a l i s t of b i t s l i c e s �/3 f /� with add i t i ona l methods �/4 public :56 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//789 /� ( i n t e rna l ) �/101112 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//131415 static s i r b i t s l i c e s �New( /� create a new l i s t of b i t s l i c e s �/16 s i r b i t s l i c e �NewFirstEntry = NULL) ; /� ( re turns NULL i f SIR Error )�/1718 s i r b i t s l i c e s �Copy(void ) ; /� create a copy of the b i t s l i c e l i s t �/1920 void Delete (void ) ; /� de l e t e the b i t s l i c e l i s t �/21 g ;4.10.2 Purpose:An object of class SIR BitSlices represents a list head. The list contains objects of type SIR BitSlice.4.10.3 Notes:� The list of bitslices is sorted by concatenation order and can be traversed with the standard listoperations.� The method New creates a new list of concatenated bitslices for use as argument to consuming methods.Optionally, NewFirstEntry speci�es the �rst list element which will be consumed by this method.� The method Copy creates a copy of this list of bitslices for use as argument to consuming methods.� The method Delete deletes this list and its elements. This method must not be used if the list isalready inserted in the SIR data structure (that is, if it was used as argument to a consuming method).33

  • 34

  • 4.11 Class SIR ChannelThe class SIR Channel is part of SIR level 2 and is declared in �le IntRep/Channel.h.4.11.1 Declaration:1 class SIR Channel : /� channel c l a s s in hierarchy tree �/2 public SIR ListElem, /� i s a l i s t element �/3 public SIR Class /� and a c l a s s �/4 f5 public :6 SIR CHNL CLASS ChannelClass ; /� channel c l a s s i f i c a t i o n ( see above ) �/789 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//101112 /� ( i n t e rna l ) �/131415 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//161718 static s i r channe l � Create ( /� create a new channel �/19 const char �Name, /� ( re turns NULL i f SIR Error ) �/20 s i r d e s i g n �Design ,21 BOOL Inte rna l = FALSE) ; /� de f au l t : wi thout body �/2223 s i r channe l �Copy( /� create an exact copy with new name �/24 const char �Name, /� ( re turns NULL i f SIR Error ) �/25 BOOL Str ip = TRUE) ;2627 ERROR Rename( /� rename t h i s channel �/28 const char �Name) ;2930 ERROR Delete (void ) ; /� de l e t e t h i s channel �/313233 s i r channe l s � GetList (void ) ; /� obta in a pointer to the channel l i s t �/3435 SIR CHNL CLASS GetClass (void ) ; /� obta in t h i s channels c l a s s i f i c a t i o n �/363738 BOOL FindInstance ( /� f ind an ins tance of t h i s channel �/39 s i r c h n l i n s t ��ChnlInst = NULL, /� return ins tance found �/40 s i r c h n l i n s t � LastInstance = NULL) ; /� continue search here �/414243 ERROR CreateBody (void ) ; /� create a minimal channel body �/35

  • 44 /� ( so that i t becomes an in t e rna l channel ) �/4546 ERROR DeleteBody (void ) ; /� de l e t e the channel body �/47 /� ( so that i t becomes an ex t e rna l channel ) �/48 g ;4.11.2 Purpose:An object of class SIR Channel represents a channel declaration or de�nition.4.11.3 Notes:� The member ChannelClass classi�es this channel as one of the following: SIR CHNL EXTERN,SIR CHNL LEAF, SIR CHNL COMPOUND, SIR CHNL WRAPPER, SIR CHNL OTHER. This value is automatically up-dated whenever changes are made to the channel through the API layer 2.� The method Create creates a new channel with name Name for the Design. The channel will be ade�nition if Internal is TRUE, otherwise a declaration.� The method Copy creates a copy of this channel named Name. Source line information is stripped fromthe copy if Strip is TRUE.� The method Rename changes the name of this channel to Name.� The method Delete deletes this channel if it is not used.� The method GetList obtains a pointer to the list head of this channel.� The method GetClass looks up the classi�cation of this channel (stored in ChannelClass).� The method FindInstance searches for an instance of this channel. The method returns whether anyinstance was found and, if requested, stores a pointer to the instance in ChnlInst.If LastInstance is speci�ed (not NULL), the search for instances starts after the last one found.� The method CreateBody generates a minimal body for this channel. An already existing body will bereplaced. The channel will be an internal channel (a de�nition) after this method is applied.� The method DeleteBody removes the body from this channel. If none exists, nothing changes. Thechannel will be an external channel (a declaration) after this method is applied.36

  • 4.12 Class SIR ChannelsThe class SIR Channels is part of SIR level 2 and is declared in �le IntRep/Channel.h.4.12.1 Declaration:1 class SIR Channels : /� channel c l a s s e s l i s t �/2 public SIR List /� i s s imply a l i s t of channels �/3 f /� with add i t i ona l methods �/4 public :56 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//789 /� ( i n t e rna l ) �/101112 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//131415 s i r channe l � Find ( /� f ind a channel with t h i s name �/16 const char �Name) ; /� ( re turns NULL i f not found ) �/17 g ;4.12.2 Purpose:An object of class SIR Channels represents a list head. The list contains objects of type SIR Channel.4.12.3 Notes:� The list of channels is sorted in alphabetical order and can be traversed with the standard list opera-tions.� The method Find searches for a channel in this list by Name. NULL (but no error) is returned if nochannel is found.37

  • 38

  • 4.13 Class SIR ChnlInstThe class SIR ChnlInst is part of SIR level 2 and is declared in �le IntRep/ChnlInst.h.4.13.1 Declaration:1 class SIR ChnlInst : /� channel ins tance in the hierarchy tree �/2 public SIR ListElem, /� i s a l i s t element �/3 public SIR Instance /� and an ins tance �/4 f5 public :6 s i r channe l �Channel ; /� l i nk to i t s channel c l a s s �/789 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//101112 /� ( i n t e rna l ) �/131415 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//161718 static s i r c h n l i n s t � Create ( /� create a new channel i n s t a n t i a t i o n �/19 const char �Name, /� ( re turns NULL i f SIR Error ) �/20 s i r channe l �ChnlType ,21 s i r c l a s s �Parent ,22 s i r portmaps �NewPortMapList = NULL) ; /� de f au l t : no ports �/2324 s i r c h n l i n s t �Copy( /� create an exact copy with new name �/25 const char �Name, /� ( re turns NULL i f SIR Error ) �/26 BOOL Str ip = TRUE) ;2728 ERROR Rename( /� rename t h i s channel ins tance �/29 const char �Name) ;3031 ERROR Delete (void ) ; /� de l e t e t h i s channel ins tance �/323334 BOOL IsBehaviorMember ( /� i s a member of a behavior �/35 s i r b ehav i o r ��BhvrReturn = NULL) ; /� return the behavior �/3637 BOOL IsChannelMember ( /� i s a member of a channel �/38 s i r channe l ��ChnlReturn = NULL) ; /� return the channel �/394041 s i r c h n l i n s t s � GetList (void ) ; /� obta in a pointer to the ins tance l i s t �/4243 39

  • 44 BOOL FindDependant ( /� f ind o b j e c t s depending on t h i s ins tance �/45 SIR DEPENDENCY �Reason = NULL, /� return type of dependency �/46 s i r f u n c t i o n ��DepFct = NULL, /� return funct ion found �/47 s i r s ta t ement ��DepStmnt = NULL, /� return statement found �/48 s i r e x p r e s s i o n ��DepExpr = NULL, /� return expre s s ion found �/49 s i r b hv r i n s t ��ConnBhvr = NULL, /� return beh . in s t . found �/50 s i r c h n l i n s t ��ConnChnl = NULL, /� return chan . in s t . found �/51 s i r d e f i n i t i o n �LastFound = NULL) ; /� continue search here �/525354 ERROR ChangeType ( /� change the type of t h i s channel ins tance �/55 s i r channe l �ChannelType ) ; /� replacement type �/56 g ;4.13.2 Purpose:An object of class SIR ChnlInst represents an instantiation of a channel in another channel or behavior.4.13.3 Notes:� The link Channel points to the channel class of this instance. It should be followed for a traversal ofthe instantiation tree.� The method Create creates a new channel instance of type ChnlType with name Name in behavior orchannel Parent. If the ChnlType has ports, a suitable port mapping list NewPortMapList must besupplied which will be consumed by this method.� The method Copy creates a copy of this channel instance named Name. Source line information isstripped from the copy if Strip is TRUE.� The method Rename changes the name of this channel instance to Name.� The method Delete deletes this channel instance if it is not used.� The method IsBehaviorMember determines whether this instance belongs to a behavior and, if re-quested, stores a pointer to the behavior in BhvrReturn.� The method IsChannelMember determines whether this instance belongs to a channel and, if requested,stores a pointer to the channel in ChnlReturn.� The method GetList obtains a pointer to the list head of this channel instance.40

  • � The method FindDependant searches for objects that depend on this channel instance. The methodreturns whether any object was found and, if requested, stores the reason for the dependency in Reason.Reason is one of the following: SIR DEP EXPRESSION, SIR DEP STATEMENT or SIR DEP CONNECTION. ForSIR DEP EXPRESSION, the dependent function is stored in DepFct, the statement in DepStmnt and theexpression in DepExpr. For SIR DEP STATEMENT, the dependent function is stored in DepFct and thestatement in DepStmnt. For SIR DEP CONNECTION, the dependent instance is stored either in ConnBhvror ConnChnl.If LastFound is speci�ed (not NULL), the search for dependants starts after the last found DepFct,DepBhvr or DepChnl.� The method ChangeType changes the type of the channel instance to ChannelType. In other words,the channel of this instance is replaced with a new one. Obviously, this method only succeeds forcompatible channels.

    41

  • 42

  • 4.14 Class SIR ChnlInstsThe class SIR ChnlInsts is part of SIR level 2 and is declared in �le IntRep/ChnlInst.h.4.14.1 Declaration:1 class SIR ChnlInsts : /� channel in s tances l i s t �/2 public SIR List /� i s s imply a l i s t of ChnlIns ts �/3 f /� with add i t i ona l methods �/4 public :56 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//789 /� ( i n t e rna l ) �/101112 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//131415 s i r c h n l i n s t � Find ( /� f ind an ins tance with t h i s name �/16 const char �Name) ; /� ( re turns NULL i f not found ) �/17 g ;4.14.2 Purpose:An object of class SIR ChnlInsts represents a list head. The list contains objects of type SIR ChnlInst.4.14.3 Notes:� The list of channel instances is sorted in alphabetical order and can be traversed with the standardlist operations.� The method Find searches for a channel instance in this list by Name. NULL (but no error) is returnedif no channel instance is found.43

  • 44

  • 4.15 Class SIR ClassThe class SIR Class is a base class of SIR level 2 and is declared in �le IntRep/Class.h.4.15.1 Declaration:1 class SIR Class : /� base c l a s s for c l a s s e s in hierarchy tree �/2 public SIR De f in i t i on /� inc ludes d e f i n i t i o n base c l a s s �/3 f4 public :5 s i r p o r t s �Ports ; /� l i s t of por ts �/6 s i r imp l i f s � Imp l Inte r f ace s ; /� l i s t of implemented i n t e r f a c e s �/7 s i r p o r t v a r s �PortVar iab les ; /� l i s t of port v a r i a b l e s ( or NULL) �/8 s i r v a r i a b l e s �Var iab les ; /� l i s t of c l a s s�l o c a l v a r i a b l e s ( or NULL) �/9 s i r b hv r i n s t s �BhvrInsts ; /� l i s t of i n s t an t i a t e d behaviors ( or NULL) �/10 s i r c h n l i n s t s �ChnlInsts ; /� l i s t of i n s t an t i a t e d channels ( or NULL) �/11 s i r f u n c t i o n s �Methods ; /� l i s t of l o c a l methods ( or NULL) �/121314 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//151617 /� ( i n t e rna l ) �/181920 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//212223 BOOL I s In t e rna l (void ) ; /� i s an in t e rna l c l a s s ( body is known ) �/2425 BOOL IsExterna l (void ) ; /� i s an ex t e rna l c l a s s ( body is unknown ) �/2627 BOOL Implements ( /� checks i f t h i s implements the i n t e r f a c e �/28 s i r i n t e r f a c e � I n t e r f a c e ) ; /� ( checks the l i s t of impl . i f s . ) �/2930 BOOL IsCompatibleWith ( /� check for c ompa t i b i l i t y of c l a s s e s �/31 s i r c l a s s �Class2 ) ;323334 ERROR ForEachDef in i t ion ( /� i t e r a t e over a l l d e f i n i t i o n s in the c l a s s �/35 s i r d e f f c t Cal l e rFunct ion , /� ( abor ts i f return va lue != 0 ) �/36 void �CallerArgument ,37 BOOL MembersAndMethodsOnly = FALSE) ;3839 ERROR ForEachInstance ( /� i t e r a t e over a l l in s tances in t h i s c l a s s �/40 s i r i n s t f c t Cal l e rFunct ion , /� ( abor ts i f return va lue != 0 ) �/41 void �CallerArgument ) ;4243 ERROR ForEachBehaviorInst ( /� i t e r a t e over a l l l o c a l behavior ins tances �/45

  • 44 s i r b i n s t f c t Cal l e rFunct ion , /� ( abor ts i f return va lue != 0 ) �/45 void �CallerArgument ) ;4647 ERROR ForEachChannelInst ( /� i t e r a t e over a l l l o c a l channel in s tances �/48 s i r c i n s t f c t Cal l e rFunct ion , /� ( abor ts i f return va lue != 0 ) �/49 void �CallerArgument ) ;5051 ERROR ForEachFunction ( /� i t e r a t e over a l l methods in t h i s c l a s s �/52 s i r f c t f c t Cal l e rFunct ion , /� ( abor ts i f return va lue != 0 ) �/53 void �CallerArgument ) ;5455 ERROR ForEachVariable ( /� i t e r a t e over a l l v a r i a b l e s in t h i s c l a s s �/56 s i r v a r f c t Cal l e rFunct ion , /� ( abor ts i f return va lue != 0 ) �/57 void �CallerArgument ,58 BOOL MembersOnly = FALSE) ;5960 ERROR ForEachPort ( /� i t e r a t e over a l l por ts of t h i s c l a s s �/61 s i r p o r t f c t Cal l e rFunct ion , /� ( abor ts i f return va lue != 0 ) �/62 void �CallerArgument ) ;6364 ERROR ForEachPortVariable ( /� i t e r a t e over a l l port vars . of t h i s c l a s s �/65 s i r p o r t v f c t Cal l e rFunct ion , /� ( abor ts i f return va lue != 0 ) �/66 void �CallerArgument ) ;6768 ERROR ForEachImplInterface ( /� i t e r a t e over a l l implemented i n t e r f a c e s �/69 s i r i i f f c t Cal l e rFunct ion , /� ( abor ts i f return va lue != 0 ) �/70 void �CallerArgument ) ;71 g ;4.15.2 Purpose:The base class SIR Class contains common members and methods for behaviors (class SIR Behavior) andchannels (class SIR Channel).4.15.3 Notes:� The member Ports contains the list of ports.� The member ImplInterfaces contains the list of implemented interfaces.� The member PortVariables contains the list of port variables. It is NULL for external classes.� The member Variables contains the list of local variables. It is NULL for external classes.� The member BhvrInsts contains the list of instantiated sub-behaviors. It is NULL for external classes.� The member ChnlInsts contains the list of instantiated sub-channels. It is NULL for external classes.46

  • � The member Methods contains the list of local methods. It is NULL for external classes.� The method IsInternal determines whether this class is internal (is a de�nition with a class body).� The method IsExternal determines whether this class is external (is a declaration without a classbody).� The method IsCompatibleWith determines whether this class is compatible with Class2. For com-patibility, both classes must be of the same class, must have compatible ports, and must implementthe same interfaces.� The method ForEachDefinition traverses over all de�nitions contained in this class and callsCallerFunction(Current, CallerArgument) for each object of type SIR Definition. The traversalis aborted if CallerFunction returns an error.Optionally, MembersAndMethodsOnly limits the traversal to only members and methods of this class(the top level).� The method ForEachInstance traverses over all instances contained in this class and callsCallerFunction(Current, CallerArgument) for each object of type SIR Instance. The traversalis aborted if CallerFunction returns an error.� The method ForEachBehaviorInst traverses over all sub-behaviors contained in this class and callsCallerFunction(Current, CallerArgument) for each object of type SIR BhvrInst. The traversal isaborted if CallerFunction returns an error.� The method ForEachChannelInst traverses over all sub-channels contained in this class and callsCallerFunction(Current, CallerArgument) for each object of type SIR ChnlInst. The traversal isaborted if CallerFunction returns an error.� The method ForEachFunction traverses over all methods contained in this class and callsCallerFunction(Current, CallerArgument) for each object of type SIR Function. The traversalis aborted if CallerFunction returns an error.� The method ForEachVariable traverses over all variables contained in this class and callsCallerFunction(Current, CallerArgument) for each object of type SIR Variable. The traversalis aborted if CallerFunction returns an error.Optionally, MembersOnly limits the traversal to class variables only (the top level).47

  • � The method ForEachPort traverses over all ports of this class and calls CallerFunction(Current,CallerArgument) for each object of type SIR Port. The traversal is aborted if CallerFunctionreturns an error.� The method ForEachPortVariable traverses over all port variables of this class and callsCallerFunction(Current, CallerArgument) for each object of type SIR PortVar. The traversal isaborted if CallerFunction returns an error.� The method ForEachImplInterface traverses over all implemented interfaces by this class and callsCallerFunction(Current, CallerArgument) for each object of type SIR ImplIf. The traversal isaborted if CallerFunction returns an error.

    48

  • 4.16 Class SIR ConstantThe class SIR Constant is part of SIR level 1 and is declared in �le IntRep/Constant.h.4.16.1 Declaration:1 class SIR Constant : /� constant repre sen ta t i on �/2 public SIR Unit , /� i s a uni t of the des ign �/3 public SIR Node /� and a node �/4 f5 public :6 SIR CONSTTYPE Type ; /� type of the constant �/7 union8 f9 bool B Value ; /� boolean constants �/10 char C Value ; /� character constants �/11 unsigned char UC Value ;12 short int S Value ; /� in t ege r constants �/13 unsigned short int US Value ;14 int I Value ;15 unsigned int UI Value ;16 long int L Value ;17 unsigned long int UL Value ;18 long long int LL Value ;19 unsigned long long int ULL Value ;20 f loat F Value ; /� f l o a t i n g constants �/21 double D Value ;22 long double LD Value ;23 s i r b i t �BIT Value ; /� b i t vec tor constant �/24 s t r ing �CS Value ; /� character s t r i n g constant �/2526 long long int T Value ; /� type ' time ' i s ' long long int ' �/27 g ;282930 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//313233 /� ( i n t e rna l ) �/343536 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//373839 static s i r c on s t an t �New( /� create a new in tege r constant (#1 ) �/40 long long int Value , /� ( re turns NULL i f SIR Error ) �/41 SIR CONSTTYPE CType = SIR CONST INT) ; /� de f au l t : in t ege r �/4243 static s i r c on s t an t �New( /� create a new unsigned constant (#2 ) �/49

  • 44 unsigned long long Value , /� ( re turns NULL i f SIR Error ) �/45 SIR CONSTTYPE CType = SIR CONST UINT) ; /� de f au l t : unsigned in t ege r �/4647 static s i r c on s t an t �New( /� create a new f l o a t i n g point constant (#3 ) �/48 long double Value , /� ( re turns NULL i f SIR Error ) �/49 SIR CONSTTYPE CType = SIR CONST DOUBLE) ; /� de f au l t : double �/5051 static s i r c on s t an t �New( /� create a new b i t v e c t o r constant (#4 ) �/52 s i r b i t Value , /� ( re turns NULL i f SIR Error ) �/53 SIR CONSTTYPE CType = SIR CONST BIT) ; /� de f au l t : b i t �/5455 static s i r c on s t an t �New( /� create a new s t r i n g or b i t v e c t o r constant �/56 const char �Value , /� ( re turns NULL i f SIR Error ) (# 5 ) �/57 SIR CONSTTYPE CType = SIR CONST CHARSTRING) ; /� de f au l t : s t r i n g �/58 /� ( a l so supports SIR CONST BIT or SIR CONST UBIT) �/5960 s i r c on s t an t �Copy( /� crea t e s a copy of the constant �/61 BOOL Str ip = TRUE) ; /� ( re turns NULL i f SIR Error ) �/6263 void Delete (void ) ; /� de l e t e s the constant �/646566 static s i r c on s t an t � Parse ( /� create a constant from a tex t s t r i n g �/67 const char �Text ) ; /� ( re turns NULL i f PRS Error ) �/68 /� ( r equ i r e s l i bParse r . a ! ) �/6970 const char � Print ( /� return t ex t s t r i n g of the constants va lue �/71 BOOL CppNotation = FALSE) ; /� de f au l t : SpecC notat ion �/727374 BOOL I s In t e g e r (void ) ; /� check whether t h i s i s any in t ege r �/7576 BOOL IsUnsigned (void ) ; /� check whether t h i s i s any unsigned in t ege r �/7778 BOOL IsF loa t ing (void ) ; /� check whether t h i s i s any f l o a t i n g point �/7980 BOOL IsB i tvec to r (void ) ; /� check whether t h i s i s a b i t v e c t o r �/8182 BOOL I sS t r i n g (void ) ; /� check whether t h i s i s a t ex t s t r i n g �/838485 SIR CONSTTYPE GetConstType ( /� obta in the exact type of a constant �/86 void ) ;8788 ERROR GetValue ( /� obta in an in t ege r va lue (#1 ) �/89 long long int �ValuePtr ) ;9091 ERROR GetValue ( /� obta in an unsigned in t ege r va lue (#2 ) �/92 unsigned long long � ValuePtr ) ;9394 ERROR GetValue ( /� obta in a f l o a t i n g point va lue (#3 ) �/50

  • 95 long double �ValuePtr ) ;9697 ERROR GetValue ( /� obta in a b i t v e c t o r va lue (#4 ) �/98 s i r b i t �ValuePtr ) ;99100 ERROR GetValue ( /� obta in a t ex t s t r i n g ( or b i t v . ) va lue (#5 ) �/101 const char ��ValuePtr ) ;102103 const char � GetSourceFi le ( /� obta in source l oca t i on (NULL i f unknown ) �/104 unsigned int �LineNumber ) ; /� return l ine number ( or 0 ) �/105106107 ERROR SetValue ( /� se t the in t ege r va lue (#1 ) �/108 long long int Value ) ;109110 ERROR SetValue ( /� se t the unsigned va lue (#2 ) �/111 unsigned long long int Value ) ;112113 ERROR SetValue ( /� se t the f l o a t i n g point va lue (#3 ) �/114 long double Value ) ;115116 ERROR SetValue ( /� se t the b i t v e c t o r va lue (#4 ) �/117 s i r b i t Value ) ;118119 ERROR SetValue ( /� se t the t ex t ( or b i t v . ) s t r i n g va lue (#5 ) �/120 const char �Value ) ;121122 ERROR SetSourceF i l e ( /� se t source l oca t i on of t h i s constant �/123 const char �FileName = NULL, /� de f au l t : unknown �/124 unsigned int LineNumber = 0 ,125 s i r f i l e l i s t � F i l eL i s t = NULL) ; /� needed to i n s e r t FileName �/126127 ERROR Convert ( /� conver t t h i s constant to another type �/128 SIR CONSTTYPE CType ) ;129 g ;4.16.2 Purpose:An object of class SIR Constant represents a SpecC constant.4.16.3 Notes:� The member Type represents the type of this constant and is one of the following values:SIR CONST BOOL, SIR CONST CHAR, SIR CONST UCHAR, SIR CONST SHORT, SIR CONST USHORT, SIR CONST INT,SIR CONST UINT, SIR CONST LONG, SIR CONST ULONG, SIR CONST LONGLONG, SIR CONST ULONGLONG,SIR CONST FLOAT, SIR CONST DOUBLE, SIR CONST LONGDOUBLE, SIR CONST BIT, SIR CONST UBIT,SIR CONST CHARSTRING, SIR CONST TIME. 51

  • � Depending on Type, exactly one of the union members XX Value is valid and contains the value of thisconstant.� The methods New create a new constant object for use as argument to consuming methods. Pleaserefer to the comments in the class declaration to determine which of the overloaded methods to usefor which constant type.� The method Copy creates a copy of this constant for use as argument to consuming methods.� The method Delete deletes this constant. This method must not be used if the constant is alreadyinserted in the SIR data structure (that is, if it was used as argument to a consuming method).� The method Parse creates a new constant for use as argument to consuming methods from a textrepresentation in SpecC syntax. This method requires linking with libParser.a.� The method Print generates a text representation of this constant in SpecC syntax. Optionally,CppNotation allows to generate C++ syntax instead.� The method IsInteger checks whether this constant is of any signed integer type. Signed in-teger constants are SIR CONST BOOL, SIR CONST CHAR, SIR CONST SHORT, SIR CONST INT, SIR CONST LONG,SIR CONST LONGLONG, SIR CONST TIME.� The method IsUnsigned checks whether this constant is of any unsigned integer type. Un-signed integer constants are SIR CONST UCHAR, SIR CONST USHORT, SIR CONST UINT, SIR CONST ULONG,SIR CONST ULONGLONG.� The method IsFloating checks whether this constant is of any oating point type. Floating pointconstants are SIR CONST FLOAT, SIR CONST DOUBLE, SIR CONST LONGDOUBLE.� The method IsBitvector checks whether this constant is of any bitvector type. Bitvector constantsare SIR CONST BIT, SIR CONST UBIT.� The method IsString checks whether this constant is of string type. A string constant isSIR CONST CHARSTRING.� The method GetConstType looks up the constant type (stored in member Type).� The methods GetValue obtain the value of this constant according to the type classes above.� The method GetSourceFile obtains the source code location of this constant. NULL is returned ifunknown. 52

  • � The methods SetValue modify the value of this constant. The type is not changed, so the value mustbe suitable for Type.� The method SetSourceFile changes the source code location of this constant. NULL speci�es unknownlocation.� The method Convert converts this constant (and its value) to the new type CType. Only legal conver-tions are supported.

    53

  • 54

  • 4.17 Class SIR ConstraintThe class SIR Constraint is part of SIR level 1 and is declared in �le IntRep/Constraint.h.4.17.1 Declaration:1 class SIR Constraint : /� cons t ra in t �/2 public SIR Node , /� i s a node �/3 public SIR ListElem /� and a l i s t element �/4 f5 public :6 s i r l a b e l �Label1 ; /� f i r s t l a b e l entry �/7 s i r l a b e l �Label2 ; /� second l a b e l entry �/8 s i r c on s t an t �MinTime ; /� minimum time (NULL i f unspec i f i ed ) �/9 s i r c on s t an t �MaxTime; /� maximum time (NULL i f unspec i f i ed ) �/101112 //++++++++++++++++++++++++++++API Layer 1+++++++++++++++++++++++++++++//131415 /� ( i n t e rna l ) �/161718 //++++++++++++++++++++++++++++API Layer 2+++++++++++++++++++++++++++++//192021 static s i r c o n s t r a i n t � Create ( /� create a new timing cons t ra in t (#1 ) �/22 s i r s ta t ement �TimingStmnt , /� and apply i t here �/23 s i r l a b e l �Label1 , /� ( re turns NULL i f SIR Error ) �/24 s i r l a b e l �Label2 ,25 s i r c on s t an t �NewMinTime , /� use NULL i f unspec i f i ed �/26 s i r c on s t an t �NewMaxTime) ; /� use NULL i f unspec i f i ed �/2728 static s i r c o n s t r a i n t � Create ( /� create a new timing cons t ra in t (#2 ) �/29 s i r s ta t ement �TimingStmnt , /� and apply i t here �/30 s i r l a b e l �Label1 , /� ( re turns NULL i f SIR Error ) �/31 s i r l a b e l �Label2 ,32 long long int MinTime , /� ( type ' time ' i s ' long long int ' ) �/33 long long int MaxTime) ;3435 ERROR Delete (void ) ; /� de l e t e t h i s cons t ra in t �/363738 s i r s ta t ement � GetStatement1 ( /� obta in the beg inning statement �/39 void ) ;4041 s i r s ta t ement � GetStatement2 ( /� obta in the ending statement �/42 void ) ;43 55

  • 44 ERROR GetMinTime ( /� obta in the minimum time �/45 long long int �MinTimePtr ) ; /� ( return minimum time va lue ) �/4647 ERROR GetMaxTime( /� obta in the maximum time �/48 long long int �MaxTimePtr ) ; /� ( return maximum time va lue ) �/4950 const char � GetSourceFi le ( /� obta in source l oca t i on (NULL i f unknown ) �/51 unsigned int �LineNumber ) ; /� return l ine number ( or 0 ) �/525354 ERROR SetMinTime( /� modify the minimum time (#1 ) �/55 s i r c on s t an t �NewMinTime ) ; /� use NULL i f unspec i f i ed �/5657 ERROR SetMinTime( /� modify the minimum time (#2 ) �/58 long long int MinTime ) ;5960 ERROR SetMaxTime ( /� modify the maximum time (#1 ) �/61 s i r c on s t an t �NewMaxTime) ; /� use NULL i f unspec i f i ed �/6263 ERROR SetMaxTime ( /� modify the maximum time (#2 ) �/64 long long int MaxTime) ;6566 ERROR SetSourceF i l e ( /� se t source l oca t i on of t h i s cons t ra in t �/67 const char �FileName = NULL, /� de f au l t : unknown �/68 unsigned int LineNumber = 0 ) ;6970 void Str ip (void ) ; /� remove source l oca t i on for the cons t ra in t �/71 g ;4.17.2 Purpose:An object of class SIR Constraint represents a timing constraint. More speci�cally, it is used in the SpecCdo - timing construct (a timing diagram) and represents a range statement.4.17.3 Notes:� The links Label1 and Label2 point to the labels of the range statement.� The members MinTime and MaxTime contain the minimum and maximum times of the range statement.Either of them can be NULL, in which case this represents �1 and +1,