Skip to content

Commit 8593c42

Browse files
committed
upload ovm_demo_v3
1 parent 24b3829 commit 8593c42

File tree

14 files changed

+325
-0
lines changed

14 files changed

+325
-0
lines changed

ovm_demo_v3/00_src/and2.v

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module and2 (
2+
output reg Y,
3+
input A, B,
4+
input clk,
5+
input rst);
6+
7+
always @(posedge clk or negedge rst)
8+
begin
9+
if(rst==1)
10+
Y <= 0;
11+
else
12+
Y= A&B;
13+
end
14+
15+
endmodule
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
class and_agent extends ovm_component;
2+
3+
`ovm_component_utils(and_agent);
4+
virtual and_if and_vif;
5+
function new(string name, ovm_component parent);
6+
super.new(name, parent);
7+
endfunction
8+
9+
function void build();
10+
ovm_report_info("build", "");
11+
12+
endfunction
13+
14+
function void connect();
15+
ovm_report_info("connect", "");
16+
endfunction
17+
18+
function void end_of_elaboration();
19+
ovm_report_info("end_of_elaboration", "");
20+
endfunction
21+
22+
function void start_of_simulation();
23+
ovm_report_info("start_of_simulation", "");
24+
endfunction
25+
26+
task run();
27+
ovm_report_info("run", "");
28+
29+
endtask
30+
31+
function void extract();
32+
ovm_report_info("extract", "");
33+
endfunction
34+
35+
function void check();
36+
ovm_report_info("check", "");
37+
endfunction
38+
39+
function void report();
40+
ovm_report_info("report", "");
41+
endfunction
42+
43+
44+
45+
endclass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
`include "../00_bench/agent/and_agent/and_if.sv"
2+
`include "../00_bench/agent/and_agent/and_agent.sv"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
interface and_if();
2+
logic rst;
3+
logic clk;
4+
logic A;
5+
logic B;
6+
logic Y;
7+
parameter U_DLY = 1ps;
8+
9+
initial begin
10+
if(rst==1)
11+
begin
12+
A<=0;
13+
B<=0;
14+
end
15+
else
16+
gen_AB();
17+
18+
end
19+
20+
task gen_AB();
21+
automatic int stim_num=100;
22+
23+
while(stim_num>0) begin
24+
@(posedge clk)
25+
A<=#U_DLY $random();
26+
B<=#U_DLY $random();
27+
stim_num--;
28+
end
29+
endtask: gen_AB
30+
31+
32+
endinterface:and_if
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~
2+
// ~ --
3+
// ~ Published by: www.asic-digital-design.com
4+
// ~ --
5+
// ~ Description: This is clock generator model.
6+
// ~ --
7+
// ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~
8+
//`timescale 1ps/1ps
9+
module clock_gen ( clk, arst );
10+
output clk;
11+
input arst;
12+
13+
parameter param_time_end_of_sim = 1000000;
14+
parameter param_clock_half_period = 50;
15+
reg clk_i;
16+
17+
// clock generation
18+
initial begin
19+
{clk_i} <= 1'b0;
20+
#(param_time_end_of_sim) $finish;
21+
end
22+
//end initial
23+
24+
always @(*)
25+
begin
26+
if(arst==1)
27+
{clk_i} <= 1'b0;
28+
else
29+
#(param_clock_half_period) {clk_i} <= ~(clk_i);
30+
end
31+
32+
// outputs --
33+
assign {clk}=clk_i;
34+
//--
35+
endmodule
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~
2+
// ~ --
3+
// ~ Published by: www.asic-digital-design.com
4+
// ~ --
5+
// ~ Description: This is reset generator model.
6+
// ~ --
7+
// ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~
8+
//`timescale 1ps/1ps
9+
module reset_gen ( arst );
10+
output arst;
11+
12+
parameter param_reset_delay = 25;
13+
14+
reg arst_i;
15+
16+
// reset generation
17+
initial begin
18+
{arst_i}<=1'b1;
19+
#(param_reset_delay) {arst_i}<=1'b0;
20+
end
21+
//end initial
22+
23+
// outputs --
24+
assign {arst}=arst_i;
25+
//--
26+
endmodule

