1 Department of Information Technology, Technical University of Denmark2 System-on-Chip Hardware, Department of Informatics and Mathematical Modeling, Technical University of Denmark3 Department of Informatics and Mathematical Modeling, Technical University of Denmark4 Department of Applied Mathematics and Computer Science, Technical University of Denmark
In this dissertation I present my thesis: A high-level type system is a good aid for developing signal processing programs in handwritten Digital Signal Processor (DSP) assembler code. The problem behind the thesis is that it if often necessary to programing software for embedded systems in assembler language. However, programming in assembler causes numerous problems, such as memory corruption, for instance. To test the thesis I define a model assembler language called Featherweight DSP which captures some of the essential features of a real custom DSP used in the industrial partner's digital hearing aids. I present a baseline type system which is the type system of DTAL adapted to Featherweight DSP. I then explain two classes of programs that uncovers some shortcomings of the baseline type systesm. The classes of problematic programs are exemplified by a procedure that initialises an array for reuse, and a procedure that computes point-wise vector multiplication. The latter uses a common idiom of prefetching memory resulting in out-of-bounds reading from memory. I present two extensions to the baseline type system: The first extension is a simple modification of some type rules to allow out-ofbounds reading from memory. The second extension is based on two major modifications of the baseline type system: • Abandoning the type-invariance principle of memory locations and using a variation of alias types instead. • Introducing aggregate types, making it possible to have different views of a block of memory, thus enabling type checking of programs that directly manage and reuse memory. I show that both the baseline type system and the extended type system can be used to give type annotations to handwritten DSP assembler code, and that these annotations precisely and succinctly describe the requirements of a procedure. I implement a proof-of-concept type checker for both the baseline type system and the extensions. I get good performance results on a small benchmark suite of programs representative of handwritten DSP assembler code. These empirical results are encouraging and strongly suggest that it is possible to build a robust implementation of the type checker which is fast enough to be called every time the compiler is called, and thus can be an integrated part of the development process.