2110496 Embedded processors 2006


Prabhas Chongstitvatana

Syllabus

lecture 3 hours per week,
Tue and Wed  Eng. Building 4  room M-07-4,  9-10:30am
tutorial   1 hour per week, 8-9am Tue in my office

I will offer a course that unify hardware and application software requirement for embedded systems.  This series of lecture aims to integrate the knowledge of building a computer system from the most bottom level: functional units, data path, microprogram, to the highest level: operating system, high level language and application programs.  An executable abstract language is used to as a mean to explore all levels. 

Announcement

The deadline for handin all homework is 12 October 2006, 4pm at my office box.  See Final Update Software.

What's New

22 June 2006   lecture on nut compiler and new nut31.zip package, howework week 3
29 June 2006   Runtime and the evaluator,   the sim-in-nut  (evaluator)
30 June 2006    Code generator, language extension
5 July 2006      Nut-compiler completion kit
7 July 2006       Code generator completion kit
14 July 2006     Nut completion kit source,  Code gen completion kit source
14 July 2006     Microprogramming,   SX-chip,  SX-microprogram,  Sx kit
1 Aug  2006      Stack frame caching,   Sx2-chip,   Sx2 kit
5 Aug 2006       S-code object to test inc/dec
8 Aug 2006        How to microprogram Sx
15 Aug 2006     Nut Operating System,   Noss  (Nut OS Supervisor)
17 Aug 2006     Sx-noss package, demonstrate 3 processes running concurrently
22 Aug 2006      Basic OS concept,   Nut  Operating System (updated)
29 Aug 2006      Optimisation  and codes     nos2 code
30 September 2006   Final update software:  sx1.zip    sx1-noss.zip   Note on optimisation
3 Oct 2006       Final update software:  sx2.zip   
This is the last update for this course.

Lecture

Weekly assignment

week 1)   Learning Nut
Write a program in NUT to do reversing elements in an array.  Try to compile and run it to see the result.  Observe the object code.  How the object code (in n-code) correspond to the source code?
week 2)  Nut compiler
2.1)  Write internal structures of your own simple program to understand n-code.
2.2)   To improve your skill in recursion, write and run a few simple recursive program in Nut (using nut3)
2.2)   Modify nut3 compiler:
2.2.1  Nut3 does not have the operator: mul, div.  Add it to the compiler and simulator (simulator is optional)
(hint:  at compiler, you should look at the following functions:
#define xMUL 8  in nut.h
add reserved word to keynames[]  in nut.c
prAtom()  in data.c
2.2.2   (optional, you need not do it, but it is a challenge) string in nut can be more efficient by packing 4 characters into one word.  Do it.
week 3) Language extension   For detailed discussion
3.1  Extend the nut-in-nut compiler to include "let" and "enum"
3.2   Write a function in nut compiler to output "linearise" vesion of object code, so that the object code will be locatable.
week 4)  Complete the compiler
4.1   Complete the nut-in-nut compiler
4.2    Study eval-in-nut (sim.txt)  and try to add some missing operators to it
week 5)  Code generator
5.1    Complete the code generator (using the code gen completion kit),   use  the package nut32.zip
5.2     Write some nut program and compile, generate s-code and run it using somv2
week 6)  Microprogramming
6.1    Compile and run Sx-kit 
6.2    Add the instruction "inc v" and "dec v"  to the Sx-chip via microprogram, measure its effectiveness.
         The object code to test inc/dec :   bubble   normal    with inc    listing of with inc
week 7)  Measuring performance
7.1 write 3 benchmark programs in nut: hanoi, matmul,  (bubble quick already existed in sx0 kit) run it under sx0-simulator to test the correctness. Here is the benchmark programs in Som language  hanoi    matmul  
7.2 modify the simulator to count the frequency of each instruction.  run the above benchmarks to find out the dynanic instruction count.
week 8)  Run Sx2, try to write a microprogram for some new instruction and test it.
8.1  Compare the performance with Sx1.
8.2  Discuss the finding, suggest some way to improve the performance (counting the total cycle used to complete a task) by
8.3  adding some new instruction
8.4  improving the microstep of some instruction
You don't have to simulate the execution.  You can calculate the number clock from the profile.
week 9)  Run Noss  (use nos0.zip package, including the update compiler and code generator for "run")
          9.1  Write some simple nut program.  Compile it with Nos.  Run it under NOSS
          9.2   Change the "quanta" (you must recompile Noss) then rerun your program. Observe the behaviour.
week 10)   Run Noss version 1  with semaphore
          10.1   Write a producer/consumer  using monitor, two processes communicate with a buffer of size 10.
           Compare the overhead with a buffer size 1.
          10.2    Write a timer service, you need to modify the noss.c
week 11)   Do some simple optimisation
          11.1    At the level of algorithm, change the symbol table access to use hash table (write at Nut level)
          11.2    Run the compiler benchmark with this new compiler.  Collect the profile and discuss the result.

Documents

Nut langauge manual
N-code manual
Discussion on language extension
s-code
Sx2 processor (draft)
Optimisation   ch9-12.pdf

Tools

NUT v 1.0 compiler and sinulator       readme
NUT v 3.0  compiler and simulator with source code in C
Nut-in-Nut compiler with nut31/nsim31 with source   (update 5 July, please update to use with nut-compiler completion kit)
sim-in-nut   the partial evaluator of n-code in Nut      The test file "t2.txt"
gen.txt   nut-som-codegenerator
Nut 32   (include nut-codegen and somv2 simulator)
Som v2 (for s-code simulator with source)
Sx kit  (with source)
Sx2 kit (with source)    readme
Nos version 0  package
Sx-noss package   integrate noss with sx, demonstrate 3 processes running concurrently, ns.obj is generate by new gen2.txt
new sx-noss package  (sx-noss1.zip)
Nos version 1  with semaphore
Nos2 (with send/receive)
optimisation package    readme   
tools for optimisation:   sx1p.zip   sx1-noss.zip 

Final updated software

1  Sx simulator package is updated ( sx1.zip )to the latest one (including a test object "qs.obj" in /test).  It runs in "monitor" mode.  Start with
  c:>sx1 qs.obj
then
  >g
(go).  You will see the program terminate with 4820 instructions executed.  You can generate a profile by editing the source "sx.c" to include outprof().  It will output a file "prof.txt" displaying the number of times a line is executed.

2  Sx-noss package is updated ( sx1-noss.zip ) it can task-switch with varying time quanta. (change TIMEOUT in sx.h). Run "noss ns2.obj".  ns2.obj is the producer/consumer benchmark. noss is sx1+noss.c.  It runs without monitor mode. You can also output a profile (see comment in note 1).

3  Sx2 simulator (sx2.zip) , resolved the global variable "clock". Now it works properly.  There are two example objects: bbs.obj  qs.obj (bubblesort and quicksort) in the directory sx2/test/.  These two objects are generated from other optimised code generator, not the one in this class. 

4  Chapter 9 of my textbook (optimisation) is uploaded.  ( ch9-12.pdf )

last update 3 Oct.  2006