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!

Showing results for 
Search instead for 
Did you mean: 
Visitor anderslange
Registered: ‎08-24-2011

Implementation of a simple modN counter in Vivado HLS

Hi everybody


I'm trying to implement a simple BRAM based shiftregister in Vivado HLS.

I need it as the built in class "ap_shift_reg" uses LUTs (SRL's), and I need rather long shift registers for buffering a couple of lines of data in an image for a streaming application. Using external RAM is not an option.


I'm having trouble getting the design to meet the desired timing. I'm using a XC7Z020-1CLG484. My requirement is minimum 400MHz clock. I can without any problems, and in very few line of code implement this in VHDL.

But I'm trying to learn HLS in order to be able to apply it to the rest of the project which will benefit much more from it, since it will have some much more complicated control logic, and I would like to be able to do quick exploration of different architectures.


I've identified the performance issue to being the needed address counter for the BRAM based shift register.

Whenever I try to implement this counter so that it may reset itself to zero once it passed/reaches a certain value, the result is that it won't meet my timing requirement. I know it is possible to make to the counter work at the required speed since I've implemented and PAR'd it in ISE.


My current most efficient implementation looks like this:


template<class TYPE, int MAX_CNT, int BIT_WIDTH>
DT shiftreg<TYPE, DC, DW>::shift(DT din)
	static TYPE mem[MAX_CNT];
	static ap_uint<BIT_WIDTH> mem_ptr = 0;
	TYPE tmp;

	tmp = mem[mem_ptr];
	mem[mem_ptr] = din;

	mem_ptr = (mem_ptr==(MAX_CNT-1))? ap_uint<BIT_WIDTH>(0) : mem_ptr++;

	return tmp;

Once I pipeline it, the performance drops way below the requirements....


I'm frustrated.... will appreciate any suggestions :-)



Anders Lange


Anders Lange
PhD Student, The Maersk Mc-Kinney Moller Instute
University of Southern Denmark, Faculty og Engineering
0 Kudos
1 Reply
Registered: ‎04-17-2011

Re: Implementation of a simple modN counter in Vivado HLS

This post is quite old now, was the issue resolved at your end? Do you still need any assistance?

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