1 / 75

Koala component model

Koala component model. Maarten Pennings MG-R course day 2 am. Contents. Koala supports the following concepts: why component model components interfaces modules binding. 1. Concepts 2. The Basic Model 3. More on Interfaces 4. Function Binding 5. Optional Interfaces 6. Switches.

mirari
Download Presentation

Koala component model

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Koala component model Maarten Pennings MG-R course day 2 am Koala Workshop

  2. Contents • Koala supports the following concepts: • why component model • components • interfaces • modules • binding 1. Concepts 2. The Basic Model 3. More on Interfaces 4. Function Binding 5. Optional Interfaces 6. Switches Koala Workshop

  3. Concepts Why component model • Product familyin one LoB: 100 products in 5 years • Software size explosionabout factor 2 every 2 years • Product features overlapin multiple LoB similar software • Diversitymany small differences in hardware and user interface • Distributed developmentdifferent LoB’s, research, software lab Koala Workshop

  4. 2003 2002 2001 2000 1999 1998 Concepts Product family • MG98 is a product familywith 100 product types over 5 years • MG98 is a main stream productcost optimisation is important Cost effective component model Koala Workshop

  5. Concepts Software size explosion GFL 93 100 in 1000 lines of source code MID2 95 200 MID98 97 450 MID98+ 99 600 Share components between products Koala Workshop

  6. Concepts Feature overlap LoB’s time Share components between LOB’s Koala Workshop

  7. Concepts Product diversity (overview) • Many typesaround 50 from 24” till 38” • Many sets1 000 000 pieces (at $1000) • Many countries27 languages, 38 Approbation organisations • Many standards3 voltages, 11 power plugs, 13 frequency standards, 9 sound standards, 22 connector types, 10 TXT standards Koala Workshop

  8. Concepts Product diversity (features) • Screen4x3/16x9/Shift/PIP/DualScreen/Mosaic/Freeze/Zoom/Replay/Photofinish • SoundMono/Stereo/Dolby/Equalizer/SmartSound/Cordless/Surround • ChannelsACI/ATS/GiveName/Favourite • ModesTV/VCR/Demo/Cable/Web/DVD/Satellite • ProgramGuidesEPG:day,channel,theme/VPS,PDC/DualScreen/EasyLink/Lock • GraphicsOSD/TXT/ChineseTXT/GemStart Components should be easy to tweak Koala Workshop

  9. Concepts Distributed development • Eindhoven NatLabarchitectural concepts • BriarcliffDigital TV • Bruggehigh-end TV europe • Eindhoven ASA labFlat TV / component factory • Bangalorecomponent factory • Singaporebasic TV Components are developedat different sites Koala Workshop

  10. Concepts Component model multi systemcomposition single systemdecomposition Koala Workshop

  11. Concepts Koala’s Concepts A component is a unit of encapsulation. An interface is a small and coherentset of functions. A module is a unit of code. A binding is a connection between interfaces. Koala Workshop

  12. Concepts Components A component is a piece of software that is non trivial in size (an asset to the company), but that does not contain any configuration specific information. A component provides and requires interfaces, and can interact through these interfaces only. MS-COM allows for WIN32 calls Koala Workshop

  13. Concepts Interfaces We treat interfaces as first class citizens. • interfaces are unidirectional; • each interface has a definition; • Interface definitions are units of reuse. • an interface definition is always shared between a ‘provider’ and a ‘requirer’; • variants of components may provide or require the same interfaces. --- --- --- Koala Workshop

  14. m1 m2 Concepts Modules For Koala, a module is a hand-written C file and a generated header file. • not all modules in a component need to be declared to Koala; • header files for undeclared modules must be hand written (of course); • communication between modules within a component is completely free; • communication with the environment must go through interfaces. m3 Koala Workshop

  15. Concepts Compound Components A group of components can be seen as a component again... C3 This allows us to create reusable subsystems (or standard designs). A subcomponent in a compound component is a copy (instance) of a reusable component (type). s1:C1 s2:C2 r1 p3 Koala Workshop

  16. Concepts Configurations • Definitions: • a basic component is a component without subcomponents; • a compound component is a component with one or more subcomponents; • a configuration is a component without provides and requires interfaces, a top-level component. C3 s1:C1 M1 M2 s2:C2 Koala Workshop

  17. Concepts Koala workspace C C1 c1.cd m.c C2 c2.cd m.c C3 c3.cd I I1.id I2.id D global.dd enums.dd workspace C C1 c1.cd m.c c1.c m.h C2 c2.cd m.c c2.c m.h C3 c3.cd c3.c I I1.id I2.id D global.h enums.h Koala loads the three kinds of definitions, and writesh files for module andc files for components koala -pcr C -pir I -ptr D C3 Koala Workshop

  18. Concepts Naming Before we proceed, let’s discuss naming: • a component has a globally unique long name and short name (prefix) • each interface has a local name unique to the component • each interface is associated with an interface definition • Note that two or more interfaces in a single component may have the same definition! ntf:IFoundNotify pow:IPower tun:ITuner tvttu:CTvTerrestrialTuner drv:ITunerDriver hnd:IFoundNotify nvm:INonVolatile Koala Workshop

  19. Basic 2. The Basic Model 1. Concepts 2. The Basic Model 3. More on Interfaces 4. Function Binding 5. Optional Interfaces 6. Switches Koala supports three ‘languages’: • DD: data type definitions • ID: interface definitions • CD: component definitions Koala Workshop

  20. Languages • CD - Component definitiondescribes components referring to component definitions and interface definitions • ID - Interface definitiondescribes function prototypes and constants referring to datatype definitions • DD - Datatype definitiondescribes datatypes referring to other datatypes Koala Workshop

  21. Basic DD An datatype definition declares a datatype that is used for typing parameters in functions (occurring in interfaces) Ordinary C header file with machine readable comments embedded DD typedef char Int8; /** koalatype Int8 **/ typedef char Bool; /** koalatype Bool **/ Koala Workshop

  22. Basic * DD - rules header file with datatype definitions only Normal C type declarations machinereadable comments /* file: SoundTypes.dd *//** koalagroup Sound **/ typedef Int8 Volume; /** koalatype Volume **/ /** koalausing Int8 **/ typedef Bool Mute; /** koalatype Mute **/ /** koalausing Bool **/ datatype file is assigned a namefor others to use Datatype name must be globally unique Datatypes may bebased on others Koala Workshop

  23. Basic ID An interface definition describes the syntax and semantics of a small set of functions: Syntax: names and types of functions and arguments. Semantics: a (simple) logical model of the behaviour. Interfaces consist of constants and functions only (nullary functions are called parameters). ID interface ISoundControl // sdc { void SetVolume(Volume v); void SetTreble(Treble b); } Koala Workshop

  24. Basic * ID - rules Interface definition name must be globally unique Parameter list may be void ... Result type must be void or simpleO …or must consist of typed and named parameters. interface I{void f(void); int g(int x, int y); int* h(Volume x, Volume * y); int j(char ROM * s);} Parameter names must be unique per function Function names must be unique per interface Osimple type = - datatype - datatype * - datatype tag * Datatype must be known to Koala Parameter type must be simpleO Koala Workshop

  25. Basic * ID - rules Nullary functions do need void... … or they drop the parenthesis interface I{ int f0( void ); int f1; int f2 = 3; int f3(x) = x + I.f2 + I.f1; } Nullary functions are called parameters or properties Constants may be defined Functions may refer to other functions in this interface Koala Workshop

  26. p1:Ia p2:Ia p3:Ib C1 r1:Ib r2:Ic r3:Ic Basic CD In a component definition, the interfaces provided and required by the component can be described. CD A component is implemented as a set of C and H files. It is preferred to have a directory per component. Part of the internal structure is also described to Koala. component C1 {provides Ia p1; ...requires Ib r1; ...} Koala Workshop

  27. p1:Ia p2:Ia p3:Ib C1 r1:Ib r2:Ic r3:Ic Basic * CD - rules Component name must be globally unique Interface names must be unique per component There may be multiple sections in any order (not recommended) component C1 {provides Ia p1, p2; Ib p3;requires Ib r1; Ic r2, r3;} Interface definitions must be known to Koala Koala Workshop

  28. Basic Binding Interfaces must be boundtip to base: component C1 {requires I r;} interface I {void f(void);void g(int x);} s1:C1 CD r:I containscomponent C1 s1;component C2 s2;connects s1.r = s2.p; component C2 {provides I p;} p:I s2:C2 Note that components get a local name here... Koala Workshop

  29. Basic Gluing ‘Glue code’ may be inserted in a binding in the form of a module... s1:C1 containscomponent C1 s1;component C2 s2;module m;connects s1.r = m; m = s2.p; • the header file of m is generated; • the C file of m is hand written. r:I m This allows to fine tune components at the level of configurations. p:I s2:C2 Koala Workshop

  30. Basic * CD - rules Definitions must be known to Koala Names must be locally unique p C1 p component C1 {provides I p;requires I r;containscomponent C s;module m;connects p = s.p; s.r = m; m = r;} S:C r Sections may be in any order (not recommended) m r Must be a base interface or a module Must be a tip interface or a module Every tip interface must be bound Every base interface may be bound zero or more times Koala Workshop

  31. Basic * Function names mustdefine p p_f Compprefix pr s1:C1 s1_rr_f rr m mayuse f pp s2_pp_f pr_f s2:C2 r_f r Koala Workshop

  32. Example /* Koala generated: m1.h */ #define r_Func C__p_func externvoid C__p_Func(int x); /* file: m1.c */ #include “m1.h” void SomeFunc(void){r_Func(54);} m1 r Koala generated handcrafted No runtime nor size penalty! p /* Koala generated: m2.h */ #define p_Func C__p_func externvoid C__p_Func(int x); /* file: m2.c */ #include “m2.h” void p_Func(int x){… x … ;} C m2 Koala Workshop

  33. Basic * Name mangling by binding p pr__p_f p_f Compprefix pr Physicalnames Logicalnames s1:C1 pr__s1_rr_f s1_rr_f rr m pp ?__?_f s2_pp_f s2:C2 This is not pp! ?__?_f r_f r Koala Workshop

  34. Basic Example tun:ITuner /* file: tvttu_m.c */ #include “_tvttu_m.h” voidtun_StartSearch(void){s1_snd_SetOutput(0);tdr_StartSearch(54);}voidf_fin_GoUp(void) { ... } You write: CTvTerrestrialTuner prefix tvttu f:CFineTuner Koala generates: fin m /* file: _tvttu_m.h */ #definetun_StartSearch tvttu__tun_StartSearch #definef_fin_GoUptvttu__f_fin_GoUp externvoid tvttu__tun_StartSearch(void); externvoid tvttu__f_fin_GoUp(void); #defines1_snd_SetOutput ??? #definetdr_StartSearch ??? externvoid s1_snd_SetOutput(int vol); externvoid tdr_StartSearch(int freq); snd s1:CSwitch tdr:ITunerDriver Koala Workshop

  35. Basic * CD - rules component C1 {specialsprefix “c”;library; :uses infrartk; :} Specifies that component is available as library Specifiesshortnameof component If you need accessto data types thatare not availablethrough usedinterfaces Koala Workshop

  36. Exercise Hello, MG-R! Koala Workshop

  37. More 3. More on Interfaces 1. Concepts 2. The Basic Model 3.More on Interfaces 4. Function Binding 5. Optional Interfaces 6. Switches • We discuss • private interfaces • interface compatibility Koala Workshop

  38. More Interface Chains • binding = connecting modules to interfaces to interfaces to modules. • components only serve as scope restrictors during the binding. • each tip should be connected to precisely one base or module; • each base may be connected to zero or more tips or modules; • modules cannot be bound to modules (un-typed lined)! Koala Workshop

  39. More Implementing Components p1 p2 p3 p4 p5 • An example implementation of a component: • m1 implements p1 in terms of r1; • m2 and m3communicate by themselves; • m4 and m5 communicate through private interfaces. C1 i1 m2 m4 m1 i2 m3 m5 r1 r2 r3 r4 r5 Koala Workshop

  40. m1 m2 More * CD - private interfaces definition must be known to Koala names must be locally unique p C component C {provides I p;requires I r;containsinterface I i;module m1, m2;connects p = m1; m1 = i; i = m2; m2 = r;} i sections may be in any order (not recommended) r is bound by the base here is bound by the tip here the tip must be bound once the base may be bound zero or more times Koala Workshop

  41. More Interface Compatibility Once defined, an interface definition may not be changed any more…(unless all components referring to the definition are changed simultaneously) but it is allowed to define new interfaces that are supersets (or subsets) of old interfaces. Koala allows to connect such new interfaces to the old interfaces. Koala Workshop

  42. More Compatibility Rules Rule: a tip may be connected to any base, if for every function in the tip interface there is a function in the base interface with: • the same function name • the same result type • the same parameter list, where each formal parameter has: • the same name • the same type Koala Workshop

  43. Ca Ca Cb I I I+ I I+ I+ C1 C2 C2 More Illustration The pictures show how old and new interfaces may be connected. interface I {void f(int x);void g(int y); } Cb I+ I C1 interface I+ {void h(int z);void g(int y);void f(int x); } Koala Workshop

  44. a:I1 a:I2 b:I2 b:I1 a:I1 a:I3 b:I3 b:I1 a:I1 a:I4 b:I4 b:I1 a:I1 b:I2 c:I3 Exercise: more on interfaces interface I1 { int f(int x, int y); void g(char c);} 1 2 interface I2 { void g(char c); int f(int x, int y);} 3 4 interface I3 { void g(char c); int h(void); int f(int x, int y);} 5 6 7 8 interface I4 { int f(int x, int y); void g(char ch);} b:I2 a:I1 c:I3 Your assignment Which of 1..8 are ok? Koala Workshop

  45. a:I1 a:I2 b:I2 b:I1 a:I1 a:I3 b:I3 b:I1 a:I1 a:I4 b:I4 b:I1 a:I1 b:I2 c:I3 Answer: more on interfaces ü ü interface I1 { int f(int x, int y); void g(char c);} 1 2 I1=I2 I1=I2 û ü interface I2 { void g(char c); int f(int x, int y);} I3ËI1no h 3 4 I1ÍI3 û û interface I3 { void g(char c); int h(void); int f(int x, int y);} 5 6 I1ËI4g(c)¹g(ch) I4ËI1g(c)¹g(ch) û ü 7 I1ÍI3, I2ÍI3 8 down split interface I4 { int f(int x, int y); void g(char ch);} b:I2 a:I1 c:I3 Koala Workshop

  46. FuBi 4. Function Binding 1. Concepts 2. The Basic Model 3. More on Interfaces 4. Function Binding 5. Optional Interfaces 6. Switches • We discuss • diversity interfaces • Koala expressions • in-line expressions • constant folding Koala Workshop

  47. m FuBi Implementing Functions Rule: every function in every interface that is connected with the tip to a module should be implemented by that module. • Implementation can be: • either in C • or in Koala • The latter is sometimes called function binding; its main purpose is to support diversity. Koala Workshop

  48. FuBi Diversity Interfaces Component diversity may be controlled through diversity interfaces. • These are requires interfaces, allowing us to: • assign values to diversity parameters using the binding mechanism; • delay static/dynamic decision • optimise on certain constant values. connects s.d = m;within m { s.d.Flag()= true; } interface I{ Bool Flag();} d:I m s:C Koala Workshop

  49. FuBi Diversity Interfaces Diversity interfaces are not provided interfaces (using SetColor instead of required with Color) • hard to optimize away(now a #define suffices) • provided needs notification(propagate changes) • initialisation problems(when can a component use property) Koala Workshop

  50. FuBi Diversity Spreadsheet Compound components may have diversity interfaces as well. d The inner diversity interfaces may be expressed in terms of constants, functions and parameters in the outer diversity interface. This allows to use different ‘languages’ for diversity depending on the level of decomposition. Catch: re-evaluated every time m s:C d r connects s.d = m; m = d; m = r;within m { s.d.f()= ! d.f(); s.d.g()= - r.g(); } Koala Workshop

More Related