Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Strange behavior when reading ROM data in Altera

Status
Not open for further replies.

zermelo

Junior Member level 3
Junior Member level 3
Joined
May 24, 2013
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,543
Hi,

I have used MATLAB to generate a linear frequency modulated waveform, quantize it as signed 16 bit and write it into a . MIF file:

Code:
for i = 1:N  
  fprintf(fid_50,'%i : %i;\n',i-1,(Chirp50_n(i))); 
  fprintf(fid_200,'%i : %i;\n',i-1,(Chirp200_n(i))); 
  
end

So I have a two . MIF files displaying this data . They look like:

Code:
WIDTH=16;
DEPTH=20000;
ADDRESS_RADIX=DEC;
DATA_RADIX=DEC;

CONTENT BEGIN

0 : 0;
1 : 9817;
2 : 18733;
3 : 25927;
4 : 30740;
5 : 32728;
6 : 31709;
7 : 27777;
8 : 21293;
9 : 12852;
10 : 3231;
11 : -6688;
12 : -15991;
13 : -23826;
14 : -29472;
15 : -32409;
(...)

These files are used to initialize two ROMS in a Cyclone III. I do not understand that when I simulate it Modelsim does only display the absolute value of the samples (I select decimal data radix). The VHDL that uses the ROMs is as easy as this:

Code:
U_ROM_50k: chirp_rom_50k  
  port map
    ( address => std_logic_vector(s_addr50k),
	  clken	=> s_50kclk_en_rom,
	  clock	=> i_clk,
	  q		=> s_chirp50k_std 
	);

  o_chirp50k  <= signed(s_chirp50k_std);

Where all the ports in the ROM (generated with the Megawizard) are std_logic_vector and the output is signed. Can you see what's going on with this code?

zermelo
 

Have you checked that the signed decimal data is correctly stored in the chirp_rom_50k memory array? As you are using decimal in the MIF and the array is probably an array of slv, I'm wondering if that is the source of the problem. I normally use hexadecimal or binary data for mif files, I've never tried loading them with signed decimal, so I can't say for sure if that would be a problem or not.
 

Hi ,

I am looking at o_chirp50k in the simulator. Actually , the memory array in Modelsim displays already incorrect values (is there any other way to check the stored values, for instance in Quartus?)

By the way, i have been reading online. Looks like Quartus does not support .MIF with signed data values. Simply goes ahead, without issuing a warning.

I´ll try tomorrow defining the MATLAB output file as raw binary.

Thanks folks,

zermelo
 

I normally always use binary or hexadecimal without issues. So once you update the .MIF file to binary data values it should work fine. You can also format the .MIF data as hexadecimal data, I find that easier to read.

Regards
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top