File: module_scope_func.v

package info (click to toggle)
yosys 0.52-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 69,796 kB
  • sloc: ansic: 696,955; cpp: 239,736; python: 14,617; yacc: 3,529; sh: 2,175; makefile: 1,945; lex: 697; perl: 445; javascript: 323; tcl: 162; vhdl: 115
file content (45 lines) | stat: -rw-r--r-- 1,377 bytes parent folder | download
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
// Some strict implementatins either forbid hierarchical identifiers within
// constant expressions, or forbid declaring functions in generate blocks, or
// both. Yosys and Iverilog are not strict in either of these ways.
module module_scope_func_top(
    input wire inp,
    output wire [31:0] out1, out2, out4, out5, out7, out8,
    output reg [31:0] out3, out6, out9
);
    function automatic integer incr;
        input integer value;
        incr = value + 1;
    endfunction
    task send;
        output integer out;
        out = 55;
    endtask

    assign out1 = module_scope_func_top.incr(inp);
    localparam C = module_scope_func_top.incr(10);
    assign out2 = C;
    initial module_scope_func_top.send(out3);

    if (1) begin : blk
        // shadows module_scope_func_top.incr
        function automatic integer incr;
            input integer value;
            incr = value * 2;
        endfunction
        // shadows module_scope_func_top.send
        task send;
            output integer out;
            out = 66;
        endtask

        assign out4 = module_scope_func_top.incr(inp);
        localparam D = module_scope_func_top.incr(20);
        assign out5 = D;
        initial module_scope_func_top.send(out6);

        assign out7 = incr(inp);
        localparam E = incr(30);
        assign out8 = E;
        initial send(out9);
    end
endmodule