ovm_demo_v3/03_st/00_bench/harness.sv

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import ovm_pkg::*;
2+
`timescale 1ps/1ps
3+
`include "../00_bench/clk_rst/reset_gen.sv"
4+
`include "../00_bench/clk_rst/clock_gen.sv"
5+
6+
`include "ovm_macros.svh"
7+
8+
`include "../00_bench/agent/and_agent/and_agent.svh"
9+
10+
module harness();
11+
`include "../00_bench/testbench/tb.svh"
12+
`include "../03_testcase/tc.svh"
13+
14+
//output logic Clock;
15+
16+
//logic arst;
17+
and_if u_and_vif();
18+
19+
reset_gen u_reset_gen(u_and_vif.rst);
20+
clock_gen #(.param_time_end_of_sim(10000),.param_clock_half_period(50)) u_clock_gen( u_and_vif.clk, u_and_vif.rst );
21+
22+
initial begin
23+
$display("greetting from harness");
24+
fork
25+
// print_signal();
26+
27+
join_none
28+
run_test();
29+
$display("hahahhahh");
30+
// run_test();
31+
end
32+
33+
34+
and2 duv(
35+
.Y(u_and_vif.Y),
36+
.A(u_and_vif.A),
37+
.B(u_and_vif.B),
38+
.clk(u_and_vif.clk),
39+
.rst(u_and_vif.rst)
40+
);
41+
42+
endmodule
43+
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
class tb extends ovm_component;
2+
3+
`ovm_component_utils(tb);
4+
5+
and_agent o_and_agent;
6+
virtual and_if and_vif;
7+
8+
9+
function new(string name, ovm_component parent);
10+
super.new(name, parent);
11+
endfunction
12+
13+
function void build();
14+
ovm_report_info("build", "");
15+
o_and_agent = new("o_and_agent",this);
16+
this.and_vif = o_and_agent.and_vif;
17+
endfunction
18+
19+
function void connect();
20+
ovm_report_info("connect", "");
21+
endfunction
22+
23+
function void end_of_elaboration();
24+
ovm_report_info("end_of_elaboration", "");
25+
endfunction
26+
27+
function void start_of_simulation();
28+
ovm_report_info("start_of_simulation", "");
29+
endfunction
30+
31+
task run();
32+
ovm_report_info("run", "");
33+
34+
endtask
35+
36+
function void extract();
37+
ovm_report_info("extract", "");
38+
endfunction
39+
40+
function void check();
41+
ovm_report_info("check", "");
42+
endfunction
43+
44+
function void report();
45+
ovm_report_info("report", "");
46+
endfunction
47+
48+
function void tb_func();
49+
ovm_report_info("tb_func", "hello");
50+
endfunction: tb_func
51+
52+
endclass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`include "../00_bench/testbench/tb.sv"

ovm_demo_v3/03_st/02_script/rtl.f

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
../../00_src/and2.v
2+
3+
../00_bench/harness.sv

ovm_demo_v3/03_st/02_script/run.bat

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
::¹Ø±Õ»ØÏÔ
2+
::@ECHO OFF
3+
::ÉèÖÃÈí¼þ·¾¶
4+
5+
6+
7+
vsim -c -do sim.do
8+
9+
pause

ovm_demo_v3/03_st/02_script/sim.do

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set TEST_NAME tc01
2+
3+
vlib ../10_sim/work
4+
vmap work ../10_sim/work
5+
vlog -L mtiAvm -L mtiOvm -L mtiUvm -L mtiUPF -f rtl.f ../00_bench/harness.sv
6+
vsim -novopt work.harness +OVM_TESTNAME=$TEST_NAME
7+
8+
9+
add wave sim:/harness/u_and_vif/*
10+
add wave sim:/harness/duv/*
11+
view structure
12+
view signals
13+
run -all

ovm_demo_v3/03_st/03_testcase/tc.svh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`include "../03_testcase/tc01/tc01.sv"
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
class tc01 extends ovm_test;
2+
3+
`ovm_component_utils(tc01);
4+
tb o_tb;
5+
6+
function new(string name, ovm_component parent);
7+
super.new(name, parent);
8+
endfunction
9+
10+
function void build();
11+
ovm_report_info("build", "");
12+
o_tb = new("o_tb",this);
13+
o_tb.and_vif = harness.u_and_vif;
14+
endfunction
15+
16+
function void connect();
17+
ovm_report_info("connect", "");
18+
endfunction
19+
20+
function void end_of_elaboration();
21+
ovm_report_info("end_of_elaboration", "");
22+
endfunction
23+
24+
function void start_of_simulation();
25+
ovm_report_info("start_of_simulation", "");
26+
endfunction
27+
28+
task run();
29+
ovm_report_info("tc01", "start");
30+
o_tb.tb_func();
31+
#10000ps;
32+
global_stop_request();
33+
ovm_report_info("tc01", "finish");
34+
endtask
35+
36+
function void extract();
37+
ovm_report_info("extract", "");
38+
endfunction
39+
40+
function void check();
41+
ovm_report_info("check", "");
42+
endfunction
43+
44+
function void report();
45+
ovm_report_info("report", "");
46+
endfunction
47+
48+
endclass

0 commit comments

Comments
 (0)