marufsust
Newbie level 6
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 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.