An Object-Oriented Platform-based Design Process for Embedded ...

0 downloads 0 Views 424KB Size Report
plex systems. This paper describes an object-oriented platform- based design process for real-time embedded systems. The pro- posed approach promotes a ...
An Object-Oriented Platform-based Design Process for Embedded Real-Time Systems Marco A. Wehrmeister1, Leandro B. Becker3, Flávio R. Wagner1, Carlos E. Pereira2 1

Computer Science Institute, Federal University of Rio Grande do Sul (UFRGS), Brazil Electrical Engineering Department, Federal University of Rio Grande do Sul (UFRGS), Brazil 3 Automation and Control Systems Department, Federal University of Santa Catarina (UFSC), Brazil 2

ABSTRACT The growing complexity of today’s embedded real-time systems demands new methods and tools in order to manage the problems of design, analysis, integration and validation of complex systems. This paper describes an object-oriented platformbased design process for real-time embedded systems. The proposed approach promotes a smooth transition from high-level UML specification to implementation, which is composed by hardware and software components. The transition from higher to lower abstraction levels is facilitated by the use of an OO realtime API, whose underlying facilities can be optimized according to the application needs and selected platform. An integrated toolset is used to support the intermediate steps of the design process. In order to illustrate the proposed approach and related toolset the design of an embedded real-time automation system for an “intelligent” wheelchair is presented. Keywords: real-time object computing, RT-UML, RT-Java, code generation.

1 Introduction The design of real-time embedded systems is a complex task because these systems include hardware and software components that must be normally highly optimized for the application. In the past, hardware configuration dominated the implementation of these systems. Nowadays, a large part of embedded realtime systems are implemented as mixed configurations (hardware + software), where the software components have become key for a successful system [2]. The dominance of software in real-time embedded systems design caused the interest on methodologies with widely accepted notations in the software community, such as the Unified Modeling Language (UML) [5]. Approaches that use UML for embedded systems design are presented in [8], [1], [6] and [10]. Nevertheless, there are still gaps that should be tackled by new methodologies. This paper introduces the Object-Oriented Platform-Based Design Process for Embedded Real-Time Systems, or simply SEEP (project acronym in Portuguese), which proposes a new method to design real-time embedded systems. This project deals with all development phases, including modeling, analysis, validation, and synthesis tools to support the development of optimized real-time embedded systems. The approach is based on the reuse of hardware and software components and on the configuration of FPGA-based architectural platforms. The SEEP approach aims at a smooth transition from objectoriented models specified with RT-UML [11] to implementation.

The transition from higher to lower abstraction levels is facilitated by the use of a real-time Java API [12] whose underlying facilities are customizable and optimized according to the application requirements and available platforms. This API includes high-level real-time constructs and therefore avoids the use of low-level system calls to implement the specified temporal behavior. Furthermore, using the provided API it is possible to design concurrent real-time Java applications and synthesize them into a dedicated Java processor [7]. The mapping from the RT-UML specs into the RTSJ-based API is based on the work presented in [3], which presents an approach that defines a clear link between real-time constraints and the programming entities that provide their implementation. The main idea of this approach is to enhance the traceability as well as the readability of timing constraints from the modeled requirements to its implementation. The remainder of this paper is organized as follows. Section 2 describes the design methodology proposed in the SEEP project. Section 3 presents the toolset developed to support the proposed design methodology and respective embedded system generation. Section 4 shows the use of the design methodology for the development of a wheelchair control and automation system. Concluding remarks and future work directions are presented in Section 5.

2 The SEEP Methodology The SEEP methodology proposes a complete and integrated approach for SoC (system-on-chip) design and ASIP (application-specific instruction set processor) generation. This methodology is defined to guide the system integrator and the core provider towards the development of embedded applications within a reduced design time. Therefore the reuse concept is assumed, and each design step aims at facilitating the development of reusable components and the rapid, but cost effective, design space exploration. An overview of the proposed design methodology is depicted in Figure 1. According to the design steps in this methodology, the design of an embedded SoC starts with the definition and validation of a high-level, pure functional model, which is not influenced by architectural choices and does not consider how design requirements (power, performance) may be fulfilled. The second step, namely system exploration, allows the evaluation of algorithms that can be used to implement parts or the whole application. As input, this process uses a library of preimplemented algorithms and models, as well as estimation data regarding their implementation on available platforms. Thus, the algorithms can be analyzed, considering the available estimation data, in terms of efficiency, power consumption, memory occupa-

tion, and area costs. Test issues are also taken into account during this phase. As a result, the chosen algorithms are coded in some executable language, such as SystemC, Java, C++, etc. With this description, the architectural exploration can take place.

