Accesss text File and Display it in FPGA

Status
Not open for further replies.

marufsust

Newbie level 6
Joined
May 5, 2010
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Malaysia
Activity points
1,383
Hi all,

I want to read a set of data from a text file and show each data in every clock cycles. am using $readmemh function to read tha text file and store it in a register. But the problem is I can not show each element of that register in one clock cycle. Here is my code


module ppg_peak(clock,reset,show_val);

parameter DATA = 18;
input clock,reset;
output [27:0] show_val;


reg [27:0] show_val;
// Declare memory array that is twelve words of 32-bits each
reg [27:0] Mem [0ATA];

reg [DATA:0] k;
// Fill the memory with values taken from a data file
initial
begin
$readmemh("myfile_new.txt",Mem);
end

always@(posedge clock)
begin
if(reset <= 1)
begin
show_val <= 0;
k <= 0;
end
else
begin
if(k <= DATA)
begin
show_val <= Mem[k];
k <= k+1'b1;
end
else
k <= 0;
end
end

endmodule


Is there any other solutions for doing this? Moreover the text file can be accesed while I am using Modelsim but cannot be accessed in Quartus II with same code why??

Thanks in Advance.
 

I was under the impression that Quartus would support Verilog $readmemh for synthesis, but I didn't try. Altera IP is however using altsyncram instances and it's init_file feature to implement initialized RAM/ROM. It's also working in Modelsim, if you are using *.hex rather than Altera specific *.mif files. There may be also an issue with different file locations expected by Quartus versus Modelsim.
 
I was under the impression that Quartus would support Verilog $readmemh for synthesis ...

You are correct FvM, according to:

Reference "Altera 10.x Recommended HDL Coding Styles", pg 10-34, Section "Specifying Initial Memory Contents at Power-Up."

Altera 10.x Recommended HDL Coding Styles


However, I have yet to dig up v9.x or earlier of this reference manual to verify $readmemh compatible with earlier versions of Quartus II.
 
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…