AG VLSI Design and Architecture

SFB 501 - Project D1: Application System "Buildings"

PSiGene

Pattern Code Generator

[PSiGene]



Description

The pattern code generator is a Smalltalk program (written in VisualWorks) capable of generating the complete source code for a building simulator. It uses the class model of the simulation model and the pattern bindings defining the simulators functionality as input.

All patterns provided by the catalog are realized within PSiGene as VisualWorks classes. This implementation ignores the informal parts of the pattern description (e.g. Intent) and emphasizes the Participants as well as the Implementation part. The implemented patterns are descendants of a common superclass AbstractPattern. This class provides the protocol needed to bind patterns, to generate code, and to create error reports for the user.

The following figure (figure 1) shows a small example of how code generation usually is done in PSiGene. Input to PSiGene is a simple class model consisting of a class Room that aggregates several Radiators. Each Radiator has a method q to calculate the heatflow affecting its surroundings (here: the room in which the radiator is located). To this class model the pattern FollowRelationAndSum is bound. The purpose of this binding is to follow the radiators relation in order to collect and sum up the heat flows from all radiators in a certain room.
Part of the pattern FollowRelationAndSum is shown on the upper right corner of figure 1. The pattern has two code templates to generate a method that traverses a relation and sums up values from adjoining objects. One of these two templates is used during the code generation depending on the cardinality of the relation that should be traversed (If the relation radiators would have been of cardinality 1:1 different code than shown in the example would have generated .).

fig. 1

Figure 1

The generation of simulation code is divided into two phases, which are performed automatically, without manual intervention:

The implemented patterns are structured as shown in figure 2:

PSiGene classes

Figure 2

Each pattern class is inherited from a common superclass AbstractPattern. A unique generation method may exist for every pattern class so that various code synthesis techniques could be used. However, to generate code simply by macro replacement, the inherited methods from AbstractPattern can be used. This text shows the complete (Smalltalk-) source code from our pattern FollowRelation. The pattern class for FollowRelationAndSum inherits from FollowRelation and only replaces the code templates (see source code).


Table of Contents PSiGene