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.

Reading in a .txt file with Verilog Code

Status
Not open for further replies.

FboDigit

Member level 1
Joined
Jun 19, 2012
Messages
38
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
Canada
Activity points
1,502
I want to read a file using Verilog language. The trick is that I want to read only 1 segment of text at a time. I have been able to implement the syntax with VHDL using the READ() statement.
The code look like this.

case(xdata):
...
m : begin
READ(my_line,spaces);
READ(my_line, cmd);
READ(my_line, spaces);
READ(my_line, addr_v);
READ(my_line, spaces);
READ(my_line, data_v);
READ(my_line, spaces);
READ(my_line, mask_v);

The problem is that I a not able to find the equivalent in Verilog.

The line I want to read is formated like this:
"m 6 E0000008 00000080 00000080"

Is there any way to read this kind of file using Verilog/SystemVerilog ???
 

look for the $fscanf system function

$fscanf("%s %x %x %x",cmd,addr_v,data_v,mask_v);
 

Thank you Dave that will work for sure. This is really helpfull!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top