Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
9 years ago

Help with IOWR_32DIRECT and IORD_32DIRECT(

Hello,

I need some help with the functions IOWR_32DIRECT and IORD_32DIRECT. I made a component in VHDL which simply copies the input to the output. Using the Nios II and the functions IOWR_32DIRECT and IORD_32DIRECT I intend to "throw" a value in this component and expect it in return the same value. However, the result is totally different. Could anyone help me indicating where is the error?

The architecture used has an Nios II, Onchip Memory, JTAG UART and the component that I created.

The codes are:

VHDL (Component):

----------------------------------------------
  LIBRARY ieee;
  USE ieee.std_logic_1164.all;
  USE ieee.std_logic_unsigned.all;
----------------------------------------------
ENTITY Copy IS
PORT (dataIn: in STD_LOGIC_VECTOR (31 DOWNTO 0);
        dataOut:    out STD_LOGIC_VECTOR (31 DOWNTO 0);
        write_n, read_n: in STD_LOGIC;
        clk, reset: in STD_LOGIC
        );
END ENTITY;
ARCHITECTURE CompCopy OF Copy IS
SIGNAL data: STD_LOGIC_VECTOR (31 DOWNTO 0);
BEGIN
    PROCESS (clk, reset)
    BEGIN
        IF(clk'Event and clk='1') then
            
            IF write_n = '1' THEN
                data <= dataIn;
            END IF;
                
            IF read_n = '1' then
                dataOut<= data;
            END IF;
        END IF;
    END PROCESS;
END CompCopy;

C:


# include <stdio.h># include "system.h"# include "io.h"
int main()
{
    int i = 1;
    IOWR_32DIRECT(COPY_0_BASE, 1, i);
    printf("\nValue: %d\n", IORD_32DIRECT(COPY_0_BASE, 1));
    return 0;
}

Returned value: 1052681

The "Signals" tab in "Component Editor" are:

name

interface

signal type

width

direction

dataIn

avalon_slave_0

writedata

32

input

dataOut

avalon_slave_0

readdata

32

output

write_n

avalon_slave_0

write_n

1

input

read_n

avalon_slave_0

read_n

1

input

clk

clock

clk

1

input

reset

reset

reset

1

input

Thank you very much!

4 Replies