cancel
Showing results for
Show  only  | Search instead for
Did you mean:
Participant
1,966 Views
Registered: ‎11-02-2017

## INT8 DSP48E1 HLS

Came across this white paper from Xilinx on utilizing DSP48E2 (18X27) to compute two INT8 multiplication operation in once cycle.

https://www.xilinx.com/support/documentation/white_papers/wp486-deep-learning-int8.pdf

Has anyone tried the same technique on DSP48E1(18X25) with HLS?

Cheers.

1 Solution

Accepted Solutions
2,288 Views
Registered: ‎04-26-2015

@futuristic The following hasn't been tested, but it looks like a good start to me.

Using Xilinx's syntax, you're aiming to compute a*c and b*c (ie c is a common factor). Then for an unsigned operation it'd just be:

```inline void mul2(ap_uint<8> a, ap_uint<8> b, ap_uint<8> c, ap_uint<16> * ac, ap_uint<16> * bc) {
ap_uint<24> x = 0;
x.range(23,16) = a;
x.range(7,0) = b;

ap_uint<32> product = x * c;
*ac = product.range(31,16);
*bc = product.range(15,0);
}
```

I haven't looked at the signed operation in detail, but it looks to be very similar.

5 Replies
1,935 Views
Registered: ‎04-26-2015

@futuristic HLS won't do it automatically, but it should be easy to implement it manually. Just write an inline function that does the two-element multiply.

Participant
1,925 Views
Registered: ‎11-02-2017

@u4223374 Could you share a snippet?

2,289 Views
Registered: ‎04-26-2015

@futuristic The following hasn't been tested, but it looks like a good start to me.

Using Xilinx's syntax, you're aiming to compute a*c and b*c (ie c is a common factor). Then for an unsigned operation it'd just be:

```inline void mul2(ap_uint<8> a, ap_uint<8> b, ap_uint<8> c, ap_uint<16> * ac, ap_uint<16> * bc) {
ap_uint<24> x = 0;
x.range(23,16) = a;
x.range(7,0) = b;

ap_uint<32> product = x * c;
*ac = product.range(31,16);
*bc = product.range(15,0);
}
```

I haven't looked at the signed operation in detail, but it looks to be very similar.

Participant
1,908 Views
Registered: ‎11-02-2017

@u4223374 That works great!

Participant
443 Views
Registered: ‎04-10-2019

@u4223374  The unsigned operation works well, Can you provide an example of signed multiplication? Can only pack two unsigned numbers? Thank you!