bigrice911
Member level 3
system verilog read file
How to make a SystemVerilog Class to read a text vector
and how to sync it with the global clock? read every byte per cycle
I have tried to write one but it seems not work... can anyone give me a hint on that?
the input vector format:
000
123
AAB
012
0EF
23F
876
...
...
...
How to make a SystemVerilog Class to read a text vector
and how to sync it with the global clock? read every byte per cycle
I have tried to write one but it seems not work... can anyone give me a hint on that?
Code:
class #(parameter File_Name = "input_vector.txt",
parameter Data_Width = 12) SIM_MEM;
reg [Data_Width-1:0] Data;
function new(input File_P);
integer File_P;
begin
File_P = $fopen(File_Name, "r");
if(!File_P) begin
$display("File %s open failded, no such file!", File_Name);
$finish(2);
end
else begin
if(!$feof(File_P)) begin
$fscanf(File_P, "%h", Data);
return Data;
end
else begin
$display("%s reaches file's end!", File_Name);
$fclose(File_P);
$finish(2);
end
end
endclass
the input vector format:
000
123
AAB
012
0EF
23F
876
...
...
...