<<

An Automated Flow for Integrating Hardware IP into the Automotive Systems Process

Jan-Hendrik Oetjens Ralph Görgen Joachim Gerlach Wolfgang Nebel Robert Bosch GmbH OFFIS Institute Robert Bosch GmbH Carl v. Ossietzky University AE/EIM3 R&D Division Transportation AE/EIM3 Embedded Hardware-/ Postfach 1342 Escherweg 2 Postfach 1342 Software-Systems 72703 Reutlingen 26121 Oldenburg 72703 Reutlingen 26111 Oldenburg Jan-Hendrik.Oetjens Ralph.Goergen Joachim.Gerlach nebel@informatik. @de.bosch.com @offis.de @de.bosch.com uni-oldenburg.de

Abstract during system integration is possible in an earlier stage of the systems engineering process. This contribution shows and discusses the require- Most of the companies’ system development processes ments and constraints that an industrial engineering follow – at least, in their basic principals – the well- process defines for the integration of hardware IP into known V model [1]. In our specific case, there is running the system development flow. It describes the developed an additional boundary through that V model. It partitions strategy for automating the step of making hardware de- the process steps into tasks to be done within our semi- scriptions available in a MATLAB/Simulink based system conductor division and tasks to be done within the corre- modeling and validation environment. It also explains the sponding system divisions (see Figure 1). The prior men- transformation technique on which that strategy is based. tioned acts as a supplier of the hardware parts of the over- An application of the strategy is shown in terms of an all system for the latter. Such boundaries also exist in industrial automotive electronic hardware IP block. many other companies whereas the exact boundary shape in the V model may differ. In our case, the system divi- sions are responsible for the engineering of the system 1. Introduction application, the definition of the coarse grain system ar- chitecture and the assembling of the system by integrating The domain of automotive electronics system is all components (mechanical parts, sensors, hardware IP, characterized by specific constraints and environmental software, etc.). An aspect that arises from that partitioning conditions that significantly differ from those in other is that both sides, systems engineering and semiconductor design domains like mobile communications, multimedia development, have different views on the system and its or high performance computing. This results from the fact constraints, different understandings and know how, and that automotive electronics systems are often involved in different , tools, and environments. This safety critical car functions that have to be highly reliable makes a seamless interaction of both sides an ambitious and robust over a long lifetime, and are used in harsh en- and highly important challenge. vironments in terms of vibrations, temperature changes, or electromagnetic interferences. These specific con- System System Design Test straints have to be considered during all steps of the System automotive electronics systems engineering process. This Engineering contribution describes a methodology developed at the Integration semiconductor division of Robert Bosch GmbH in coop- Design Test eration with OFFIS Institute for Information Technology, Design Semiconductor which provides a seamless and automated strategy for Development making intellectual property (IP) hardware models avail- Module Module able on higher levels of model abstraction. This allows Design Test Validation considering hardware IP accurately during the system modeling and exploration phase. Hence, the identification of incorrect system behavior or problems that may arise Implementation

Figure 1. V model for system engineering

