# `EHLS.Runtime`
[🔗](https://github.com/elixir-hls/elixir-hls/blob/v0.1.0/lib/ehls/backend.ex#L175)

A runtime backend: what the generated functions call on the CPU to use the hardware.

The generated code calls `module()`: `pipe_enable(pipeline, on)`, `level_start(level, pipeline, words)`,
`peek(stage, words)`, `mem_read(stage, addr, count)`, an instance's CPU ends `end_send/5`, `end_request/5`, `end_cancel/1`, `end_push/3`,
`pack(list, layout)` and `unpack(binary, layout)` (as `EHLS.pack/2` and `EHLS.unpack/2`), and block
packages `reg_read(reg)`, `reg_write(reg, value)` (`c:EHLS.Blocks.registers/0`), with indices
from the generated module `:hw_kernels` that `generate/1` writes (`runtime/0` there names
`module()`, `reg/2` and `data/2` serve the packages). The behaviour assumes no
particular VM: a call may block, be served by a process or go through Linux.

# `generate`

```elixir
@callback generate(out :: Path.t()) :: :ok
```

Writes what the application needs at run time (e.g. `<out>/gen/hw_kernels.erl`) from `<out>/hw`.

# `generate_nif`
*optional* 

```elixir
@callback generate_nif(out :: Path.t()) :: :ok
```

For `--target cpu`: writes the NIF kernels' table and index (e.g. `<out>/gen/ehls_nif_kernels.c`) from `<out>/cpu`.

# `module`

```elixir
@callback module() :: module()
```

The module the generated functions call.

# `name`

```elixir
@callback name() :: atom()
```

The short name (`EHLS_RUNTIME`).

# `socs`

```elixir
@callback socs() :: [atom()]
```

The SoC backends it works with (their names); `[]`: any.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
