size_cast.sv 774 Bytes
Newer Older
1 2 3
module top;
    localparam BW = 3;
    logic [2:0] test;
4 5
    logic [3:0] foo;
    logic [3:0] bar;
6 7
    integer x;
    reg [7:0] y;
8 9 10 11 12 13 14 15

    initial begin
        test = BW'(0);
        $display(test);
        foo = 2'('1);
        $display(foo);
        bar = $bits(bar)'('1);
        $display(bar);
16 17 18 19 20 21 22 23 24 25
        x = 1'('1); $display("%b %0d", x, x);
        y = 1'('1); $display("%b %0d", y, y);
        x = 2'('0); $display("%b %0d", x, x);
        y = 2'('0); $display("%b %0d", y, y);
        x = 2'('1); $display("%b %0d", x, x);
        y = 2'('1); $display("%b %0d", y, y);
        x = 2'('x); $display("%b %0d", x, x);
        y = 2'('x); $display("%b %0d", y, y);
        x = 2'('z); $display("%b %0d", x, x);
        y = 2'('z); $display("%b %0d", y, y);
26
    end
27
endmodule