File: getc1.v

package info (click to toggle)
gplcver 2.12a-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,604 kB
  • ctags: 9,129
  • sloc: ansic: 126,201; sh: 1,539; makefile: 86; perl: 22
file content (34 lines) | stat: -rw-r--r-- 711 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * fileio test of getc - copy to stdout
 */

`timescale 1ns / 10 ps
`define EOF -1
`define NULL 0
`define MAX_LINE_LENGTH 1000
`define STDOUT 32'h8000_0001
module test1;
  integer file;
  reg [3:0] bin;
  reg [31:0] dec, hex;
  real real_time;
  reg [8*`MAX_LINE_LENGTH-1:0] line; /* Line of text read from file */
  integer r;
  integer c;

  initial
     begin : file_block
      file = $fopen("infil.txt", "r");
      if (file == `NULL) disable file_block;
  
      begin : read_block
       forever  
         begin
          c = $fgetc(file);
          if (c == `EOF) disable read_block;
          $fwrite(`STDOUT, "%c", c);
         end
      end
      $fclose(file);
    end
endmodule // read_pattern