As previously mentioned, the SEEP approach promotes a smooth transition from object-oriented models specified with RTUML to the final embedded system. Such transition is facilitated by the use of an object-oriented real-time API, which is currently implemented for the RT-Java programming language (it is based on the RTSJ standard [4]).

3 Toolset for Embedded System Generation

Figure 1: The SEEP design methodology

In the architectural exploration step, the designer decides on major architectural blocks for the system implementation. This step allows the evaluation of a number of architectures that can be used to implement the functional solution initially devised. As input, this process uses libraries of pre-implemented platforms and components. The following tasks are performed: hw/sw partitioning, definition of type and number of processing units (microprocessors, ASICs, DSPs), definition of communication structure (networks-on-chip [13], bus, peer-to-peer). Currently, two platforms are being considered in the SEEP project. The first one is based on a family of Java processors, implemented on conventional FPGAs, while the second one is a commercial platform, containing a large FPGA with two PowerPC processors. The final result is an abstract macro-architecture, where some of the specified application tasks are deployed as software tasks while others are deployed to dedicated hardware blocks. For guiding both system and architectural exploration, estimators are available to evaluate the impact of design decisions on characteristics such as power and energy consumption, memory occupation, and performance. Additionally, data from new implemented systems can be added to refine the design space exploration of future applications. Finally, hardware and software synthesis are performed in steps 5 to 7. This synthesis is largely automated. Software parts are compiled for the architecture on which they will be deployed. As part of the software synthesis process, an operating system may be required to implement services such as task communication and task scheduling. This operating system must be also dedicated to the application and optimized for the given design requirements. A VHDL description of a cycle-and-pin accurate micro-architecture is generated for the hardware part. Inputs to this task are VHDL descriptions of the selected architectural blocks, already available in the component library. These descriptions may be parameterized, and their configuration depends on design decisions taken at the design exploration steps. As a final result, a complete real-time embedded system is generated.

As mentioned in the previous section, an executable description is used as input for the architectural exploration, where alternative hardware and software solutions that fulfill the system requirements should be considered and evaluated. After compiling all the available information, the final system generation is performed, resulting in a micro-architecture and a software description for a dedicated system. In the SEEP methodology, we are currently limited to accept Java source code for representing the architecture-independent description. Using the SASHIMI environment [7], both a VHDL description for a dedicated Java processor and the respective program memory code (application code) are generated. This CAD environment automatically synthesizes a dedicated microprocessor (named FemtoJava) for a target application, using only a subset of instructions required by the application. This Java processor implements an execution engine for Java in hardware through a stack machine that is compatible with the Java Virtual Machine (JVM) specification. A customized control unit for the FemtoJava processor is generated, supporting only the opcodes used by the application. The size of its control unit is thus directly proportional to the number of different opcodes utilized by the application software. In order to more clearly express the timing and other constraints in the source code of the real-time embedded application, an API based on the Real-Time Specification for Java (RTSJ) was developed. This specification introduces the concept of schedulable objects, which are instances of classes that implement the Schedulable interface, such as the RealtimeThread. It also specifies a set of classes to store parameters that represent a particular resource demand from one or more schedulable objects. For example, the ReleaseParameters class (superclass from AperiodicParameters and PeriodicParameters) includes several useful parameters for the specification of real-time requirements. Moreover, it supports the expression of the following elements: absolute and relative time values, timers, periodic and aperiodic tasks, and scheduling policies. The term ‘task’ derives from the scheduling literature, representing a schedulable element within the system context. It is also a synonym for schedulable object. A brief description of the available classes follows (a more detailed description can be found in [12]): RealtimeThread: represents a real-time task in the embedded system. It can be periodic or aperiodic, depending on the given release parameter object. ReleaseParameters: base class for all release parameters of a real-time task. It has attributes like cost and deadline. The periodicParameters subclass has attributes like the start and end time and also the execution period. The SporadicParameters class (a subclass from AperiodicParameters) has attributes like the minimum interval between two occurrences. SchedulingParameters: base class for all scheduling parameters used by the Scheduler object. The task priority is repre-

