日常记录(100)nocasedef、数组切片+:、casex与casez

取消默认行的统计

https://bbs.eetop.cn/forum.php?mod=viewthread&tid=930288&page=1#pid10730364
image
image

数组切片

  • 位置j可以是变量,但是宽度k需要是常量
    image

image

module taa (input [1023:0] in, input [7:0] sel, output [3:0] out);
    assign out = in[sel*4+:4];
    /* assign out = {in[3+sel*4],in[2+sel*4],in[1+sel*4],in[sel*4]}; */
endmodule

module test_taa ();
    reg [1023:0] in;
    reg [7:0] sel;
    reg [3:0] out;

    taa t_inst(.*);
    initial begin
        int i;
        in = 1024'h1234567890;
        for (i = 0; i < 10; i++) begin
            #10 sel = i;
        end
        #10 $finish;
    end

    initial begin
        $monitor("in :%0h, sel %0h out %0h", in, sel, out);
    end
endmodule

输出

in :1234567890, sel xx out x
in :1234567890, sel 0 out 0
in :1234567890, sel 1 out 9
in :1234567890, sel 2 out 8
in :1234567890, sel 3 out 7
in :1234567890, sel 4 out 6
in :1234567890, sel 5 out 5
in :1234567890, sel 6 out 4
in :1234567890, sel 7 out 3
in :1234567890, sel 8 out 2
in :1234567890, sel 9 out 1

case语句

posted @ 2022-06-30 18:58  大浪淘沙、  阅读(77)  评论(0)    收藏  举报