02-05-2017 02:41 PM
hi pals,
This is a program for 8-bit parallel counter
typedef unsigned char u8;
void counter(volatile bool run, volatile int delay, volatile u8 *counter) {
#pragma HLS INTERFACE ap_none register port=counter
#pragma HLS INTERFACE ap_none register port=delay
#pragma HLS INTERFACE ap_none register port=run
#pragma HLS RESOURCE variable=delay core=AXI4LiteS metadata="-bus_bundle CONTROL_BUS"
#pragma HLS RESOURCE variable=return core=AXI4LiteS metadata="-bus_bundle CONTROL_BUS"
volatile u8 counter_reg = 0;
while(run == 1) {
volatile int i = 0;
for (i = 0; i < delay; i++);
*counter = counter_reg++;
}
}
Which data type should I use to make it 4-bit parallel counter?
Best Regards,
Deepa krishnamurthy
02-05-2017 02:58 PM
There's no built-in C type that's 4 bits long, so you'll need to have a look at UG902 v2016.4, page 207 ("Arbitrary Precision Data Types Library"). Otherwise you could explicitly overflow the 8-bit counter when it reaches 16.
02-05-2017 02:58 PM
There's no built-in C type that's 4 bits long, so you'll need to have a look at UG902 v2016.4, page 207 ("Arbitrary Precision Data Types Library"). Otherwise you could explicitly overflow the 8-bit counter when it reaches 16.
02-05-2017 04:55 PM
@deepa_krishna if you code your counter like this counter = (counter + 1) & 0xf, I am pretty sure the logic optimization will come out to a 4 bit variable.
02-06-2017 11:09 AM
Thanks for the solution
02-06-2017 11:10 AM