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: 
672 Views
Registered: ‎08-24-2018

A simple counter stick at a certain number

Hello all,

 

I have a simple counter working with 1MHZ zynq processor as the code below. After a while, its value sticks at 0X407 (1031). It means the block cannot produce the right output. I have this problem with the other blocks too. Could you solve this problem? (I attached the behavioral simulation waveform.)

 

#include"ap_int.h"
#include <iostream>
#include<stdlib.h>
#include <cstdio>
#include <cstdlib>

typedef ap_int<64> signal64;
typedef ap_uint<1> boolSignal;
typedef ap_int<3> threeSBit;
typedef ap_int<1> signal1;

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define NOTEQUAL(a,b) (a!=b ? 1 : 0)

#define MAX_TIME 1152921504606846976

using namespace std;

 

void counterBlk(
boolSignal reset,

volatile signal64* fnlCntr,
signal64& fnlCntrAXI

)
{
#pragma HLS INTERFACE ap_ctrl_none port=return
#pragma HLS PIPELINE
#pragma HLS INTERFACE axis register both port=fnlCntrAXI
#pragma HLS INTERFACE ap_none port=reset
#pragma HLS INTERFACE ap_none port=fnlCntr

static boolSignal lastStage = 0;
static signal64 cntr = 0;
static boolSignal preReset = 0;

if (reset == 1 && preReset == 0)
cntr = 0;
else
{
if(cntr < MAX_TIME)
cntr++;
else
cntr = 0;
}
*fnlCntr = cntr;
fnlCntrAXI = cntr;
preReset = reset;
}

counter.JPG
0 Kudos
7 Replies
Mentor xilinxacct
Mentor
651 Views
Registered: ‎10-23-2018

Re: A simple counter stick at a certain number

mmehrabi@asu.edu

is it possible the amount of time you have the scope active is too short? (e.g. the default runtime of the simulation too short?) If so, increase the runtime and try again.)

0 Kudos
616 Views
Registered: ‎08-24-2018

Re: A simple counter stick at a certain number

I run it for a longer time. After 4 resets it is stuck on a number and never increased.

counter2.JPG
0 Kudos
587 Views
Registered: ‎08-24-2018

Re: A simple counter stick at a certain number

I found that when I use AXI, I have this problem.

0 Kudos
Mentor xilinxacct
Mentor
576 Views
Registered: ‎10-23-2018

Re: A simple counter stick at a certain number

mmehrabi@asu.edu

If you can zip up the smallest program and testbench, that exhibits the problem, I will take a look. I don't have the same hardware, so I may not have the same experience. No promises, but it sounds interesting.

What version are you using?

0 Kudos
482 Views
Registered: ‎08-24-2018

Re: A simple counter stick at a certain number

I attached the Vivado project and the related files. There are three cpp wiles there, counter.cpp produces the counter value, counterDMA transfers the value to the PS using AXI DMA and fifo to have all counter numbers in the PS, and axilite provides a register, axilite, to have the latest value in the PS. 

 

change NTPPrj.txt to NTPPrj.xpr

change counter.txt to counter.cpp

change counterDMA.txt to counterDMA.cpp

change axilite.txt to axilite.cpp

 

The VIVADO version is 

If you have 2017.4.

Let me know if you have further questions.

0 Kudos
481 Views
Registered: ‎08-24-2018

Re: A simple counter stick at a certain number

 
0 Kudos
Mentor xilinxacct
Mentor
395 Views
Registered: ‎10-23-2018

Re: A simple counter stick at a certain number

mmehrabi@asu.edu

Your files are incomplete to make buildable project.

That being said.... try this to isolate your issue... It looks like you were using HLS... Create your top-level function... just the counter... stimulate it with a test bench, and verify that must works correctly in isolation.

If that does, try the next level... Insure all your data types are the width you need.

Hope that helps

If so, please mark as solution accepted. Kudos are also welcomed :-)

0 Kudos