sented by the class PriorityParameters, which can be used by scheduling mechanisms such as the PriorityScheduler. Scheduler: abstract class that represents the scheduler itself (scheduling algorithm). It contains the subclasses PriorityScheduler, RateMonotonicScheduler, and EDFScheduler. HighResolutionTime: base class for all classes that represent a time value. The subclass AbsoluteTime represents an absolute instant of time. The subclass RelativeTime represents a time relative to other time instant that is given as parameter. Clock: a global clock reference. It returns an AbsoluteTime object that represents the current system date and time. Timer: abstract class that represents a system timer. The derived class OneShotTimer represents a single timer occurrence, while the derived class PeriodicTimer represents a periodic one. Some of the proposed API classes have slight differences in their implementation when compared to the RTSJ. This is due to constraints in the FemtoJava architecture and also for clarity reasons. An example of such difference appears in the RealtimeThread class. In the proposed implementation, it has two abstract methods that have to be implemented in the derived subclasses: mainTask() and exceptionTask(). They represent, respectively, the task body – equivalent to the run() method from a normal Java thread – and the exception handling code applied when deadline misses occur. This simplification allows the exception handling code to be executed in the same object context of main thread code, thus reducing the memory usage when compared to the RTSJ approach. Another class that has a different implementation is the Timer class. It has an abstract method named runTimer() that must be implemented in the subclass and represents the code executed when the timer expires. This method appears both in the OneShotTimer and PeriodicTimer classes.

4 Case Study To illustrate the use of the SEEP methodology, a case study is presented. It consists in the design of a real-time embedded automation and control system for an “intelligent” wheelchair to support people with special needs. The main function of the system is the movement control. Hard-real time requirements must be accomplished for safety reasons. The design process starts with the construction of a high-level object modeling using RT-UML. Diagrams used in the model are: Use Cases, Collaboration, and Class Diagrams. Especially the last two diagrams are decorated with the stereotypes and tag-values coming from RT-UML. Figure 2 presents the object collaboration diagram for the ‘movement actuation’. It contains three classes representing, respectively, the interface class for the joystick used in the wheelchair control, the interface class for the motor activation drive, and the class that represents the movement controller itself. Readers should attempt to the RT-UML stereotypes that are used to decorate this diagram. For example, the stereotype «SAtrigger» in A.1 is used to represent a periodic activation for the joystick data sampling. Moreover, «SAresponse» in A.1.2 is used to assign a deadline for the execution of the wheelchair motor control. The next phase in the SEEP design cycle is system exploration. In this phase, algorithms and library components are selected to optimize the wheelchair control for a given platform. An extensive discussion about this topic is out of the scope of this

Figure 2: Object collaboration diagram for ‘Movement actuating’

paper and readers interested in more details can refer to [9]. For the present case study, it is assumed that the Java programming language is chosen for coding the selected algorithm, so that programs that make use of the RTSJ-based API presented in Section 3 are generated. Details about this process follow. When applied to classes, the RT-UML stereotypes correspond to Java classes that may extend classes from a RTSJ-based API, e.g. «SAscheRes» can be mapped to RealtimeThread. Stereotype tags that are relevant in the context of the runtime application are mapped to RTSJ-based API class attributes. Class constructors should accept initialization values for such attributes. When applied to methods, they correspond to methods implemented in the generated class or in one of its attributes. Figure 3 shows the result of the performed mapping, containing the source code for the real-time class JoystickDriver, which includes objects responsible for periodically sampling the joystick commands and, if necessary, for notifying the MovementController about the necessity of acting in the movement. The period and deadline information derives from tags specified in the collaboration diagram in Figure 2. They are represented, respectively, by the «SATriggers» and «SAResponse» stereotypes of RT-UML. The code contains two important methods: mainTask() and exceptionTask(). The former represents the task body, i.e., the code executed when the task is activated. This is a periodic task, in which periodic activation is implemented as a loop whose execution frequency is controlled by calling the waitForNextPeriod() method. This method uses the task release parameters for interacting with the scheduler and controlling the correct execution of the method. The exceptionTask() method represents the exception handling code that is triggered in case of a deadline miss, i.e., if the mainTask() method does not finish on time. After the source code is generated using the RTSJ-based API, it is then compiled using a standard Java compiler, and the synthesis of the embedded real-time system is performed. The resulting class files are used as input to the SASHIMI tool and analyzed in order to generate VHDL files that will customize the FemtoJava processor. It is important to highlight that the generated FemtoJava’s control unit is proportional to the number of different Java opcodes used by the application software. In the final step, the resulting binary is loaded into the FPGA.

