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.

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 [0:DATA];

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

Quartus II integrated synthesis and other synthesis tools also support the $readmemb
and $readmemh commands so that RAM initialization and ROM initialization work
identically in synthesis and simulation. Example 10–27 shows an initial block that
initializes an inferred RAM block using the $readmemb command.

Refer to the Verilog Language Reference Manual (LRM) 1364-2001 Section 17.2.8 or the
example in the Templates for the Quartus II software for details about the format of
the ram.txt file.

Example 10–27. Verilog HDL RAM Initialized with the readmemb Command
reg [7:0] ram[0:15];
initial
begin
$readmemb("ram.txt", ram);
end

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.
 
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top