# Review Graph Programming Code - 2023.1 English

## Vitis Tutorials: AI Engine Development

Document ID
XD100
Release Date
2023-10-03
Version
2023.1 English
1. Examine the header file, `aie/dds.h`, of the sine kernel (DDS):

```void sine(const int32 phase_increment,output_buffer<cint16,extents<128>> & owin);
```

Now examine `aie/kernels/dds.cc`, and notice how `phase_increment` is used in the sine function:

```phase_in += (phase_increment << 6);
auto [sin_,cos_] = aie::sincos(phase_in << 14) ; // phase_in + (7i + j + 1) * phase_increment
cint16 scvalues={cos_,sin_};
```
2. Examine `aie/graph.h` and `aie/graph.cpp`. These are provided as a starting point to specify the data flow graph used in this example.

In `graph.h`, the kernel object `dds`, the graph input port `trigger`, and the graph output port `out` are declared in the `ddsgraph class`. The DDS kernel object is bound to the `sine` function declared in the included `dds.h` header. The DDS kernel output is connected to the graph output. It tells the compiler that the source for the function is in `kernels/dds.cc`. The kernel output is connected to `out.in[0]`, which will be directed to `data/output.txt`.

```out = adf::output_plio::create("Dataout", adf::plio_32_bits, "data/output.txt");
In `graph.cpp`, an instance of the `ddsgraph`, `gr`, is instantiated.
In the `main()` function, graph `init()`, `run()`, and `end()` are called to initialize, run, and wait to be ended.
```gr.init();
The graph `run()` has been called with the parameter `4` to specify the iteration number of the graph. Otherwise, it will run forever.