前面章节,我们学习了怎么查看force信号,以及怎么在基于UVM平台下对信号进行force操作。今天,我们细致的研究下,force 信号对 RTL 代码中reg类型信号的影响。
先看例子:下面的例子中,clk,rst ,counter 三个信号,均声明为 reg 类型变量。我们着重关注一下 counter[7:0] 信号,该信号8bit,是一个计数器。
`timescale 1ns/1ps
import uvm_pkg::*;
//`include "uvm_pkg.sv"
//`include "uvm_macros.svh"
module tb_top();
reg clk,rst;
reg [7:0] counter;
initial begin
clk = 0;
forever #5 clk = ~ clk;
end
initial begin
rst = 1;
#30 rst = 0 ;
#25 rst = 1;
end
always @ (posedge clk or negedge rst) begin
if(!rst)
counter <= 8'b0;
else
counter <= counter +1;
end
initial begin
run_test("helloworld_test") ;
end
initial begin
$f