日常记录(86)UART初步等细节

2022/6/1 23:20:29

本文主要是介绍日常记录(86)UART初步等细节,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

UART的RTL连接

左端的uart16550为需要验的模块
image

验证收集内容

https://gitee.com/bai-mengwei/my_uart_tb
LCR:控制读写格式的
MCR:调制解调控制寄存器
MSR:调制解调状态寄存器
断言:验证apb协议

onehot0

onehot0表示没有高(全为0),则仍然可以断言成功
image
可以用在检查片选信号上(片选信号每次最多选一个,可以不选)
image

binsof(x) intersect(y)

bins的选择条件
x的内容中,包括y的部分
image
如下示例
image

$stable

是上升沿||下降沿的一种取反。
image
在判定的时候,不稳定是指代前一个状态发生

module taa ();
    logic a;
    logic [2:0] b;
    logic c;

    initial begin
        a = 0;
        forever begin
            #10 a = ~a;
        end
    end

    initial begin
        b = 3'b0;
        forever begin
            #20 b = b + 1;
        end
    end

    initial begin
        c = 0;
        forever begin
            #5 c = ~c;
        end
    end

    property STABLE_TEST;
        @(posedge a)
        (!$stable(b) && $onehot(b)) |=> c;
    endproperty
    MY_ASSERT: assert property(STABLE_TEST);

    initial begin
        #100000;
        $finish;
    end
endmodule
test: taa wave
taa:
	vcs -full64 -sverilog -R -debug_access+all +vcs+vcdpluson taa.sv
debug:
	./simv -gui &
wave:
	dve -vpd vcdplus.vpd &

image

fork-join_none在task外的执行

module taa ();
    task task1();
        fork
            #10;
            $display("after 10 time");
        join_none
    endtask: task1

    task task2();
        fork
            #10;
            $display("after 10 time");
        join
    endtask: task2

    task task3();
        begin
            #10;
            $display("after 10 time");
        end
    endtask: task3

    initial begin
        $display("before");
        task1();
        #10;
        $display("task 1:fork join_none %t", $realtime);
        task2();
        #10;
        $display("task 2 %t fork join", $realtime);
        task3();
        #10;
        $display("task 3 %t begin end", $realtime);
        $finish;
    end
endmodule
taa:
	vcs -full64 -sverilog -R -debug_access+a taa.sv

输出

before
after 10 time
task 1:fork join_none                   10
after 10 time
task 2                   30 fork join
after 10 time
task 3                   50 begin end
$finish called from file "taa.sv", line 34.
$finish at simulation time                   50

非连续跟随重复符

image

连续重复运算符

image

非连续重复操作符

image

uvm_reg_predictor

如果使用镜像值获取数据(在function中使用),则必须定义uvm_reg_predictor并连接(bus_in)
image
image
例子
image

自定义概率生成数据的randcase

module taa ();
    initial begin
        int x;
        for (int i = 0; i < 10; i++) begin
            randcase
                1:x=1;
                2:x=2;
                3:x=3;
            endcase
            $display("x is %0d", x);
        end
    end
endmodule
taa:
	vcs -sverilog -R taa.sv

输出数据

x is 2
x is 3
x is 1
x is 3
x is 3
x is 3
x is 2
x is 1
x is 2
x is 3


这篇关于日常记录(86)UART初步等细节的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程