Forum Discussion

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

SOPC - simple question

Hi,

I am new here, so sorry for trivial questions:-)

It's my first project in SOPC Builder (I use 5.1) and I'd like to add something very simple in order to learn how to use the tool.

My VHDL code is simple counter from Altera site. But when I try to use Component editor, I see error: "slave must have a read or write interface, or support interrupts." I cannot add result signal. In signals tab there is only clock signal, which I set to type clk.

I read tutorials, I finieshed it step by step but there was nothing about it.

Here is code:

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

ENTITY count IS

PORT

(

clock: IN STD_LOGIC;

result: OUT integer RANGE 0 TO 31

);

END count;

ARCHITECTURE rtl OF count IS

SIGNAL result_reg : integer RANGE 0 TO 31;

BEGIN

PROCESS (clock)

BEGIN

IF (clock'event AND clock = '1') THEN

result_reg <= result_reg + 1;

END IF;

END PROCESS;

result <= result_reg;

END rtl;

Thank you for any help!

Best regards,

Koza

11 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Ok, then your accesses to the peripheral were being cached. To avoid this with a processor with data cache use this:

    # include "io.h" // contains cache bypassing macros

    IORD (base, offset); // base address and word address in the peripheral

    IOWR (base, offset, data); // base address, word address, and the data you want to write

    Those are for accessing native (registered) components like the one you created. If you need to bypass cache to access memory (dynamic) components there are similar macros in io.h for those only they use byte addressing instead of word addressing. They should be contained in this document:

    http://www.altera.com/literature/hb/nios2/n2sw_nii5v2.pdf

    Also the keyword volatile tells the compiler to not optimize away code. For example if you read from a memory location polling for a specific value, you should make it volatile otherwise the compiler may get rid of the polling loop. The compiler would do this since it would see the multiple accesses to the same location and remove it since it doesn't know that some external event might change that value. So it would remove the loop and only read it once (thinking the value will never change so the loop isn't necessary).