1 / 13

Embedded Functional Programming in Hume

Embedded Functional Programming in Hume. Gergely Patai patai@iit.bme.hu Péter Hanák hanak@iit.bme.hu Budapest University of Technology and Economics Department of Control Engineering and Information Technology. Outline. Introducing Hume Example: lift control Example: light measurement

glyn
Télécharger la présentation

Embedded Functional Programming in Hume

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. Embedded Functional Programming in Hume Gergely Patai patai@iit.bme.hu Péter Hanák hanak@iit.bme.hu Budapest University of Technology and Economics Department of Control Engineering and Information Technology IASTED Software Engineering 2007, Innsbruck

  2. Outline • Introducing Hume • Example: lift control • Example: light measurement • Conclusions The Hume language is developed at University of St Andrewsand Heriot-Watt University in Scotlandwithin theEmBounded Project (IST-510255).http://www.hume-lang.orghttp://www.embounded.org IASTED Software Engineering 2007, Innsbruck

  3. Hume overview • An experimental functionally based language for embedded systems • Pure functions: no side effects • Inherently parallel • Visual program structure • Static space-time guarantees • Verifiable properties • Increased dependability • Viable on low-end platforms IASTED Software Engineering 2007, Innsbruck

  4. Hume example: counter program stream display to "std_out"; type integer = int 32; inc x = x+1; box counter in (n::integer) out (n’::integer, nout::integer) match n -> (inc n, n); wire counter (counter.n’ initially 0) (counter.n, display); Counter n n’ nout display IASTED Software Engineering 2007, Innsbruck

  5. Hume basics • Hume programs are ‘boxes’ connected with ‘wires’ • Wires: • are mailboxes that can hold one piece of data at a time • each connects strictly one output to one input • statically typed • Boxes: • map their inputs to their outputs with a pure function(combinational network) • the function consists of rules, exactly one of which is chosen by patternmatching on the input • if some outgoing wires needed by the rule are occupied,theresult is buffered until the wire is freed up by its consumer • Supersteps: global consume–produce cycles IASTED Software Engineering 2007, Innsbruck

  6. Execution alternatives • Source-level interpreter • HAM (Hume Abstract Machine) interpreter • Hume → HAM assembly compilation • Optional transformation to bytecode • Native code • HAM → C conversion (macro expansion) • Compiled with a C compiler, linked to a lightweight runtime system (RTS) • No endianness issues, no malloc, no threads IASTED Software Engineering 2007, Innsbruck

  7. Lift control • Task: single-shaft lift simulation • Hardware: mitmót • ARM7 (32-bit) @ 54MHz(Philips LPC2106) • 128k flash, 64k RAM • OS: eCos • User code: compiled to native code IASTED Software Engineering 2007, Innsbruck

  8. Lift control software state cache →user state’ cache’ C→ C← D→ D← state position →R ←R →D ←D Requests Cabin state’ position’ ↑clk R↑ R↓ enabled state Door ↑C ↓C clk← enabled’ state’ IASTED Software Engineering 2007, Innsbruck

  9. Light measurement • Task: remote measurement • Hardware: Tmote Sky • MSP430 (16-bit) @ 8MHz • 48k flash, 10k RAM • OS: Contiki with HAM interpreter • Stripped string and floating point support • Peripherals accessed as streams • User code: HAM bytecode loadable over the air IASTED Software Engineering 2007, Innsbruck

  10. Light measurement software State (init/alive/dead) Calibration(thresholds, speeds) Control Photo diode Speed control UDP packet Receiver Command Ack/Light ( Init, _*, _, *) -> (Alive, (200, 400, 50, 10), 50, *) | ( _, _*, _, Reset) -> ( Init, *, *, 0) | ( Dead, _*, _, _*) -> ( Dead, *, *, *) | (Alive, _*, _, Calibrate t1 t2 d1 d2) -> (Alive, (t1, t2, d1, d2), *, 1) | (Alive, (t1, t2, d1, d2), p, *) -> if p < t1 then (Alive, (t1, t2, d1, d2), d1, p) else if p < t2 then (Alive, (t1, t2, d1, d2), d2, p) else (Dead, *, *, *); IASTED Software Engineering 2007, Innsbruck

  11. Experiences • Short source code • Easy portability • Big native code (experimental compiler) • No significant speed loss with bytecode • Sufficiently fast for simple tasks • Great potentials for a future IDE IASTED Software Engineering 2007, Innsbruck

  12. Future work • Improving the Tmote Sky port of the interpreter • New resource-constrained applications on a variety of platforms • Developing and evaluating extensions and tools for the language • Further information: http://www.inf.bme.hu/fp4es IASTED Software Engineering 2007, Innsbruck

  13. Thank you for your attention! IASTED Software Engineering 2007, Innsbruck

More Related