Fixed error in carry calculation for MAC of the hwmult
This commit is contained in:
parent
df6f0ec3bc
commit
6fe57b02e4
|
@ -70,6 +70,7 @@ static void hwmult_destroy(struct simio_device *dev)
|
||||||
static void do_multiply(struct hwmult *h)
|
static void do_multiply(struct hwmult *h)
|
||||||
{
|
{
|
||||||
uint32_t im;
|
uint32_t im;
|
||||||
|
uint64_t temp = 0;
|
||||||
|
|
||||||
/* Multiply */
|
/* Multiply */
|
||||||
if (h->mode & 2)
|
if (h->mode & 2)
|
||||||
|
@ -79,16 +80,19 @@ static void do_multiply(struct hwmult *h)
|
||||||
|
|
||||||
/* Accumulate or store */
|
/* Accumulate or store */
|
||||||
if (h->mode & 4)
|
if (h->mode & 4)
|
||||||
h->result += im;
|
{
|
||||||
|
temp = (uint64_t)h->result + im;
|
||||||
|
h->result = temp;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
h->result = im;
|
h->result = im;
|
||||||
|
|
||||||
/* Set SUMEXT */
|
/* Set SUMEXT */
|
||||||
if (h->mode & 2)
|
if (h->mode & 2) /* MPYS and MACS */
|
||||||
h->sumext = (h->result & 0x80000000) ? 0xffff : 0;
|
h->sumext = (h->result & 0x80000000) ? 0xffff : 0;
|
||||||
else if (h->mode == MPY)
|
else if(h->mode == MAC)
|
||||||
h->sumext = (h->result < im) ? 1 : 0;
|
h->sumext = temp >> 32;
|
||||||
else
|
else /* MPY */
|
||||||
h->sumext = 0;
|
h->sumext = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue