File: t_display_recurse.v

package info (click to toggle)
verilator 5.038-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 162,552 kB
  • sloc: cpp: 139,204; python: 20,931; ansic: 10,222; yacc: 6,000; lex: 1,925; makefile: 1,260; sh: 494; perl: 282; fortran: 22
file content (52 lines) | stat: -rw-r--r-- 1,405 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2023 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0

module t(/*AUTOARG*/
   // Inputs
   clk
   );
   input clk;

   integer i;
   integer count = 'd0;

   always @(posedge clk) begin
      count <= count + 1;
      if (count == 10) begin
         for(i=0; i<30; i=i+4) begin
            // See issue #4480, verilator may inline getb() which has another display inside it
            $display("%d: %02x%02x%02x%02x", i, getb(i+3), getb(i+2), getb(i+1), getb(i));
         end
      end
      if (count == 11) begin
         $write("*-* All Finished *-*\n");
         $finish;
      end
   end

   localparam SIZE = 64*1024;
   localparam ADDRW = $clog2(SIZE/4);
   reg [31: 0] ram [(SIZE/4)-1: 0];

   function [7:0] getb;
      input [31:0] address;
      if (address[31:ADDRW+2] != 0) begin
         $display("Address out of range");
      end
      case(address[1:0])
        0: getb = ram[address[ADDRW+1: 2]][8*0+7:8*0];
        1: getb = ram[address[ADDRW+1: 2]][8*1+7:8*1];
        2: getb = ram[address[ADDRW+1: 2]][8*2+7:8*2];
        3: getb = ram[address[ADDRW+1: 2]][8*3+7:8*3];
      endcase
   endfunction

   initial begin
      for (i=0; i<SIZE/4; i=i+1) begin
         ram[i] = {i[15:0], 16'hdead};
      end
   end
endmodule