Forum Discussion

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

Memory WRITING issue

Dear,

I have a procedure (Sort) that read two numbers in each cycle. and return the max and the min. I am reading two numbers from mif file , the problem is that I want to write back the result returned from the PROCEDURE to the same location of the memory that I had read from. I expected it to be in the next cycle but the memory is not able to be inferred " can't infer memory for variable 'ram1' with attribute '"M4K"'. I listed the code below as reference. Many thanks.

ARCHITECTURE behave OF min_max IS

TYPE MEM IS ARRAY(0 TO 15) OF signed(9 DOWNTO 0);

signal ram1:MEM;

ATTRIBUTE ram_init_file: STRING;

ATTRIBUTE ram_init_file OF ram1: SIGNAL IS "bits.mif";

ATTRIBUTE ramstyle: STRING;

ATTRIBUTE ramstyle OF ram1: SIGNAL IS "M4K";

SIGNAL reg1sig,reg2sig,dataodd,dataeven,minsig,maxsig: signed(9 downto 0);

BEGIN

PROCESS (clock)

variable kk:integer range 0 to 7:=0;

BEGIN

IF rising_edge(clock) THEN

dataodd <= ram1(2*kk+1);

dataeven<=ram1(2*kk);

reg1sig<=dataodd;

reg2sig<=dataeven;

Sort(Reg1sig,reg2sig,maxsig,minsig); -- THE PROCEDURETAKES TWO NUMBERS AND RETURN TWO , IT WORKS WELL WITHOUT WRITING TO RAM1

ram1(2*kk+1) <= maxsig;

ram1(2*kk)<= minsig;

kk:=kk+1;

END IF;

OUT<=maxsig;

END PROCESS;

12 Replies