Data Format - Data Format - 6.0 English - PG141

DDS Compiler LogiCORE IP Product Guide (PG141)

Document_ID
PG141
Release_Date
2024-12-11
Version
6.0 English

The DDS Compiler sine and cosine outputs are generated as unsigned integer or single precision float values that are cast to doubles on the interface. To restore the sign for printing to stdout or use outside the C model, you must either cast back to integer and scale accordingly for the integer output type, or cast back to float for the float output type. Because both sine and cosine can be a maximum of 26 bits wide (integer), casting to an int is sufficient. To scale the data, it is recommended that the data is shifted up by the difference between the width of an int (usually 32 bits) and the config.Output_Width C model parameter to set the sign bit correctly, then scaled down by the same value, maintaining the sign.

For example, for a 12-bit output, the scaling value is (32 - 12) = 20, and the correctly-signed sine output can be printed using the following code:

std::cout << "sine " << ((int)sine_output << 20) >> 20) << std::endl;

See the C model smoke test, run_bitacc_cmodel.c, for a generalized example.

The phase output from the C model can be up to 48 bits wide, and can be either signed or unsigned, depending on the configuration. See Output PHASE Channel for more details. In the general case, for a signed phase output, cast the double to a 64-bit integer type (for example, int64_t), and for an unsigned phase output, cast the double to an unsigned 64-bit integer type (for example, uint64_t).