978-3-9810801-5-5/DATE09 © 2009 EDAA In automotive electronics system design, the modeling ual coding step is time-consuming and error-prone. Addi- and validation of heterogeneous system behavior on a tionally, the effort to keep the hardware description and high of abstraction (at the systems engineering the Simulink model compliant (e.g., after several adapta- level) is often done using MATLAB/Simulink. For the tion or configuration steps on hardware side) is quite design of the integrated circuits (at the semiconductor high. Therefore, this step is often skipped in practical use development level), traditional register-transfer level due to the tape-out schedule, which is a handicap for an hardware description languages like VHDL and Verilog efficient reuse. play a major role. Regarding the “design” arc of the V model a typical strategy for crossing the boundary be- 3. Related work tween systems engineering and semiconductor develop- ment can be divided in two steps. Firstly, a natural lan- Because co-simulation and manual generation of C guage specification document is derived for the system code are often not applicable in practical use, an approach parts to be implemented in hardware from the Simulink for the automatic generation of C/C++ code from hard- model (to be done at the systems engineering level or in ware descriptions is necessary. Tools for generating C++ tight cooperation of both levels). Secondly, engineering code that can be embedded into a Simulink environment of the hardware component is started (at the semiconduc- already exist on the market. Known commercial ap- tor development level) based on this document. Vice proaches in this area are VTOC [2] and Model Studio [3]. versa – regarding the “validation” arc of the V model – VTOC is a model generator that allows generating C++ the hardware component can be considered at systems models from Verilog hardware descriptions. The gener- engineering level at the earliest after the whole hardware ated models can be embedded into HDL or SystemC envi- development task has finished and all system components ronments via wrappers for the Verilog PLI (Program Lan- are available for their integration in a physical prototype. guage Interface) and SystemC. The model generator This means that a more accurate Simulink model of the Model Studio allows generating and validating software developed hardware IP, which would allow starting the models. Models created by this tool can be embedded into system validation task already at model level, does not several system level design tools as well as HDL simula- exist. This lack becomes more dramatically in the context tors and SystemC environments. An API is generated, of current system-level design methodologies like plat- which provides visibility to the model’s content. form-based design or component-based design. There- Both approaches do not intend to produce user- fore, an efficient reuse of existing hardware IP is highly readable code. Whereas user-readable code is required if crucial. a manual transition to a more abstract modeling of parts The paper is organized as follows: In section 2, exist- of the generated code is planned. These parts may be ei- ing strategies for implementing cycle-accurate Simulink ther performance-critical or their RT-level implementa- models are discussed. Section 3 outlines related work in tion is insignificant for the system model’s application the automatic generation of executable models from HDL (ALUs, memory banks, protocol interfaces, etc.). Some code. Section 4 presents our approach using a conversion non-commercial approaches generate SystemC code that into a SystemC model and its integration into Simulink. allows manual adaptations [4] [5]. This class of tools is The described approach was used to integrate an automo- characterized by a mapping of a subset of an HDL to al- tive hardware IP into Simulink, which is presented in sec- most equivalent SystemC code. The original HDL hard- tion 5. Finally, section 6 concludes with an outlook on ware description is reproduced by a generated code that future work. uses the available SystemC constructs. If there is no equivalent construct a comparable one is chosen, which is 2. Existing strategies functionally equivalent in most cases. Even if there is no comparable SystemC construct, the HDL construct is not Existing strategies to overcome this lack include the part of the supported subset. Thus, the supported subset of co-simulation of hardware descriptions and Simulink these tools is significantly smaller than the synthesizable models at systems engineering level. This is expensive in subset of the HDL. An equivalent behavior of the gener- terms of effort and costs because the expertise and envi- ated SystemC model is not guaranteed due to an impre- ronment for simulating hardware does usually not exist on cise language mapping. that level. In case of external customers, another aspect is that co-simulation usually requires the source code of the 4. SystemC-based approach hardware description, which might be critical due to non- disclosure reasons. Other strategies include the manual Our approach for an automated transformation of generation of C code descriptions for the hardware func- hardware descriptions into Simulink models also uses tionality to be embedded into Simulink via S-functions. In SystemC as an intermediate layer. The approach can be practical use, this is often not feasible due since the man- derived in two steps. In a first step, a VHDL hardware description is converted into a functional equivalent Sys- used to define the structure of the XML representation of temC model. This step is done using a company-internal a design for the particular language. The representation is transformation tool, which allows a highly flexible rule- based on a semantically annotated abstract syntax tree. based manipulation of source code descriptions. For that Additionally, the tool is able to generate the environment tool, a transformation rule was specified which provides a that is necessary to manipulate code written in the particu- mapping of hardware description and SystemC language. lar languages that is described by the grammar descrip- In a second step, the resulting SystemC code is embedded tions. This generation process yields four documents per into Simulink via a specific SystemC wrapper class, language. Firstly, the XML-Schema description is con- which implements an S-Function interface to Simulink. verted into an HTML document that describes the gram- mar for the user who implements transformation rules. 4.1. Generation of SystemC models Secondly, a grammar description for a parser generator is created. The parser generator uses this description to The use of an existing transformation tool for realizing build a lexical scanner and a parser that are used to con- the conversion from a VHDL hardware description into a vert HDL descriptions into the XML representation. The SystemC model reduced the implementation effort to the transformation tool uses ANTLR [12] generated lexical specification of a rule set for the mapping of the two lan- scanners and parsers. Thirdly, a DTD for the XML repre- guages. A powerful environment for defining this map- sentation is generated. The XSLT processor uses this ping is provided by a previously described in-house trans- DTD to check the syntactical correctness of the HDL formation tool [6] [7]. The main concept of the tool is a code represented by the XML tree. Finally, a library of conversion of an HDL description into an XML [8] repre- XSLT templates is created. The transformation rules use sentation. The XML representation is the basis for trans- those templates to add new code to the transformation formations. One of the main advantages of the XML rep- result. They ensure that the generated code is syntactically resentation is that efficient standard tools can be used to correct. The specification of transformation rules is per- manipulate the representation. These tools are XSLT formed in a generic XML-based transformation language processors, which use the W3C standard language XSLT that is derived from the available templates for the HDL. [9] to define rules (so-called style sheets) for processing Rules written in this language can be automatically trans- the input XML document. In our case, the XSLT proces- formed to XSLT style sheets, which are used by the sor Saxon [10] is used. Finally, after the transformations XSLT processor to manipulate the XML representation. are performed, the XML representation can be converted back into an HDL description. The transformation tool HTML XSL templ. ensures that comments and formatting is preserved from Transform. grammar for code stylesheets the original HDL code if the related statement is un- doc generation changed during the transformations. This allows the User mixed use of manual manipulation steps (by the ) XML Schema and automated transformation steps (by the tool). Figure 2 grammar definition shows the XML-based transformation flow.

Transformations Parser ANTLR DTD XSL generator grammar grammar processor Source Target definition definition

HDLXML HDL Figure 3. Automatically generated tool environment The transformation tool includes grammar descriptions Figure 2. XML-based transformation tool of both of the required languages: The input VHDL and The transformation tool mainly addresses design ma- the output SystemC. Therefore, the main task for the im- nipulations, which are often done manually. It replaces plementation of a VHDL to SystemC conversion was the these time-consuming and error-prone manipulations with description of a transformation rule that maps VHDL con- an automated approach. structs to equivalent SystemC. It is not mandatory that input and output languages of Because SystemC does not provide types that behave the tool are the same. In case of different languages, a exactly like VHDL types, a mayor requirement for the transformation rule that describes the mapping between mapping was the implementation of equivalents for the both languages is required. For the processing of different VHDL standard data types (i.e. integer, arrays, and enu- languages, the transformation tool requires a grammar meration types). The implemented mapping bases on the description for each of them. As shown in Figure 3, these use of a library that contains classes and templates to re- grammar descriptions are provided in the XML Schema produce the VHDL standard types including their associ- format [11]. At first, the XML Schema descriptions are ated attributes and operators. VHDL types derived from utes. Because IP blocks should be converted into Sys- the standard types can then be handled by the VHDL-to- temC and, in general, such blocks solely contain synthe- SystemC mapping. To allow compatibility to standard sizable code, it is sufficient to consider the synthesizable SystemC , an automatically generated wrapper on types (i.e. integer, enumeration, and array types) in this top of the design hierarchy realizes a configurable con- case. version to standard SystemC types. In our approach, a library has been created that con- tains C++ template classes. They can be used to declare 4.1.1. Conversion strategy VHDL-like types. Furthermore, it contains declarations of the VHDL standard types as declared in package At first sight, RTL descriptions in SystemC and VHDL std.standard and macros for the declaration of user- look very similar. However, unfortunately there are some defined types. differences in the details. In both languages exist hierar- The provided types and objects of those types support chical modules and processes, ports and signals, and RT the following features known from VHDL: level types like logic vectors and arbitrary integer types. • attributes Nevertheless, some features known from VHDL are not • range and index constraints supported or behave different in SystemC. The differ- • boundary checks on assignments ences can be classified into three categories: • ascending and descending ranges that do not have to 1. Syntactical differences. E.g., the declaration of a start with 0 function in another function is allowed in VHDL but • constrained and unconstrained subtypes not in C++ and therewith not in SystemC. Further- • operators as defined in VHDL more, C++ supports only constant integer expressions in case-statements, in VHDL array types can be used • string-to-array conversion. as well. Not implemented until now is the support for aggregates 2. Behavioral differences. E.g., operator precedence is and port slicing. different in both languages and in contrast to VHDL, Using these types instead of natural C++ or SystemC SystemC does no boundary checks on variable as- types allows a straightforward conversion of type and signments. object declarations, computational and assignment state- 3. Language elements. E.g., multiple for ments, and expressions in VHDL to equivalent SystemC. one entity, subtypes, or attributes of objects and The resulting code is still compliant to standard SystemC. types. 4.1.2. Implementation of the transformation rule The main task for a conversion from VHDL to Sys- temC is now to find equivalent C++-constructs for VHDL The VHDL to SystemC transformation works as de- elements. Solving the problems of the first category is scribed in section 4.1. The transformation rule walks possible, but only by workarounds because the formal through the XML representation of the VHDL code that syntax of C++ cannot be touched. Functions can be de- has been set up by the front-end of the transformation clared in a particular namespace instead of in another tool. While walking through the tree, every VHDL ele- function and accessed with its explicit name; case- ment is replaced by an equivalent SystemC construct and statements can be replaced by if-elsif-statements when afterwards the resulting XML representation of SystemC necessary. The second category splits into two parts. code can be written out as source text. Some of the problems, like operator precedence, are actu- Table 1. Mapping VHDL to SystemC (extract) ally caused by the C++ syntax definition. Workarounds are the only possible solution here as well (e.g., brackets VHDL SystemC can be used to correct operator precedence). The bound- package namespace entity SC_MODULE ary checks on variable assignments arise from the differ- design units SC_MODULE derived from ences in the type systems of C++/SystemC and VHDL. architecture Those differences can be eliminated by implementing the entity module missing features in C++. The third category, VHDL lan- generic template parameter guage elements that are not available in SystemC, can declarations port sc_port also be solved by implementing counterparts in C++. E.g., signal sc_signal process statement SC_METHOD/SC_THREAD multiple architectures for one entity can be realized as statements different derivations of the same entity module. Many of concurrent statement equivalent process statement the disparities apply to types and objects of those types. In a first step, the transformation rule transforms Therefore, it is useful to provide a set of types and associ- package declarations to namespaces and the declarations ated operators that behave like those in VHDL. Further- inside of it to equivalent C++ declarations. In a second more, they should support subtypes and the VHDL attrib- step, it processes entities. They lead to SystemC modules, its generics to template parameters, and its ports to corre- Table 2. Synchronization strategies sponding sc_port declarations. To support multiple archi- Scenario Strategy tectures for one entity, the transformation creates for each SystemC module Only internal events can occur. The S-function architecture one module that is derived from the module has no incoming gets a variable sample time assigned. It uses the that replaces the entity. Then, the content of the particu- signals event queue to predict the time of the next event. lar architecture is processed sequentially. Signal declara- Events can occur if incoming signals change. The SystemC module S-function gets inherited sample times assigned. tions lead to declarations of sc_signal, component instan- has incoming The sample time is inherited for each port sepa- tiations to instantiations of modules as class members, signals but no rately in order to allow different input sample internal periods process statements to SystemC processes, and so on. Sys- times. temC does not support concurrent statements as known SystemC module The S-function inputs inherit their sample times. A from VHDL but for each kind of it, there is an equivalent has incoming base period is calculated from the inherited sample process statement. Finally, a constructor has to be gener- signals and inter- times and the internal periods. The base period is ated that binds the ports of embedded components and nal periods assigned to the outgoing signals. starts the processes. The data type conversion is done implicit by the wrap- For the design’s top module, an additional step is per- per classes. Default C/C++ types are mapped to their formed. To connect the design to a standard SystemC Simulink equivalents. For SystemC types, different map- environment, the top module is surrounded by a wrapper ping strategies are available. The simplest way is a con- that converts its ports into standard SystemC types. Here version to the Simulink standard type double. For typical it is possible to use a standard mapping for the type con- SystemC modules generated from VHDL a conversion version, or it can be configured individually. from SystemC logic vectors to Simulink fixed point is the A particular characteristic of this transformation is that appropriate way. it is implemented to create readable code. As far as possi- ble, identifiers and the code structure in the generated 5. Experiments code are the same as in the original code. This especially includes formatting characters and comments; they are In the following, the automated flow will be compared inserted at a position in the result code that is equivalent to a manual. An automotive electronics example, the im- to their original position. Hence, the design is prepared plementation of a configurable bus-arbiter, has been used for further processing steps, automatic or by hand. for the evaluation. As shown in Figure 4, the arbiter se- quences the requests of the masters to access one of the 4.2. Embedding SystemC into Simulink slaves. The master and slave modules are part of the sys- tem model, which is implemented in MATLAB/Simulink. The integration of the resulting SystemC code into The arbiter itself is available as an IP block implemented Simulink is done by a previously described wrapper con- in synthesizable VHDL. cept [13]. This concept bases on an abstract SystemC wrapper class that realizes the S-Function interface re- Master Master ... Master quired by Simulink. The wrapper class provides the nec- essary functionality for synchronization and data type conversion between SystemC and Simulink. Classes im- plementing the abstract SystemC wrapper class are gener- Arbiter RT Level ated along with the VHDL-to-SystemC transformation. Therefore, the user of the flow described above gets a ready-to-compile Simulink model of the VHDL design. Slave Slave ... Slave The synchronization of the Simulink and the SystemC environment is a complex task because Simulink uses a sample-time whereas SystemC uses an event queue. Inte- System Level Interrupt grating SystemC into Simulink as an S-function requires Control that the S-function is updated whenever a signal at the interface of the SystemC module changes. Therefore, a Figure 4. Bus-arbiter model synchronization method where incoming signals inherit their sample time and outgoing signals have a variable For the manual conversion of the arbiter to a Simulink sample time would be preferred. Due to limitations of component as described in section 2, the designer needs Simulink, this preferred method is not supported. As a to know its entire functionality and how he can express it result, different scenarios with different synchronization in C code. Additionally, he must know how to write an S- strategies are supported by the provided wrapper classes. Function. Due to the different models computation in Table 2 gives a short overview. VHDL and Simulink simulations, it is a difficult task to come to a comparable behavior. As one can see, a de- 6. Conclusion and future work signer with knowledge in several abstraction layers and their particular tools is necessary to manage this task, and In this contribution, the challenges that lie in the inte- even then, it is time-consuming and error-prone. gration of hardware IP into the system development flow The automated flow consists of only four commands to have been discussed. Furthermore, an automated flow has the transformation tool, load bus-arbiter design, transform been described that allows the seamless integration of IP to SystemC, generate S-Function wrapper, and write out components available as VHDL code into a Simulink design. This can be done either by the system engineer or model. The VHDL code is converted automatically into by the RTL engineer because the four commands auto- equivalent SystemC code. This is done by an environment matically create an S-Function and no special knowledge for automated design transformations that has been ex- is needed. For both of them, the complete conversion plained in detail as well as the VHDL-to-SystemC map- costs only about five minutes. ping strategy. The result is a SystemC module surrounded In both approaches, the final step is to compile the re- by an S-Function wrapper, which can be used directly in a sulting S-Function and instantiate it in the appropriate Simulink model. An analysis of the benefits and the over- Simulink block, and afterwards, the simulation of the sys- head of the automated flow has been done by means of an tem can be started. industrial automotive electronics example. It has shown The analysis of the simulation performance shows that that the time saving due to the automation of the conver- it is almost the same in the two cases. Table 3 lists some sion surpass the overhead during simulation by far. profiling results that have been achieved with MATLAB Further tasks are to provide support for additional R2008a running on a Linux system with an Intel Pentium VHDL-features and to add specialized implementations D 2.8GHz CPU with 2GB RAM. The mentioned values of often-used VHDL types in C++ to improve their per- are the average values of ten simulation runs in each case. formance. Table 3. Simulation Performance manually automatically 7. References

