# AR# 15254

|

## Description

The CORE Generator RAM\ROM coefficient file does not allow me to use negative numbers when I set the .coe file to the base-10 (decimal) format.

## Solution

CORE Generator 8.1i and earlier versions cannot properly parse COE files with negative numbers.

To work around this, convert the number into the twos complement, then use the decimal version of the twos-complement number.

For example

The number -10 in 7 bits is: (twos-complement)

1110110

If the format was not twos-complement, the value in decimal for the same binary numbers would be 54.

This is determined by the following formula:

2*2^(N-1) + original value = changed value.

This will give the correct decimal values needed to achieve the correct binary format.

When the output is assumed to be twos-complement, the intended negative decimal values will be correct.

The following script allows MATLAB to convert the .coe file:

function out = coe_create(t)

for (i=1:length(t))

if (t(i) < 0 )

t(i) = t(i) + (2* (2^11));

end

end

out = t;

This MATLAB script processes an array of values and produces the correct values.

AR# 15254
Date 08/11/2014
Status Archive
Type General Article
Tools
People Also Viewed