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.

How to make a SystemVerilog Class to read a text vector

Status
Not open for further replies.

bigrice911

Member level 3
Joined
Apr 27, 2004
Messages
65
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
500
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?

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
...
...
...
 

systemverilog file read

any hint?
 

fscanf system verilog

I think PERL or Python are more suited for text handling.
 

fscanf systemverilog

I do not use sv to process my text file; I just use it read the vector from the file and feed the vector to the testbenches or DUT.
The reason why I need a sv class here is the class can be easily reused and called.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top