Directives¶
A C± program configures its processor with directives: lines starting with
#, at the top of the file, one per line. Each has a default, so a program
writes only what it changes. A C++ program says the same with
#pragma yanc <setting> <value> (see The C++ YANC accepts).
#NUBITS 32
#NUIOIN 2
#NUIOOU 1
#FROUND 2
Configuration¶
directive |
default |
sets |
C++ |
|---|---|---|---|
|
32 |
the word width, in bits: 2 to 32 |
|
|
23 |
the float’s mantissa bits |
|
|
8 |
the float’s exponent bits |
|
|
1 |
the number of input ports |
|
|
1 |
the number of output ports |
|
|
0 (C++: 2) |
how float operations round: 0, 1 or 2 (see Floating point) |
always 2 |
|
128 |
the divisor of |
(no effect) |
|
3 |
how many low bits of the index |
(C± only) |
|
worked out |
the data stack depth |
|
|
worked out |
the call stack depth |
|
#NUBITS = #NBMANT + #NBEXPO + 1(the sign bit), and#NBMANTbelow2^(#NBEXPO-1)(the exponent has to reach 1.0, which is2^(NBMANT-1) · 2^-(NBMANT-1)): the assembler stops when either fails, but only for a program that uses float. The defaults give 32 = 23 + 8 + 1; a 16-bit processor with float is, for example,#NUBITS 16,#NBMANT 10,#NBEXPO 5, and one without float needs only#NUBITS 16. YANC is maintained at 32 bits; narrower words work, wider ones are not supported.#NUGAINmust be a power of two.norm(x)isx / NUGAINin hardware: a power of two is a shift, any other value would be a divider on the processor’s critical path, so the compilers refuse it.The stacks are sized from the program when
#NDSTACand#SDEPTHare left out: as deep as the program goes, which is usually a few words. Give them only to reserve more. A stack that overflows in simulation shows on the waveform’sfl_fullsignal.The processor’s name is the source file’s: there is no directive for it (
#PRNAMEis an error since v7.1).
Markers¶
These two go inside a function, as statements, at most once each per program; each adds a pin to the processor.
directive |
pin |
does |
|---|---|---|
|
input |
while |
|
output |
|
#PRACA is a restart point, not an interrupt routine: nothing is saved,
there is no return to where the program was, and holding itr at 1 keeps
the processor on that point. #TOAQUI lets a testbench or other hardware
see that the program has reached a place, for example the end of an
initialisation.
Waveform¶
A variable the program writes and never reads is not in the processor: its
writes leave the program, it takes no data word, and it is not in the
waveform; the compiler warns of each one. #WAVE keeps such variables,
to see them in the waveform:
float y, t, e;
#WAVE t, e // never read: kept for the waveform
It names variables already declared, separated by commas: globals at the
top of the file, locals inside their function. It changes nothing for a
variable the program reads. A value the compiler takes from the accumulator,
without reading the variable back, does not count as a read: in
t = a[j]; e = t - y; nothing reads t. In C++ such a variable leaves
the program too, without a warning, and there is no #WAVE yet.
Constants¶
#define NAME text replaces the name by the text from that line on:
#define N 64. It has no arguments; there is no #include and no #if in
C± (C++ has the whole preprocessor).