e-Informatica Software Engineering Journal, Volume 12, Issue 1, 2018, pages: 9–26, DOI 10.5277/e-Inf180101

A Graphical Modelling Editor for STARSoC Design Flow Tool Based on Model Driven Engineering Approach

Elhillali Kerkouche∗, El Bay Bourennane∗∗, Allaoua Chaoui∗∗∗ ∗Department of Computer Science, Mohamed Seddik Ben Yahia University, Jijel, Algeria ∗∗LE2I Laboratoire, , University of Bourgogne, Dijon, France ∗∗∗MISC Laboratory, Department of Computer Science and its Applications, Faculty of IT, Abdelhamid Mehri University, Constantine, Algeria [email protected], [email protected], [email protected]

Abstract Background: Due to the increasing complexity of embedded systems, system designers use higher levels of abstraction in order to model and analyse system performances. STARSoC (Synthesis Tool for Adaptive and Reconfigurable System-on-Chip) is a tool for hardware/software co-design and the synthesis of System-on-Chip (SoC) starting from a high level model using the StreamsC textual language. The process behaviour is described in the syntax language, whereas the architecture is defined with a small set of annotation directives. Therefore, these specifications bring together a large number of details which increase their complexity. However, graphical modelling is better suited for visualizing system architecture. Objectives: In this paper, the authors propose a graphical modelling editor for STARSoC design tool which allows models to be constructed quickly and legibly. Its intent is to assist designers in building their models in terms of the UML Component-like Diagram, and in the automatic translation of the drawn model into StreamsC specification. Methods: To achieve this goal, the Model-Driven Engineering (MDE) approach and well-known frameworks and tools on the platform were employed. Conclusion: Our results indicate that the use of the Model-Driven Engineering (MDE) approach reduces the complexity of embedded system design, and it is sufficiently flexible to incorporate new design needs. Keywords: embedded systems, hardware/software co-design, STARSoC tool, UML, model-driven engineering, Eclipse modelling project 1. Introduction amount of code to be written by designers, which saves time to market and reduces fabrication The increasing complexity of embedded system costs compared to hand-tuned implementations designs calls for high level specification languages [2]. For these reasons, the design tools are widely (like StreamsC [1] or others C/C++ based ex- adopted by the embedded system designers’ com- tensions), and for automated transformations munity [3]. The specification of the applications towards lower level descriptions. These languages becomes easier at high abstraction levels, since allow to create high level models quickly, run sim- the implementation details are hidden from the ulations, optimize designs and investigate the ef- designer. ficiency of different algorithms and architectures The Synthesis Tool for Adaptive and Recon- before generating their corresponding low level figurable System-On-Chip(STARSoC) [4] is one implementations. The automatic generation of of those design tools that allow hardware-soft- low level implementation drastically reduces the ware co-design, design space exploration and high 10 Elhillali Kerkouche, El Bay Bourennane, Allaoua Chaoui level synthesis from a StreamsC textual specifi- objective, it is proposed to use the Model-Driven cation. The StreamsC language [5] permits the Engineering (MDE) [7] approach which is based modelling of the architecture and the behaviour on meta-modelling and Model Transformations, of a complex embedded system containing both and to employ well-known frameworks and tools Hardware and Software communicating processes. under the Eclipse platform to in this automatic In StreamsC textual models, the architecture of approach. the system is defined with a collection of annota- The rest of the paper is organized as fol- tion directives which are used to declare processes lows. Section 2 outlines the major related works. and communication between them, whereas pro- In section 3, some concepts of the StreamsC cesses’ behaviours are described in the C pro- language are presented. Section 4 presents the gramming language. Therefore, these specifica- STARSoC Tool. In section 5, an overview of the tions allow for gathering a lot of details (system Eclipse Modelling Project is given. In section 6, architecture and processes’ behaviours) which the approach is presented and it is applied on an increase their length and their complexity, and example in section 7. The last section concludes consequently decrease their legibility. the paper and gives some perspectives of this It is well known that graphical specification work. is better suited for describing the system com- ponents and their relationships, whereas compo- nents’ behaviours are generally expressed in tex- 2. Related works tual notations (like the C programming language) which allow their reuse as building blocks in new In the literature, several research works have designs. The optimal modelling solution consists been done on the automatic code generation tools in combining textual notations with graphical for Multi-Processor Systems-on-Chip (MPSoCs) notations in order to accumulate their advan- in order to facilitate and to accelerate the design tages. Thereby, every system aspect is provided process. with the most suitable view (textual/graphical). In addition to STARSoC, there are several UML Component Diagrams [6] are widely used code generation tools for MPSoCs which use the to define the structure of a system. A Component textual specification of the whole system as input. Diagram provides a clear view of the organization From this high level specification containing var- and the dependency among components in a sys- ious system parameters, the tools generate a low tem, including their contents (source code, binary level description of the system and perform their code or executable) and their interfaces through functionalities which are necessary in the design which they interact with one another. In this process, such as simulation, design space explo- work, the Authors propose to develop a graphical ration, performance evaluation, etc. For exam- modelling editor for the STARSoC design tool. ple, xENOC [8] is an automatic environment for More precisely, it is an approach and a tool sup- hardware/software design of Network-on-Chip port to allow a high-level graphical specification (NoC)-based MPSoC architectures. xENoC is of embedded systems which combines the archi- based on a tool, called NoCWizard which uses tectural and behavioural aspects of a system in an eXtensible Markup Language (XML) specifi- one model. The architectural aspect is expressed cation (including NoC features, Intellectual Prop- with a UML Component-like Diagram which is an erties (IPs) and mapping) to generate many types adaptation of the UML Component Diagram to of NoC instances by using Verilog language [9]. the structural concepts of the StreamsC language, In addition to NoC instances generation, xNoC whereas the behavioural aspect is specified in the also includes an Embedded Message Passing In- C programming language. From the graphical terface (eMPI) supporting parallel task communi- specification of a system, this approach permits cation. SystemCoDesigner [10] is another design to automatically generate a clean and correct environment for high-level system modelling and SteamsC specification. In order to achieve this simulation, automatic design space exploration A Graphical Modelling Editor for STARSoC Design Flow Tool Based on Model Driven Engineering Approach 11

and automatic hardware/software synthesis from Computer Science Laboratory of Lille University, abstract model to final implementation. In Sys- French) developed a design flow methodology and temCoDesigner, the input model is given using a tool labelled GASPARD2 [17]. Using a subset of SystemC textual language [11] which describes MARTE Profile, GASPARD2 follows the Model the structural and behavioural aspects of the sys- Driven Architecture (MDA) [18] principles to de- tem. In addition to academic environments, some scribe systems at different level of abstractions. It commercial design environments support the cre- emphasizes system level co-modelling (hardware ation of MPSoCs. The most popular are Altera and software), simulation, models refinement, System on a Programmable Chip (SoPC) [12] automatic code generation and IPs integration. and Xilinx Embedded Development Kit (EDK) The UML-SystemC profile [19] is proposed to [13]. In these environments, the hardware part take advantages of both UML and the SystemC description and the hardware-software integra- language. It captures both the structural and the tion of the final system are strongly automated behavioural features of the SystemC language using an extensive IP cores library. Although tex- and allows high level modelling of systems with tual notations better describe system parameters straightforward translation to the SystemC code. and aspects for the design and implementation, In [20], the authors proposed an UML-based these notations increase the complexity of system design environment, called Koski, for MPSoCs specifications. implementations of wireless sensor network ap- On the other hand, several research works plications. It provides a complete design flow have been proposed to adapt the UML notation covering the design phases from system level to the modelling of embedded systems. The ad- modelling to the FPGA (Field Programmable vantage of UML is that it can be extended to Gate Array) prototyping. Note that only the rel- any particular domain by defining profiles which evant profiles have been given here. Many other introduce additional domain-specific modelling works which combine the UML modelling with concepts and constraints. In this context, many embedded system design flow exist in the litera- profiles have been proposed for embedded sys- ture. However, they rarely cover all design phases tems design. The SysML (System Modelling Lan- from requirement modelling to implementation guage) profile [14] reuses a subset of UML nota- and validation. tion and provides additional extensions needed in In this work, the Authors intend to introduce system engineering. It offers graphical modelling a straightforward graphical modelling layer for support for the specification, analysis, design, the STARSoC tool. The proposed graphical mod- verification and validation of complex heteroge- elling editor increases flexibility by integrating neous systems that may combine hardware and the UML notation (UML Component Diagram software components. The MARTE (Modelling notation) to the STARSoC input specification and Analysis of Real-time and Embedded Sys- language (StreamsC). Furthermore, it takes ad- tems) profile [15] is another UML profile which vantages of the MDE approach to rapidl design adds capabilities to UML for the development systems and integrates new design needs. of Real Time and Embedded Systems (RTES). This extension provides support for specification, design and verification/validation phases. In ad- 3. StreamsC language dition, it defines a common way of modelling both the hardware and software aspects of sys- The StreamsC language is a parallel program- tems (such as the representation of repetitive ming language following the communicating pro- structures) in order to improve communication cess model [5]. The language is a small set of di- between developers. In order to cope with the rectives and library functions callable from a con- design complexities of intensive signal and image ventional C program. The directives are used data processing applications, the DaRT (Data- to declare three distinguished objects: process, parallelism for Real-Time) team [16] of LIFL (the stream or signal, whereas the library functions 12 Elhillali Kerkouche, El Bay Bourennane, Allaoua Chaoui

/// PROCESS_FUN /// IN_STREAM /// OUT_STREAM /// IN_SIGNAL /// OUT_SIGNAL /// PROCESS_FUN_BODY ...... C code ...... /// PROCESS_FUN_END Figure 1. Format of the PROCESS FUN directive

/// PROCESS PROCESS_FUN [TYPE [SP | HP]] Figure 2. Format of a process directive are used to communicate stream data between the process. The data type of stream or signal processes. In the StreamsC programming model elements precedes the name of the stream or a process is an independently executing object signal. StreamsC provides predefined unsigned with a process body. The process body is writ- and signed integer data types of stream or signal ten in a subset of C syntax and uses intrinsic elements for selected bit lengths ranging from 1 functions to perform stream or signal operations. to 64. The supported bit lengths are 1, 2, 4, 6, A process may be either software or hardware. 8, 12, 16, 18, 20, 24, 32, 40, 48, 64, 128. A sim- All declared processes are initiated when the ple convention is used to name these predefined program begins and runs until their subroutine types. The signed types have the name sc_int bodies complete their tasks/functions. . The unsigned types have the In the following, the directives format is re- name sc_uint. called for describing processes, streams and sig- To describe a process to StreamsC, the PRO- nals that a StreamsC program uses. These direc- CESS directive is used. A process has an asso- tives are embedded in specially formatted blocks. ciated run function and it is an SP (software Each directive must be on one line and prepended process) or HP (hardware process) type. If omit- by “///” followed by a keyword identifying the ted, SP is assumed. Figure 2 shows the format directive and optional parameter(s) [1]. of the PROCESS directive. The first set of directives describes the run The last directive CONNECT is used to con- function of a process. This is the body of code nect processes via streams and signals. To con- that gets executed when the associated process nect two processes, the name of one process’s is initiated. The PROCESS FUN directive gives stream or signal is associated with the name of a name to the run function, input and output another process’s stream or signal. In Figure 3, streams and signal parameters, followed by an the stream or signal formal parameter defined optional parameter to be passed to the process in the PROCESS FUN directive is generically when it is initiated. After the parameter, the referred to as a port. The CONNECT directive body of the function appears as a normal C code, must be specified from “source” to “destination” usually containing variable declarations, stream (see Figure 3). and/or signal communication, and computation. Note that the connections between processes Finally, a keyword directive is used to mark the must be one-to-one. Broadcast patterns and end of the run function. The format of the PRO- many-to-one connections are not supported. CESS FUN directive is shown in Figure 1. An example of the use of these directives to The stream and signal names can be used declare and connect processes is shown in Fig- within stream operations within the body of ure 4. There are two software processes called A Graphical Modelling Editor for STARSoC Design Flow Tool Based on Model Driven Engineering Approach 13

/// CONNECT . . Where: ::= stream or signal name from a PROCESS_FUN directive Figure 3. Format of a StreamsC CONNECT directive

// // Process Functions definitions // /// PROCESS_FUN setup_run /// OUT_STREAM sc_uint4 data /// PROCESS FUN BODY ... C code ... /// PROCESS_FUN_END /// PROCESS_FUN finish_r un /// IN_STREAM sc_uint4 processed_data /// PROCESS_FUN_BODY ... C code ... /// PROCESS_FUN_END /// PROCESS_FUN p_run /// IN_STREAM sc_uint4 s t r 1 /// OUT_STREAM sc_uint8 s t r 2 /// PROCESS_FUN_BODY ... C code ... /// PROCESS_FUN_END // // Process definitions // /// PROCESS setup PROCESS_FUN setup_run /// PROCESS p_1 PROCESS_FUN p_run TYPE HP /// PROCESS p_2 PROCESS_FUN p_run TYPE HP /// PROCESS f i n i s h PROCESS_FUN finish_run // // Connections // /// CONNECT setup.data p_1. str1 /// CONNECT p_1 . s t r 2 p_2 . s t r 1 /// CONNECT p_2. str2 finish .processed_data Figure 4. CONNECT directives example

setup and finish, and two hardware processes (Field Programmable Gate Array) platform for which are instances of the p process. The first Multi-Processor Systems on Chip (MPSoCs). instance of the p process (p_1) receives stream The overall design flow of the STARSoC tool data from the setup process. The second instance is summarized in Figure 5. of the p process (p_2) receives data from the The design methodology in the STARSoC previous instance and outputs data to the finish tool starts from a global model of an applica- process. tion which is a set of communicating processes described in the StreamsC textual language. In the StreamsC model, a process may be either 4. STARSoC design tool a software process (SP) or a hardware process (HP). Software and hardware processes represent STARSoC [4] is a framework for hard- the software and hardware part of the system, re- ware/software co-design, design space explo- spectively. The hardware and software partitions ration and rapid prototyping on an FPGA are defined by the user. Note that this design 14 Elhillali Kerkouche, El Bay Bourennane, Allaoua Chaoui

Figure 5. STARSoC design flow [21]

flow is based mainly on reusing open source Intel- fast simulation and design exploration of a com- lectual Properties (IPs) for both hardware and plex System on Chips (SoCs) at several levels software parts. of abstraction and detail. TLM proposes four After hardware-software partitioning, the well-defined transaction level abstraction mod- hardware part is synthesized in Register-Transfer els that can be independently validated, simu- Level (RTL) re-using the StreamsC compiler [22]. lated and estimated. In these models, the ap- In addition, the hardware interface allowing the plication is represented as a set of communi- two partitions, i.e. hardware and software, to cating processes where the communication and communicate is also generated in the RTL code. the computation are explicitly separated. These The obtained RTL code is then downloaded to processes perform computations and communi- the FPGA. The software part will be compiled cate with other processes through an abstract and re-instrumented to generate the machine channel. code of the software processes. This machine On the basis of the specification model which code is then downloaded into the program mem- describes system functionality without any ar- ory of each available processor in the gener- chitecture details (obtained from process codes), ated MPSoC platform. As a result, STARSoC the STARSoC tool performs co-simulation by generates a bus-based MPSoC platform from using the following TLM model levels shown in a high-level application specification. Figure 5: Before building a prototype for an applica- – PE-assembly model: it is made up with mul- tion, the STARSoC performs a hardware/soft- tiple processing elements (PEs) connected by ware co-simulation to validate the behaviour for channels. both hardware and software components and – Bus-arbitration model: it represents a refined also the interaction between them. In addition, PE-assembly model in the communication co-simulation permits the performance analy- part. sis and rapid exploration of several solutions – Cycle/time-accurate computation model: containing different descriptions of the system It contains cycle accurate computation components. For this purpose, The STARSoC and approximate-timed communication. tool uses Transaction-Level Modelling (TLM) This model can be generated from the framework [23] which is commonly used for the bus-arbitration model. A Graphical Modelling Editor for STARSoC Design Flow Tool Based on Model Driven Engineering Approach 15

The advantage of this approach is that it better rendered in a true graphical way. The allows designers to exploit the platform at the Graphical Editing Framework [28] provides tech- earlier stages of the design flow. nology to aid developers in creating rich graph- ical editors, which are not easily built using native widgets found in the base Eclipse plat- 5. Eclipse modelling project – form. It contains the entire set of tools to de- overview fine a graphical concrete syntax for each entity of the meta-model according to its appropriate The Eclipse Modelling Project [24] is a collection graphical notation. In addition, GEF employs of frameworks and tools for the Model Driven a Model-View-Controller (MVC) architecture Engineering on the Eclipse platform. In short, which is used to interconnect the graphical part they provide a wide range of solutions for vari- of an editor with the model elements. Thereby, it ous aspects of model driven development, from permits changes to be applied to the model from language definition, generative development of the view [25]. Although EMF and GEF can be language editors to code generation as well as used separately, building a graphical editor re- model verification and validation [25]. In the fol- quires both of them. In this sense, GEF provides lowing, some of the tools from Eclipse Modelling the graphical support required for building a di- Project that have been used in this work are agram editor on the top of the EMF framework. introduced. These tools are specifically recom- mended as a basis for developing a graphical 5.3. Graphical Modelling Framework editor for the STARSoC tool. (GMF)

5.1. Eclipse Modelling Framework The Graphical Modelling Framework [29] pro- (EMF) vides a generative component and runtime infras- tructure for developing graphical editors based on The Eclipse Modelling Framework [26] forms the EMF and GEF. In other words, it provides a gen- basis for all Eclipse Modelling Project tools. It erative bridge between the EMF (that allows the represents the modelling framework and the code meta-model definition) and GEF (a lightweight generation facility for specifying meta-models graphical framework, based on MVC architec- and managing model instances. More precisely, ture) to help developers creating enhanced graph- EMF includes its own meta-modelling language ical editors [25]. Using this framework, one can called Ecore which is used for defining the ab- define graphical notations for existing EMF stract syntax of modelling languages [27]. From meta-models. a modelling language specification defined by the Ecore meta-model, EMF generates a sim- 5.4. Acceleo language ple tree-based editor that enables viewing and editing the instances of the modelling language. Acceleo is a model-to-text transformation frame- In addition, EMF comes with a set of related work that generates text from models [30]. It has frameworks for validating models, creating and been in development since 2006, and was incorpo- executing queries against EMF models as well as rated into the Eclipse M2T project in 2009 [24]. model transactions. Its purpose is to implement code generators with an easy to use language (according to Object 5.2. Graphical Editing Framework Management Group’s MOF model to text trans- (GEF) formation language standard [31]) and a good enough tool support (IDE, syntax highlighting, Although EMF is able to generate tree-based edi- error reporting and debugging features). An Ac- tors for model instances of existing meta-models, celeo program requires a meta-model and a model these editors do not suffice since models are compliant with this meta-model, from which it 16 Elhillali Kerkouche, El Bay Bourennane, Allaoua Chaoui generates a text or a code. The meta-model and presented approach consists of a process with the model are defined using the EMF framework, two steps: which makes Acceleo compatible with other tools 1. The first step consists of specializing UML based on EMF. Component Diagram [6] into StreamsC struc- The Acceleo language is a template based tural concepts. For this purpose a meta-model approach wherein the text or code to be gener- for the specialised UML Component Dia- ated from models are specified as a set of text gram is proposed and a graphical modelling templates that are parameterized with model el- editor is built according to the proposed ements. More precisely, Acceleo scans the source meta-model. model according to its meta-model and defines 2. The second step encompasses defining the a textual template in the relevant syntax for code generation of StreamsC specification. In each text fragment to be generated. The vari- order to obtain the automatic and correct able parts in the text fragment are specified process of the code generation, the authors over model elements. An advantage of this sit- propose to use an Acceleo template language uation is the fact that the structure of the Ac- to define and implement the transformation. celeo templates will directly reflect the struc- ture of the generated text. Thus, the destina- 6.1. Specializing UML Component tion text is directly generated, with no need for Diagram into StreamsC structural post-processing. The main feature of Acceleo is concepts that the generated text is mixed with Acceleo syntax. To define a new modelling language or to extend and adapt an existing one, it is necessary to provide an abstract syntax (i.e. a meta-model de- 6. Graphical modelling editor for noting constructs, their attributes, relationships STARSoC and constraints) as well as concrete graphical syntax information (the appearance of constructs As it was mentioned earlier, the STARSoC tool and relationships in the graphical editor). In this starts from a StreamsC textual specification work, the authors prefer to adapt an existing which consists of the architecture and behaviour modelling language rather than to develop a new of a complex embedded system. Gathering all modelling language for specifying systems on the system aspects in StreamsC textual specifications STARSoC tool. increase their complexity, decrease their readabil- Since StreamsC specification consists of a set ity, and make their understanding and mainte- of communicating parallel software and hardware nance more difficult. To remedy this, the authors processes described with a high level textual lan- propose to develop a graphical modelling editor guage and each process may be linked to a con- for the STARSoC design tool which combines nector by an input port or an output port, the au- the architectural and behavioural aspects of the thors propose a modelling language adapted from system in one model. The architectural aspect is UML Component Diagram [6] which meets ad- expressed with a UML Component-like Diagram ditional needs for specifying embedded systems. serving this purpose, whereas the behavioural UML Component Diagrams are widely used to aspect is specified in the C syntax. From this define the architecture and the structure of a sys- whole model, the StreamsC specification can be tem. A Component Diagram shows components, generated and all STARSoC design flow activities their contents (source code, binary code or exe- can be performed. cutable one), required interfaces, ports and rela- This section provides the outline of, the pro- tionships between them. For this purpose, the au- cess of building the proposed graphical modelling thors proposed to meta-model the structural as- editor using the well-known frameworks defined pect of StreamsC language expressed in the UML in MDE approach on the Eclipse platform. The Component-like Diagram with the meta-model A Graphical Modelling Editor for STARSoC Design Flow Tool Based on Model Driven Engineering Approach 17

Figure 6. Proposed meta-model in Ecore

shown in Figure 6. In EMF, a meta-model is ProcessType attribute takes its value from Pro- created and defined in the Ecore format, which cessType enumeration class which is SP (Software is basically a sub-set of UML Class Diagrams. Process) or HP (Software Process). The proposed Ecore model is composed by the The Connector class represents the connec- following classes: tions between processes via Ports. A connector The Application class (attribute name: name) has two associations with two other classes called represents the application. It contains all the ele- OutputPort and InputPort, which are sub-classes ments used in the application which are process of the Port class. function definitions (ProcessFun), process defi- The OutputPort class describes the output nitions (ProcessCall) and connections between ports of source processes, whereas the InputPort processes (Connector). The containment rela- class represents the input ports of destination tions between the Application class and these processes. OutputPort and InputPort classes in- elements are specified with Composition relations herit two attributes from the Port class: the name as shown in Figure 6. of the port and the data type of the stream or The ProcessFun class represents the run func- signal which takes its value from the DataType tions of processes. It has a String attribute named enumeration class. FunCode containing the function code that gets In addition, OutputPort and InputPort executed when the associated process is initiated. classes are contained in the Process class which is The ProcessCall class represents initiated pro- the abstract class of ProcessFun and ProcessCall cesses in the application. Each process has an classes. associated run function which is specified with Despite its expressiveness, Ecore cannot cover an Instanceof association, and a ProcessType all modelling constraints for a modelling language attribute to indicate the type of the process. The using only graphical elements. Usually, OCL is 18 Elhillali Kerkouche, El Bay Bourennane, Allaoua Chaoui

Figure 7. Corresponding OCL invariants of the rules employed to define additional constraints as the subsequently the corresponding OCL invariants so-called well-formedness rules. These rules are in the OCLinEcore text editor [33], which embeds implemented in OCL as invariants which are the OCL expressions directly into Ecore models attached to meta-model classes in order to de- by annotating the relevant classes, are shown in scribe properties that should always be satisfied Figure 7. for every model. Thus, the invariant constraints Rule 1: The two end ports of the Connector are defined on the meta-model and validated on must have the same data type to assure their the model level using the EMF Validation Frame- compatibility. work [32]. By introducing the OCL invariants for Rule 2: ProcessCall must have the data type meta-model classes, a modelling language is more of the input port as declared in the input port precisely defined leading to models with higher of its corresponding ProcessFun. quality. Rule 3: ProcessCall must have the data type For this purpose, the proposed Ecore model of the output port as declared in the output port was enriched with three OCL invariant con- of its corresponding ProcessFun. straints. These invariants allow the user to check EMF from the proposed Ecore model was the correctness of the described models with re- used to generate a simple tree-based editor for spect to their construction rules as stated in the the modelling language that enables editing and StreamsC language. In the following part, these viewing model instances. To develop its graphical rules are described in a natural language, and modelling editors, both GEF and GMF were used A Graphical Modelling Editor for STARSoC Design Flow Tool Based on Model Driven Engineering Approach 19

Figure 8. Graphical concrete syntax definition

to define the Graphical model and the Tooling cessCallFigure Figure Descriptor. The rectangle model and Mapping model, respectively. sizes, colours, borders and labels are described The Graphical model defines the concrete separately as rectangle attributes. Similarly, each syntax of the modelling language according to node element of the Ecore model references the their appropriate graphical notations. It includes corresponding Figure Descriptor. information related to the graphical elements The Tooling model defines the toolbar, menus (i.e. nodes, labels, connections and decorations to be used and other periphery to facilitate the for connection ends) that will appear in the ed- management of the model content in the ed- itor. The Graphical Model contains also a Fig- itor. The main focus of the Tooling model is ure Gallery that contains figures which are used the toolbar definition. The toolbar is defined to define shapes. The elements that define the within a Palette and contains Tool Groups which nodes, connections and labels are under the Fig- contain the Tools. In Figure 9, the Tooling def- ure Gallery root in the graphical model. Figure 8 inition model for this editor consists of three shows the graphical definition model for the pro- Tool Groups, namely Processes, Ports and Con- posed Ecore model. For example, the ProcessCall nectors. The Processes Tool Group contains the node uses the rectangle shape defined under Pro- ProcessFun and ProcessCall tools for creating the 20 Elhillali Kerkouche, El Bay Bourennane, Allaoua Chaoui

Figure 9. Tooling definition model

Figure 10. Mapping definition model

ProcessFun and ProcessCall elements. The Ports meta-model elements to have children, where Tool Group includes InputPort and OutputPort each child contains an inner Node Mapping. In tools for creating the Input Port and Output addition to Top Node References, Link Mapping Port elements. The last tool group concerns the is used to specify information about a link. It creation of Connectors in the models. contains information about a source feature, tar- The Mapping model maps graphical elements get feature, graphical representation, creation from the graphical definition model and creation tool, and many other properties. For instance, tools from the tooling definition model to the according to the mapping model in Figure 10, language constructs from the meta-model. The ProcessCall elements (Fig. 6) are created by Mapping model consists of several Top Node Ref- means of the Creation Tool ProcessCall (Fig. 9) erences, each of which contain one Node Mapping. and the graphical representation for them is the The Node Mapping is used to map an element ProcessCall Figure definition (Fig. 8). For each in the graphical model to both the construct ProcessCall the corresponding “name” and “Pro- in the meta-model and to the creation tool. In cessType” attributes are also visualized because addition, it is within the Node Mapping that of the specified Feature Label Mappings which the Label Mappings and Child References are relate the attribute “name” (resp. the attribute defined. Label Mappings map a Diagram Label “ProcessType”) of the ProcessCall class with the in the graphical Model to an attribute in the diagram label ProcessCallName (resp. Process- meta-model class that is referenced by the en- CallProcessType) defined in the graphical defini- closing Node Mapping. Child References allow tion model. A Graphical Modelling Editor for STARSoC Design Flow Tool Based on Model Driven Engineering Approach 21

Figure 11. Generated editor for STARSoC

Finally, the Mapping model is transformed elements and for each element type produces into a diagram generator model from which a di- the corresponding StreamsC code. To achieve agram editor can be generated. Figure 11 shows this, the ToStreamsC template uses three others the graphical modelling editor generated form templates defined for the ProcessFun, Process- EMF and GMF models defined for specifying Call and Connector meta-model elements. For systems on the STARSoC design tool. The edi- example, the template GenProcessFun(pf : Pro- tor shows the graphical elements in the diagram cessFun) takes ProcessFun pf as a parameter and the tools in the palette. Furthermore, GMF and writes the run function description of pf, provides more advanced features such as anno- which contains the PROCESS_FUN directive, tating, zooming and layouting for the generated the name of the run function, the input and the editor. The properties of a graphical element can output streams, the body of the function and the be accessed through the properties view. PROCESS_FUN_END directive, to the output file. 6.2. Code generation of StreamsC specification 7. Case study The next step is the transformation of the graph- ical specification of a system into its equivalent To evaluate the practical usefulness of the pro- StreamsC specification using the Acceleo trans- posed graphical editor, a simple application of formation language. In order to do that, the pre- image processing involving the horizontal edge ceding transformation was composed with a set of detection of an image of 256 X 256 pixels coded Acceleo templates (see Figure 12) that traverses out of 8 bits was considered. The edge detection the elements of the source model (instances of is a preliminary step in most image processing meta-models) and generates the corresponding techniques. Figure 13 presents the model created StreamsC code. in this editor. The first Acceleo template ToStreamsC (App : The application is defined through two differ- Application) is the main template. It creates the ent processes. The first one is a software process, file of the StreamsC specification and takes the it allows to send the original image, through only instance of the Application class which con- its output stream, in the direction of the input tains all model elements as a parameter. Using stream of the second process which is a hardware this parameter (App), it scans the contained process. The hardware process performs edge 22 Elhillali Kerkouche, El Bay Bourennane, Allaoua Chaoui

[comment encoding UTF−8 / ] [module generate (’http://STARSoc/ ’)] [template public ToStreamsC (App : Application)] [comment @main/] [ file (App.name.concat(’.sc’), false , ’UTF−8 ’) /∗______[ App . name / ] .sc______Automatically generated streamsc specification ______∗/ // // Process Functions definitions // [for (processFun : ProcessFun| App.ContainsProcessFun)] [GenProcessFun(processFun) /] [ / f o r ] // // Process definitions // [for (processCall : ProcessCall| App.ContainsProcessCall)] [GenProcessFun(processCall )/] [ / f o r ] // // Connections // [for (connector : Connector| App.ContainsConnectors)] [GenConnector(connector , App)/] [ / f o r ] [ / f i l e ] [/template]

[template private GenProcessFun(pf : ProcessFun)] /// PROCESS_FUN [ pf . name / ] /// IN_STREAM [ pf .HasInputPort.DataType/] [ pf .HasInputPort.name/ /// OUT_STREAM [ pf .HasOutput Port.DataType/] [ pf .HasOutputPort.name/] /// PROCESS_FUN_BODY [pf.FunCode /] /// PROCESS_FUN_END [/template]

[template private GenProcessCall(pc : ProcessCall)] /// PRoCESS [pc.name/] PROCESS_FUN [pc. InstanceOf .name/] TYPE [pc.ProcessType/] [/template]

[template private GenConnector(c : Connector, App:Application)] /// CONNECT [for (pc :ProcessCall| App.ContainsProcessCall)] [ if (pc.HasOutputPort=c.FromOutputPort)][ pc.name/][/ if ] [ / f o r ] .[ c.FromOutputPort.name/] [for (pc :ProcessCall| App.ContainsProcessCall)] [ if (pc.HasInputPort=c.ToInputPort)][pc.name/][/ if ] [ / f o r ] .[ c.ToInputPort.name/] [/template] Figure 12. Acceleo Templates for StreamsC code generation A Graphical Modelling Editor for STARSoC Design Flow Tool Based on Model Driven Engineering Approach 23

Figure 13. Graphical specification of the application

detection image and returns the resulting image works and tools (EMF, GEF, GMF, Acceleo,. . . ), to the software process. which follow the principles of MDE approach, The edge detection algorithm calculates the were used to develop a graphical editor for the absolute value of the difference between two con- STARSoC design tool. This editor supports the secutive pixels arriving on the data bus of the graphical editing of embedded system models input streams. The equation of the horizontal in terms of UML Component-like Diagram and edge detection filter is as follows: generates the StreamsC textual specifications of these models. The adapted UML Compo- y(x) = |x(n) − x(n − 1)| (1) nent Diagram is defined in accordance with Only one hardware process is sufficient to the embedded system design needs using the perform this calculation. The algorithm of hor- Ecore model, whereas the transformation pro- izontal edge detection is described below (see cess is defined and executed using the Acceleo Figure 14). framework. The resulting StreamsC specifica- Its equivalent StreamsC description is gen- tions are used to perform all STARSoC de- erated from the graphical specification of the sign tool activities, such as hardware/software application. To generate StreamsC specification co-design, design space exploration and high level in this approach, it is necessary to execute the synthesis. Acceleo template defined in the previous section. According to the authors this approach is suf- The automatic generated file Essai.sc, which con- ficiently flexible to incorporate new design needs. tains the specification, is shown in Figure 15. Due to the employed Eclipse Modelling Project, This StreamsC specification of the whole ap- revisions of the meta-model almost automatically plication is the basis on which all STARSoC de- yield an updated editor and the generation of sign activities can be performed. Figure 16 shows a text or code is supported as the coding of each the development environment for STARSoC tool. meta-model element is analysed separately. Future work plans encompass the use and adaptation of some UML behavioural diagrams 8. Conclusion in order to depict the behavioural features of embedded system processes. These behavioural The paper presents some attempts to improve diagrams will be used to automatically generate the STARSoC design tool by taking advantage process codes. One promising direction is to com- of the Model Driven Engineering techniques. bine existing UML profiles for embedded systems More precisely, Eclipse Modelling Project frame- design, such as SysML and MARTE profiles. This 24 Elhillali Kerkouche, El Bay Bourennane, Allaoua Chaoui sc_uint8 data_in, data_out, x, y; sc_stream_open(input_stream ); sc_stream_open(output_stream ); while (!sc_stream − eos(input_stream)) { #pragma SC pipeline data_in = sc_stream_read(input_stream); sc_stream_write(output_stream.data_out ); y = x − data_in ; x = data_in ; If (y>= 0) { data_out = y; } Else { data_out = y ∗ ( −1); } } sc_stream_close(input_stream ); sc_stream_close(output_stream ); Figure 14. Horizontal edges detection algorithm

Figure 15. Generated StreamsC specification A Graphical Modelling Editor for STARSoC Design Flow Tool Based on Model Driven Engineering Approach 25

Figure 16. The development environment for STARSoC tool combination is possible since most of the profiles in Proceedings of the 2000 IEEE Symposium are focused on the process paradigm. on Field-Programmable Custom Computing Ma- chines. Napa Valley, CA, USA: IEEE Computer Society, Apr. 2000, pp. 49–56. References [6] Unified Modeling Language, Version 2.5, Object Management Group, 2015, OMG [1] M. Gokhale, sc2 Reference Manual, Los Alamos Document Number: formal/15-03-01. [Online]. National Laboratory, Los Alamos, NM, USA, http://www.omg.org/spec/UML/2.5/PDF 2003. [7] A.R. da Silva, “Model-driven engineering,” [2] W. Meeus, K.V. Beeck, T. Goedemé, J. Meel, Computer Languages, Systems and Structures, and D. Stroobandt, “An overview of today’s Vol. 43, No. C, Oct. 2015, pp. 139–155. high-level synthesis tools,” Design Automation [8] J. Joven, O. Font-Bach, D. Castells-Rufas, for Embedded Systems, Vol. 16, No. 3, Aug. 2012, R. Martínez, L. Terés, and J. Carrabina, “xENoC pp. 31–51. – an experimental network-on-chip environment [3] J. Cong, B. Liu, S. Neuendorffer, J. Noguera, for parallel distributed computing on NoC-based K.A. Vissers, and Z. Zhang, “High-level synthe- MPSoC architectures,” in 16th Euromicro In- sis for FPGAs: From prototyping to deployment,” ternational Conference on Parallel, Distributed IEEE Transactions on Computer-Aided Design and Network-Based Processing. Toulouse, France: of Integrated Circuits and Systems, Vol. 30, No. 4, IEEE Computer Society, Feb. 2008, pp. 141–148. Apr. 2011, pp. 473–491. [9] D. Thomas and P. Moorby, The Verilog Hard- [4] A. Samahi and E. Bourennane, “Automated inte- ware Description Language, 3rd ed. Norwell, MA, gration and communication synthesis of reconfig- USA: Kluwer Academic Publishers, 1996. urable MPSoC platform,” in Second NASA/ESA [10] J. Keinert, M. Streubuhr, T. Schlichter, J. Falk, Conference on Adaptive Hardware and Sys- J. Gladigau, C. Haubelt, J. Teich, and M. Mered- tems (AHS), University of Edinburgh. Scotland, ith, “SystemCoDesigner – an automatic ESL syn- United Kingdom: IEEE Computer Society, Aug. thesis approach by design space exploration and 2007, pp. 379–385. behavioral synthesis for streaming applications,” [5] M. B.Gokhale, J.M. Stone, J. Arnold, and ACM Transactions on Design Automation of M. Kalinowski, “Stream-oriented FPGA com- Electronic Systems, Vol. 14, No. 1, Jan. 2009, pp. puting in the Streams-C high level language,” 1–23. 26 Elhillali Kerkouche, El Bay Bourennane, Allaoua Chaoui

[11] T. Grotker, System Design with SystemC. Nor- [21] S. Boukhechem and E. Bourennane, “SystemC well, MA, USA: Kluwer Academic Publishers, transaction-level modeling of an MPSoC plat- 2002. form based on an open source ISS by using in- [12] SOPC Builder User Guide, Version 1.0, terprocess communication,” International Jour- Altera Corporation, San Jose, CA, USA, nal of Reconfigurable Computing, Vol. 2008, Sep. Dec. 2010, Document Number: UG-01096. 2008, pp. 1–10. [Online]. http://www.altera.com/literature/ug/ [22] J. Frigo, sc2 Hardware Library Reference Man- ug_SOPC_builder.pdf ual, Los Alamos National Laboratory, Los [13] EDK Concepts, Tools, and Techniques: A Alamos, NM, USA, 2000. Hands-On Guide to Effective Embedded [23] L. Cai and D. Gajski, “Transaction level mod- System Design, Version 13.2, Xilinx eling: An overview,” in Proceedings of the 1st Online Documents, Jul. 2011, OMG IEEE/ACM/IFIP International Conference on Document Number: UG683. [Online]. http: Hardware/Software Codesign and System Syn- //www.xilinx.com/support/documentation/ thesis. Newport Beach, CA, USA: ACM, Oct. sw_manuals/xilinx13_2/edk_ctt.pdf 2003, pp. 19–24. [14] Systems Modeling Language (OMG SysML), Ver- [24] Eclipse modelling project (EMP). [Online]. sion 1.4, Object Management Group, Sep. 2015, http://www.eclipse.org/modeling/ [Accessed OMG Document Number: formal/2015-06-03. 2016]. [Online]. http://www.omg.org/spec/SysML/1. [25] R.C. Gronback, Eclipse Modeling Project: A 4/ Domain-Specific Language (DSL) Toolkit, 1st ed. [15] A UML Profile for MARTE: Modeling and Addison-Wesley Professional, 2009. Analysis of Real-Time Embedded systems, [26] Eclipse modelling framework (EMF). [On- Version Beta 2, Object Management Group, Jun. line]. https://eclipse.org/modeling/emf/ [Ac- 2008, OMG Document Number: ptc/2008-06-09. cessed 2016]. [Online]. http://www.omg.org/omgmarte/ [27] D. Steinberg, F. Budinsky, M. Paternostro, and Documents/Specifications/08-06-09.pdf E. Merks, EMF: Eclipse Modeling Framework [16] DaRT team: Dataparallelism for real-time. 2.0, 2nd ed. Addison-Wesley Professional, 2009. [Online]. http://www.inria.fr/en/teams/dart/ [28] Graphical editing framework (GEF). [Online]. [Accessed 2016]. http://www.eclipse.org/gef/ [Accessed 2016]. [17] GASPARD2 SoC framework. [Online]. http: [29] Graphical modelling framework (GMF)). [On- //www.gaspard2.org/ [Accessed 2016]. line]. http://www.eclipse.org/modeling/gmp/ [18] Model Driven Architecture Guide, Version [Accessed 2016]. 1.0, Object Management Group, 2003, [30] User Guide, Version 3.1.0, The Eclipse Foun- OMG Document Number: omg/2003-05-01. dation, 2011. [Online]. http://www.eclipse.org/ [Online]. http://www.omg.org/mda/mda_files/ acceleo/support/ MDA_Guide_Version1-0.pdf [31] MOF Model to Text Transformation [19] UML Profile for System on a Chip Language, Version 1.0, Object Manage- (SoC), Version 1.0.1, Object Manage- ment Group, Jun. 2008, OMG Docu- ment Group, Aug. 2006, OMG Docu- ment Number: formal/2008-01-16. [Online]. ment Number: formal/2006-08-01. [Online]. http://www.omg.org/spec/MOFM2T/ http://www.omg.org/spec/SoCP/1.0.1/PDF [32] The EMF validation framework project [20] T. Kangas, P. Kukkala, H. Orsila, E. Salminen, (EMF-VF). [Online]. http://www.eclipse.org/ M. Hännikäinen, T.D. Hämäläinen, J. Riihimäki, modeling/emf/?project=validation [Accessed and K. Kuusilinna, “UML-based multiprocessor 2016]. SoC design framework,” ACM Transactions on [33] OCLinEcore editor. [Online]. https://wiki. Embedded Computing Systems, Vol. 5, No. 2, eclipse.org/MDT/OCLinEcore [Accessed 2016]. May 2006, pp. 281–320.