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

INT8 DSP48E1 HLS

Jump to solution

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. 

0 Kudos
1 Solution

Accepted Solutions
u4223374
Advisor
Advisor
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.

View solution in original post

5 Replies
u4223374
Advisor
Advisor
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.

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

@u4223374 Could you share a snippet? 

0 Kudos
u4223374
Advisor
Advisor
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.

View solution in original post

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

@u4223374 That works great! 

0 Kudos
lwq2018
Participant
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!

0 Kudos