implemented generated total duration 43.23s 44.03s [1] Hoffman, M., T. Beaumont, Application Develop- arbiter output 0.68s (1.57%) 1.72s (3.91%) ment: Managing a Project's Life Cycle, Mc Press, 1997 arbiter update 0.63s (1.46%) - [2] ARC International, VTOC for SoC Models, arbiter output + update 1.31s (3.03%) 1.72s (3.91%) http://www.arc.com/ arbiter relative performance 1 0.76 [3] Carbon Design Systems, Model Studio, total relative performance 1 0.98 http://carbondesignsystems.com/ The total duration of the simulation is 43.23s with the [4] VHDL-to-SystemC-Converter, European SystemC Users manually implemented S-Function and 44.03s with the Group, http://www-ti.informatik.uni-tuebingen.de/~systemc/ automatically generated one. The Simulink simulation [5] VH2SC, HT-Lab, http://www.ht-lab.com/ kernel calls two methods of the bus-arbiter S-Function in [6] Oetjens, J.-H., J. Gerlach, W. Rosenstiel, An XML Based Approach for the Flexible Representation and Transformation of each time step, the output method to set the modules out- System Descriptions, Forum on Design Languages, Lille, 2004 put ports and the update method to update the modules [7] Oetjens, J.-H., J. Gerlach, W. Rosenstiel, Flexible Specifi- internal states. In case of the manually implemented S- cation and Application of Rule-based Transformations in an Function, the simulation spends 1.31s on these two meth- Flow, Design, Automation, and Test in ods; that corresponds to 3.03% of the total simulation Europe, Munich, 2006 duration. The automatically generated S-Function stores [8] World Wide Web Consortium, Extensible Markup Lan- and updates its internal state in the SystemC part. There- guage, http://www.w3.org/XML/ fore, the update method is not used here. The output [9] World Wide Web Consortium, XSL Transformations method consumes 3.91% of the total simulation duration, (XSLT) Version 1.0, http://www.w3.org/TR/xslt/ 1.72s. The simulation performance of the automatically [10] The SAXON XSLT and XQuery Processor, generated arbiter module considered separately decreases http://saxon.sourceforge.net/ by a factor of 0.76 compared to the manual implemented [11] World Wide Web Consortium, XML Schema 1.0, version. That is very little according to the fact that it can http://www.w3.org/XML/Schema/ [12] ANTLR, ANother Tool for Language Recognition, be generated in a few minutes. The performance of the http://www.antlr.org/ complete simulation merely decreases by a factor of 0.98. [13] Hylla, K., J.-H. Oetjens, W. Nebel, Using SystemC for an If one assumes that the proposed flow is only used for a Extended MATLAB/Simulink verification flow, Forum on De- few parts of the system and most of the simulation dura- sign Languages, Stuttgart, 2008 tion is spent by processing the rest of the system, one can conclude that the automated flow involves no significant overhead.