Import saito.sashimi.realtime.*; public class JoystickDriver extends RealtimeThread { private static RelativeTime _100_ms = new RelativeTime(0,100, 0); private static PeriodicParameters schedParams = new PeriodicParameters(null, // start time null, // end time _100_ms, // period null, // cost _100_ms);// deadline // Attributes private int m_angle; private int m_intensity; ... // other attributes public JoystickDriver() { super(null, schedParams); // do other initializations } public void mainTask() { while(isRunning == true){//periodic loop // read analogic joystick commands this.readValuesFromHardware(); Wheelchair.movementCtrl.notify(this.m_angle, this.m_intensity); this.waitForNextPeriod(); } } private void readValuesFromHardware(); { ... // reading hardware }

};

References [1] [2]

[3]

[4] [5]

public void exceptionTask() { // handle deadline missing }

[6] Figure 3: JoystickDriver class

5 Conclusions and Future Work This paper presented the methodology proposed in the scope of the SEEP project, which aims at the design of embedded realtime systems that are composed of hardware and software elements. Moreover, the hardware and software platform underlying this design methodology was also presented. The paper included a case study, which was used to guide readers through the methodology and also to discuss how RT-UML specifications can be mapped into the RTSJ-based API elements. Using the proposed mapping, it is possible to generate the embedded application directly from the UML level. The paper showed the integration of the design phases proposed within the SEEP design process. It described the requirements modeling stage using RT-UML as well as the further design stages, including the system implementation using an API and the available Java platform. It is important to highlight that the mapping process is not unique and that other APIs offer different alternatives to implement given timing requirements. Nevertheless, the developed API is highly optimized for the FemtoJava platform. As future work, the authors intend to integrate the proposed methodology into a CASE tool, thus increasing the automation level for embedded systems design. Other issue to be tackled is the evaluation of alternative implementations of the wheelchair control using different platforms, in order to compare the impact of different design decisions in the proposed methodology.

[7] [8]

[9]

[10]

[11]

[12]

[13]

6 Acknowledgments Thanks are given to the Brazilian funding agency CNPq, which is the project sponsor. The authors also thank the other SEEP-project researchers for the valuable discussions.

Axelsson, J. Real-World Modeling in UML. In: 13th International Conference on Software and Systems Engineering and their Applications, Paris, France, Dec. 2000. Balarin, F.; Chiodo, M.; Giusto, P.; Hsieh, H.; Jurecska, A.; Lavagno, L.; Sangiovanni-Vincentelli, A.; Sentovich, E.; Suzuki, K. Synthesis of Software Programs for Embedded Control Applications. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, New York, June 1999. Becker, L.B.; Holtz, R.; Pereira, C.E. On Mapping RTUML Specifications to RT-Java API: Bridging the Gap. In: 5th IEEE International Symposium on Object-Oriented Real-Time Distributed Computing, Washington, USA, 2002. p. 348-355 Bollella, G.; Gosling, J.; Brosgol, B. (2001). The RealTime Specification for Java, http://www.rtj.org/rtsjV1.0.pdf Booch, G.; Rumbaugh, J.; Jacobson, I. The Unified Modeling Language User Guide. Reading, Massachusetts: Addison-Wesley, 1999. Chen, R.; Sgroi, M.; Lavagno, L.; Martin, G.; Sangiovanni-Vincentelli, A.; Rabaey, J. UML and Platformbased Design. Norwell: Kluwer Academic Publishers, 2003. p. 107 – 126. Ito, S.; Carro, L; Jacobi, R.P. Making Java Work for Microcontroller Applications. IEEE Design & Test of Computers, vol. 18, n. 5, 2001, p. 100-110 Jong, G. de; A UML-Based Design Methodology for Real-Time and Embedded Systems. In: Design, Automation and Test in Europe Conference and Exhibition DATE'02, Paris, France, Mar. 2002. Mattos, J. C. B.; Brisolara, L.; Hentschke, R.; Carro, L.; Wagner, F. Design Space Exploration with Automatic Generation of IP-based Embedded Software. In: Proceedings of the IFIP Working Conference on Distributed and Parallel Embedded Systems (DIPES 2004), Toulouse, France, 2004. p.237-246. Nebel, W.; Oppenheimer, F.; Schumacher, G. ObjectOriented Specification and Design of Embedded Hard Real-Time Systems. In: International Conference on Chip Design Automation. Luxemburg, 2000, p. 285-296. OMG (2003). UML Profile for Performance, Schedulability, and Time. OMG document available in http://www.omg.org/technology/documents/formal/ schedulability.htm. Wehrmeister, M.A., Becker, L.B., Pereira, C.E. Optimizing Real-Time Embedded Systems Development Using a RTSJ-based API. In: Workshop On Java Technologies For Real-Time And Embedded Systems. Lecture Notes in Computer Science 3292, Springer-Verlag Heidelberg, 2004, pp 292-302. De Micheli, G.; Benini, L. Networks-on-Chip: A New Paradigm for Systems-on-Chip Design. In: Design, Automation and Test in Europe Conference and Exhibition - DATE'02, Paris, France, Mar. 2002.