1/* 2 * fileio test of getc - copy to stdout 3 */ 4 5`timescale 1ns / 10 ps 6`define EOF -1 7`define NULL 0 8`define MAX_LINE_LENGTH 1000 9`define STDOUT 32'h8000_0001 10module test1; 11 integer file; 12 reg [3:0] bin; 13 reg [31:0] dec, hex; 14 real real_time; 15 reg [8*`MAX_LINE_LENGTH-1:0] line; /* Line of text read from file */ 16 integer r; 17 integer c; 18 19 initial 20 begin : file_block 21 file = $fopen("infil.txt", "r"); 22 if (file == `NULL) disable file_block; 23 24 begin : read_block 25 forever 26 begin 27 r = $fgets(line, file); 28 if (r == 0) disable read_block; 29 $fwrite(`STDOUT, "%s", line); 30 end 31 end 32 $fclose(file); 33 end 34endmodule // read_pattern 35