Skip to content
js216Public

About

Open-Source Toolchain for SHARC+ DSP

Resources

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

Selache: Open-Source Toolchain for SHARC+ DSP

Core toolchain:

  • selas: SHARC+ assembler
  • selcc: C99 compiler
  • seld: LDF-driven linker with processor memory model
  • selload: generate SHARC+ boot stream (LDR) from ELF

Libraries:

  • libsel: C library: string, math, stdlib, ctype, stdio, signal
  • selelf: ELF/archive parsing and writing
  • selinstr: SHARC+ instruction encoder, disassembler, VISA packing

Utilities:

  • selar: ELF archive tool for static libraries (.dlb)
  • seldump: dump ELF headers, symbols, relocations, code, archives
  • selhex: convert Intel HEX32 to Motorola S-record
  • selpatch: extract or replace raw section content in ELF
  • selsyms: print global/weak symbols as LDF RESOLVE() lines
  • selsim: run a linked executable on the host, UART0 to stdout

Getting Started

Build all tools and add to path:

cargo build --release
export PATH="$PWD/target/release:$PATH"

Example workflow:

selcc -proc ADSP-21569 -c -o main.doj main.c
selas -proc ADSP-21569 -o start.doj start.asm
seld -proc ADSP-21569 -T app.ldf -o app.dxe main.doj start.doj
selload -proc ADSP-21569 -o app.ldr app.dxe

Additions to C99

  • #pragma section("seg"): place the next object or function in seg
  • #pragma pack(N), (), (push, N), (pop): cap member alignment
  • __attribute__((aligned(N), noinline)); others ignored
  • aligned places a file-scope object
  • asm volatile ("insn" : out : in : clobbers): GNU inline assembly
  • _Static_assert(expr, "msg"): C11's, at file and block scope
  • __builtin_offsetof: as in GNU C
  • __builtin_circptr(p, inc, base, len): step p in a circular buffer
  • __builtin_clipf: the ALU's CLIP instruction
  • __builtin_copysignf/fminf/fmaxf: as C has them, NaN included
  • __SELACHE__: predefined by selcc
  • <selbss.h>: __sel_zero_bss() zeroes what the boot leaves out
  • __builtin_ names libsel's headers expand to: va_start_sel, complex_i, nanf, inff, huge_val/f/l, and one per <math.h> classification or comparison macro

Implementation-defined

  • 3.10: a diagnostic is a selcc: ... error: ... line and exit status 1
  • 4: freestanding; of the complex types (4p6) only float _Complex
  • 5.2.4.1: an object holds at most 16 MiB, an array 2^24 elements
  • 5.1.1.2: source files are UTF-8; phase 3 keeps white space
  • 5.1.2.1: startup calls main(void) with argc 0 and argv null
  • 5.1.2.1: termination halts the core; main returning skips atexit
  • 5.1.2.3: no interactive devices
  • 6.4.2: identifiers may use UCNs, or UTF-8 for the same name; all count
  • 3.6: 8-bit bytes
  • 5.1.1.2, 5.2.1, 5.2.2, 6.4.4.4: ASCII; characters keep their codes
  • 6.2.5: plain char behaves as signed char and holds a character's byte
  • 6.4.4.4: 'abc' is 0x616263, an int of the last four; L'ab' is L'b'
  • 6.4.4.4, 6.4.5: "C" locale; a wide character is its code point
  • 6.4.5: a UCN above U+00FF in a narrow string is its UTF-8 bytes
  • 6.2.5: no extended integer types
  • 6.2.6.2: two's complement; the pattern of INT_MIN is no trap
  • 6.3.1.3: conversion to a narrower signed type wraps modulo 2^N
  • 6.5: bitwise operators act on two's complement bits; >> keeps sign
  • 5.2.4.2.2: +, -, *, / round to nearest
  • 5.2.4.2.2: subnormal operands are zero; so are results, once rounded
  • 5.2.4.2.2: a double below FLT_MIN converts to a float zero, unrounded
  • 5.2.4.2.2: double +, - lose bits 54 places past the larger's last
  • 6.3.1.4, 6.3.1.5, 6.4.4.2: to nearest, ties to even
  • 6.5: no contraction
  • 7.6.1, 7.12.2: FENV_ACCESS and FP_CONTRACT are OFF
  • 7.6, 7.12: no extra exceptions, modes, environments or classes
  • 6.3.2.3: pointer to integer and back keeps the 32 bits
  • 6.5.6: ptrdiff_t is int
  • 6.7.1, 6.7.4: register and inline change no code
  • 6.7.2.1: plain int bit-fields are signed; any integer or enum type
  • 6.7.2.1: long long bit-fields have at most 32 bits, may cross a word
  • 6.7.2.1: other bit-fields never straddle; allocated from the low bit
  • 6.7.2.1: scalar members are aligned to their size, at most 4
  • 6.7.2.2: enum types are int
  • 6.7.3: each volatile read or write in the source is an access
  • 6.4.7: no header names in #pragma
  • 6.10.2: <> searches the built-in headers, then -I directories
  • 6.10.2: "" searches the includer's directory, -I, then built-in
  • 6.4.7, 6.10.2: macro tokens join as spelt; nesting stops at 200
  • 6.10.1: #if character constants are as at run time
  • 6.10.3.2: # inserts no \ before a UCN
  • 6.10.6: #pragma section, pack; others ignored
  • 6.10.8: __DATE__ and __TIME__ are always available
  • 7.17: NULL is ((void *)0)
  • 5.2.4.2, 7.18.2, 7.18.3: in libsel/include
  • 6.2.6.1: short 2 bytes; int, long, float, pointers 4; others 8
  • 6.2.6.1: the least significant byte comes first
  • 6.5.3.4: size_t is unsigned int
  • J.4: "C" locale only; decimal point .

Legal

Author: Jakob Kastelic (Stanford Research Systems, Inc.).

The toolchain (selcc, selas, seld, and all other tools) is licensed under the GNU General Public License, version 3. The runtime library (libsel) is licensed under the MIT License, so binaries compiled with selcc may be distributed under any license, including proprietary ones.

SHARC and SHARC+ are trademarks of Analog Devices. This project is not affiliated with or endorsed by Analog Devices.

About

Open-Source Toolchain for SHARC+ DSP

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages