分类: 项目管理
2012-04-10 09:59:34
High level software design, also called software architecture is the first step to analyze and consider all requirements for a software and attempt to define a structure which is able to fullfill them. For this also the non-functional requirements have to be considered, such as scalability, portability and maintainability. This first design step has to be more or less independent of a programming language. This is not always 100% possible, but a good high level design can be further refined into a low level design, which then describes the implementation in any desired programming language.
The Architecture
The first step in designing software is to define the architecture. Simply speaking this is a very high level outline of the components and layers of a software. There may be some requirements which explicitly ask for some of the below named features, but even if there are no explicit requirements it is a good design style to adhere to these principles:
1. | Design layers which at least make the functional part of the software independent of a hardware platform. Any specialities which have to be covered when running on a certain platform have to be in a special hardware abstraction layer. |
2. | Design an adaptation layer to adapt to a special operating system (if necessary). Operating systems may offer services and semaphores, but never use them directly in your functional software. Define your own services and semaphores and go through an adaptation layer to adapt them to the operating system services. |
3. | Design any additional layers inside your functional software as appropriate. |
4. | Design components inside your functional software. Depending on your requirements and future strategies it may be wise to e.g. design communication protocol components in a way that they can be easiliy removed and replaced by another protocol, to adapt to different platforms and systems. E.g. in the automotive industry the CAN bus is widely used for communication between the various electronic systems in a vehicle. However some customers require different proprietary protocols. Your software can be designed in a way to modify the protocols easiliy. Almost as easy as "plug and play", if the design is done properly. |
5. | Design an own framework which controls the calls and interactions of your functional software. |
Of course this was only a very rough outline of how an architecture may look like and what we found to be the best way for many applications. However, your own system may require some additional features of the architecture.
Object Orientation
Object orientation is nowadays usually assiciated with certain design methods like UML and programming languages like C++ or Java. However the principles of object orientation were developed long before these methods and programming languages were invented. The first steps of object oriented design were done by using C. And indeed object orientation is a principle of design rather than a tool or method based feature. Some of these principles are:
1. | Orientation of program components at the real physical world. This means that the division of a software package is done according to the real outside world of a system and according to main internal tasks of such a system. |
2. | Combining of all elements of a software (i.e. data, definitions and procedures) into an object. This means that everything that is needed to handle an element of the system is grouped and contained in one object. |
2. | Access to the object's data and functions via a clearly defined narrow interface and encapsulation of elements which are not required for the outside world to be hidden in the object. Example: |
Interfaces
The design of your interfaces is another element which adds to the stability, portability and maintainability of your software. The following things have to be observed:
|
More details will be given in the description of low level design related to the programming language C.
Operating Systems and Timing
Basically there are two categories of microcontroller systems. The first one is EVENT driven, as e.g. cell phones and other modern communication equipment.
The other kind of application is TIME driven. These microcontroller systems usually have the task to measure and evaluate signals and react on this information accordingly. This measuring activity means that signal sampling has to be performed. Additionally there may be activities like feedback current controls which have to be performed. Both activities imply by the underlying theories that sample frequencies have to be as exact as possible.
Both categories of systems are called REALTIME SYSTEMS, but they are like two different worlds!
The EVENT driven systems are comparatively simple. The are usually in an idle state until one of the defined events triggers a task or process, which is executed sequentially until it is finished and the system returns to the idle state. During the execution of such a task these systems usually do not react on other events. This "first comes first serves" principle e.g. can be seen in a cell phone, where incomming calls are ignored after you started to dial an outgoing call.
TIME driven system are much more complicated. Usually all possible inputs to the system have to be sampled and all outputs have to be served virtually simultaneously. This means that time slices have to be granted to the various activities and their duration has to be defined and limited to ensure the overall function of the system.
It would be too much to go into more details here. However there are some general rules which should be considered:
|
A Word about Modern Design Methods and Tools
Most of our ideas concerning high level design were outlined above. To some this may look outdated, because there are so many design tools around which promisse to make life easy. However there are a few things we want to point out concerning modern high level design methods and tools.
There would be a lot to say about modern design methods, such as UML, SDL and others. But there are a lot of good web-sites which specialized on this. Tools are available which allow high level design in one of these methods and even make an automatic code generation. Praises are sung that these 4th level "programming languages" will be the future way of designing software and leave the skill of coding to an automatic code export triggered by a simple hit on a button. There are certainly applications where this makes sense and where this is a sensible way to go, as e.g. the use of such a tool (SCADE) for the programs in nuclear power plants. But does this also make sense for high volume microcontroller applications? There are a few stumbling blocks for this which may not cleared away so easily in near future:
|
Some of these design methods and tools may be justified in appropriate environments, but the conclusion and our recommendation for high volume microcontroller systems is:
|