I am using the Data Pattern Generator/Checker IP in a Qsys file and trying to configure it via a NIOS. However, I am having some trouble. I am using IOWR_32DIRECT() and IORD_32DIRECT() to write and read configuration data but I am not getting correct data when I try to enable the IP cores.
I've attached the Qsys, C code, and the terminal output. I'd like someone to review it and let me know if there is something in the code that would cause the issue. The puts and printf works but the IORD's don't give the correct values. I checked the Qsys and it looks like everything is connected up correctly.
Thanks for your help.
Hello_world_small.c
// "Small Hello World" example.
#include "sys/alt_stdio.h"
#include "system.h"
#include <io.h>
#include "os/alt_syscall.h"
#include <unistd.h>
int alt_main()
{
unsigned int PRBS15 = 0x2;
unsigned int ENABLE = 0x1;
alt_putstr("Hello from Nios II!\n\n");
usleep(500000);
alt_putstr("Begin configuration of Pattern Generator\n\n");
usleep(500000);
alt_putstr("Setting pattern to PRBS15...\n");
usleep(500000);
IOWR_32DIRECT(DATA_PATTERN_GENERATOR_0_BASE, 4, PRBS15);
usleep(500000);
alt_printf("The value read from Generator is %x\n", IORD_32DIRECT(DATA_PATTERN_GENERATOR_0_BASE, 4));
usleep(500000);
IOWR_32DIRECT(DATA_PATTERN_CHECKER_0_BASE, 4, PRBS15);
usleep(500000);
alt_printf("The value read from Checker is %x\n\n", IORD_32DIRECT(DATA_PATTERN_CHECKER_0_BASE, 4));
usleep(500000);
alt_putstr("Enabling pattern generator...\n");
usleep(500000);
IOWR_32DIRECT(DATA_PATTERN_CHECKER_0_BASE, 0, ENABLE);
usleep(500000);
alt_printf("The value read from Checker is %x\n", IORD_32DIRECT(DATA_PATTERN_CHECKER_0_BASE, 0));
usleep(500000);
IOWR_32DIRECT(DATA_PATTERN_GENERATOR_0_BASE, 0, ENABLE);
usleep(500000);
alt_printf("The value read from Generator is %x\n\n", IORD_32DIRECT(DATA_PATTERN_GENERATOR_0_BASE, 0));
usleep(500000);
return 0;
}
Terminal Output
Hello from Nios II!
Begin configuration of Pattern Generator
Setting pattern to PRBS31
The value read from Generator is 8
The value read from Checker is 8
Enabling pattern generator
The value read from Checker is 0
The value read from Generator is 0
End