UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
9,428 Views
Registered: ‎12-18-2012

division result and module by the same operation...

Hello,

 

I want to compute sth like this in vivado HLS...

 

Integer_Indicator = Bit_Indicator/32;
pos = Bit_Indicator%32;

 

In the synthesis vivado HLS seems to add two separate devision module for each operation. These results could be computed by a div core....Could HLS be told to use the same hardware module to produce both result to save area?

 

Thanks

0 Kudos
9 Replies
Teacher rcingham
Teacher
9,423 Views
Registered: ‎09-09-2010

Re: division result and module by the same operation...

Isn't the point about HLS that it is for people who haven't a clue about hardware?

I look at your code snippet and think "bus splitter" - no division required at all!

------------------------------------------
"If it don't work in simulation, it won't work on the board."
0 Kudos
Moderator
Moderator
9,415 Views
Registered: ‎04-17-2011

Re: division result and module by the same operation...

You can try using set_directive_resource. Refer page 521 : http://www.xilinx.com/support/documentation/sw_manuals/xilinx2013_2/ug902-vivado-high-level-synthesis.pdf
Regards,
Debraj
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Highlighted
Adventurer
Adventurer
9,406 Views
Registered: ‎12-18-2012

Re: division result and module by the same operation...

Would the resource directive be able to force both operations to use the same division module?

 

@ No...no way. Someone that has no clue about hardware could never make an efficient HLS desing unless it was very simple. 

 

And HLS it can save a good amount of time compared to writing VHDL manually. Epsecially if you have very complex designs.

 

And yes what I try to make is more or less a bus splitter...Unfortunately it is part of a very much larger design that I implement in HLS and i need to describe it in C that the HLS can translate to hardware.

 

0 Kudos
Teacher rcingham
Teacher
9,403 Views
Registered: ‎09-09-2010

Re: division result and module by the same operation...

I seem to recall that there are bitwise operations in C. Are these supported for HLS?

------------------------------------------
"If it don't work in simulation, it won't work on the board."
0 Kudos
Adventurer
Adventurer
9,385 Views
Registered: ‎12-18-2012

Re: division result and module by the same operation...

I do not think so...What I did is implement a check bit function using shifting but i stiil need to know which bit I need,hence the devisions.... 

 

0 Kudos
Xilinx Employee
Xilinx Employee
9,372 Views
Registered: ‎08-17-2011

Re: division result and module by the same operation...

Hi everyone!

 

All those messages intriged me.. anything that is supported in C is supported by VHLS!

 

Please use this toy example to make your own tests...

As I understand this question was just a side question/issue to what you originally intented - there's more than one way to do it ;)

 

I hope this helps a bit

cheers - Hervé

 

/* !!!! the user/reader needs to write its own testbench !!!! */

#include <assert.h>

void top(unsigned int in, unsigned int pos, unsigned int &out_top, unsigned int &out_bottom) {
    assert(pos>=0);
    assert(pos<=32);
    unsigned int bits;

    // makes this variable or not!
#if 1
    bits = pos;
#else
    bits = 5; // note: input pos won't be used
#endif

#if 0

// with operators
    out_top = in / (1<<bits);
    out_bottom = in % (1<<bits);
#else

// using direct shift
    out_top = in >> bits;
    // generate a mask followed by bitwise AND
    unsigned int lshift = 32 - bits;
    unsigned int mask = 0xffffffff >> lshift;
    out_bottom = in & mask;
#endif
}

- Hervé

SIGNATURE:
* New Dedicated Vivado HLS forums* http://forums.xilinx.com/t5/High-Level-Synthesis-HLS/bd-p/hls
* Readme/Guidance* http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

* Please mark the Answer as "Accept as solution" if information provided is helpful.
* Give Kudos to a post which you think is helpful and reply oriented.
Adventurer
Adventurer
9,355 Views
Registered: ‎12-18-2012

Re: division result and module by the same operation...

Yes this does work and that is what i use....I think the conversaion got a little sidetracked...

 

To be more specific. I have sth like this:

An array of 10 integers each of 32 bits. Each bit might be a useful value and are placed in sequenced in these integers, bundled in integers to improve I/O transfer.

 

If for example I need the 55th bit I do these 2 divisions in the first post to see in which integer that bit is placed and its position in that integer (that would be pos in the previous code).

 

After that I use shifts to take the respetive bit, similarly to what you had in your code.  

 

Thaks for the replies....

 

0 Kudos
Xilinx Employee
Xilinx Employee
9,321 Views
Registered: ‎08-17-2011

Re: division result and module by the same operation...

I only noticed your response now.. sorry!

I'm not sure I understand if you solved your issue, or don't have it anymore or if you're implying any new questions..? (please mark the post solved)

If you could provide some code that represent the bigger picture, that may be useful too... and may answer/make clearer questions like do you need vaiable shifters or can something using constants be used; would it make sense to have a case statment rather than generic code, etc...
- Hervé

SIGNATURE:
* New Dedicated Vivado HLS forums* http://forums.xilinx.com/t5/High-Level-Synthesis-HLS/bd-p/hls
* Readme/Guidance* http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

* Please mark the Answer as "Accept as solution" if information provided is helpful.
* Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Teacher muzaffer
Teacher
9,300 Views
Registered: ‎03-31-2012

Re: division result and module by the same operation...

> No...no way. Someone that has no clue about hardware could never make an efficient HLS desing unless it was very simple.

I am pretty sure someone somewhere at some time said:  "someone that [sic] has no clue about cpu instructions and timing could never write an efficient program unless it was very simple" ;-)

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos