//------------------------------------------
// Classic "Hello World!" program:
// - A simulated console is used,
// or a serial port on the FPGA
// - The console is accessed using ports
// "stdin" and "stdout" with "stdio"
// functions: getchar() and puts().
//------------------------------------------
// ---- Component with ports
component CHelloWorld(
in active ubyte stdin,
out active ubyte stdout
)
{
// ---- Constant string
const string cHelloWorld = "Hello World!\n";
// ---- Working RW memory
string sHelloWorld[16]
// ---- 4 bits index
uint:4 i;
// ----- setup() function, executed once
setup()
{
// Copy constant string to memory
i = 0;
while(cHelloWorld[i] != 0 )
{
sHelloWorld[i] = cHelloWorld[i];
i++;
}
sHelloWorld[i] = 0;
}
// ----- loop() function
loop()
{
// Type any char to start
call getchar();
// Call stdio "puts()" as in C++
call puts(sHelloWorld);
// loops forever, like processes do
}
}