forked from prasadp4009/tbengy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuvmTemplate.py
1543 lines (1219 loc) · 31.9 KB
/
uvmTemplate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
File : uvmTemplate.py
Author : Prasad Pandit
Email : [email protected]
Github : https://github.com/prasadp4009
Description : Base templates for Testbench Generation
"""
makefileStr="""\
# @Author : {0}
# @Date : {1}
work = work
top_tb_name = {2}_tb
ifeq ($(OS),Windows_NT)
ifneq ("$(wildcard ../rtl)","")
INCRTL = +incdir+../rtl
else
INCRTL =
endif
ifneq ("$(wildcard ../rtl/*.sv)","")
RTL = ../rtl/{2}.sv
else
RTL =
endif
ifneq ("$(wildcard ../sim/tb)","")
INCTB = +incdir+../sim/tb
else
INCTB =
endif
ifneq ("$(wildcard ../sim/tb/*.sv)","")
TB = ../sim/tb/{2}_tb.sv
else
TB =
endif
ifneq ("$(wildcard ../sim/env/agent)","")
INCINTF = +incdir+../sim/env/agent
else
INCINTF =
endif
ifneq ("$(wildcard ../sim/env/agent/*intf.sv)","")
INTF = ../sim/env/agent/{2}_intf.sv
else
INTF =
endif
ifneq ("$(wildcard ../sim/env/agent)","")
INCAGT = +incdir+../sim/env/agent
else
INCAGT =
endif
ifneq ("$(wildcard ../sim/env/agent/*pkg.sv)","")
AGT = ../sim/env/agent/{2}_agent_pkg.sv
else
AGT =
endif
ifneq ("$(wildcard ../sim/env/agent/sequence_lib)","")
INCSEQ_LIB = +incdir+../sim/env/agent/sequence_lib
else
INCSEQ_LIB =
endif
ifneq ("$(wildcard ../sim/env/agent/sequence_lib/*pkg.sv)","")
SEQ_LIB = ../sim/env/agent/sequence_lib/{2}_seq_pkg.sv
else
SEQ_LIB =
endif
ifneq ("$(wildcard ../sim/env)","")
INCENV = +incdir+../sim/env
else
INCENV =
endif
ifneq ("$(wildcard ../sim/env/*pkg.sv)","")
ENV = ../sim/env/{2}_env_pkg.sv
else
ENV =
endif
ifneq ("$(wildcard ../sim/env/agent/regs)","")
INCREG = +incdir+../sim/env/agent/regs
else
INCREG =
endif
ifneq ("$(wildcard ../sim/env/agent/regs/*pkg.sv)","")
REG = ../sim/env/agent/regs/{2}_regs_pkg.sv
else
REG =
endif
ifneq ("$(wildcard ../sim/tests)","")
INCTESTS = +incdir+../sim/tests
else
INCTESTS =
endif
ifneq ("$(wildcard ../sim/tests/*pkg.sv)","")
TESTS = ../sim/tests/{2}_test_pkg.sv
else
TESTS =
endif
else
ifneq ("$(wildcard ../rtl)","")
INCRTL = +incdir+../rtl
else
INCRTL =
endif
ifneq ("$(wildcard ../rtl/*.sv)","")
RTL = ../rtl/*.sv
else
RTL =
endif
ifneq ("$(wildcard ../sim/tb)","")
INCTB = +incdir+../sim/tb
else
INCTB =
endif
ifneq ("$(wildcard ../sim/tb/*.sv)","")
TB = ../sim/tb/*.sv
else
TB =
endif
ifneq ("$(wildcard ../sim/env/agent)","")
INCINTF = +incdir+../sim/env/agent
else
INCINTF =
endif
ifneq ("$(wildcard ../sim/env/agent/*intf.sv)","")
INTF = ../sim/env/agent/*intf.sv
else
INTF =
endif
ifneq ("$(wildcard ../sim/env/agent)","")
INCAGT = +incdir+../sim/env/agent
else
INCAGT =
endif
ifneq ("$(wildcard ../sim/env/agent/*pkg.sv)","")
AGT = ../sim/env/agent/*pkg.sv
else
AGT =
endif
ifneq ("$(wildcard ../sim/env/agent/sequence_lib)","")
INCSEQ_LIB = +incdir+../sim/env/agent/sequence_lib
else
INCSEQ_LIB =
endif
ifneq ("$(wildcard ../sim/env/agent/sequence_lib/*pkg.sv)","")
SEQ_LIB = ../sim/env/agent/sequence_lib/*pkg.sv
else
SEQ_LIB =
endif
ifneq ("$(wildcard ../sim/env)","")
INCENV = +incdir+../sim/env
else
INCENV =
endif
ifneq ("$(wildcard ../sim/env/*pkg.sv)","")
ENV = ../sim/env/*pkg.sv
else
ENV =
endif
ifneq ("$(wildcard ../sim/env/agent/regs)","")
INCREG = +incdir+../sim/env/agent/regs
else
INCREG =
endif
ifneq ("$(wildcard ../sim/env/agent/regs/*pkg.sv)","")
REG = ../sim/env/agent/regs/*pkg.sv
else
REG =
endif
ifneq ("$(wildcard ../sim/tests)","")
INCTESTS = +incdir+../sim/tests
else
INCTESTS =
endif
ifneq ("$(wildcard ../sim/tests/*pkg.sv)","")
TESTS = ../sim/tests/*pkg.sv
else
TESTS =
endif
endif
ifeq ($(OS),Windows_NT)
DELFILES = clean_dos
else
DELFILES = clean_linux
endif
cmp:
xvlog -work $(work) -i ../sim -sv $(RTL) $(SEQ_LIB) $(REG) $(INTF) $(AGT) $(ENV) $(TESTS) $(TB) -L uvm
xelab work.$(top_tb_name) -s $(top_tb_name)_sim -L uvm -timescale 1ns/1ps -debug all
run_sim_wave:
xsim -wdb sim.wdb -log session.log -t logw.tcl $(top_tb_name)_sim -testplusarg "UVM_TESTNAME={2}_sanity_test"
xsim sim.wdb -gui
view_wave:
xsim sim.wdb -gui
run_sim:
xsim -runall -log session.log $(top_tb_name)_sim -testplusarg "UVM_TESTNAME={2}_sanity_test"
clean_linux:
rm -rf modelsim.* transcript* vlog.* work vsim.wlf *.log *hbs *Xil xsim.dir *.jou *.pb
clear
clean_dos:
if exist modelsim.* del modelsim.* /F /S /Q /A
if exist transcript* del transcript* /F /S /Q /A
if exist vlog.* del vlog.* /F /S /Q /A
if exist vsim.wlf del vsim.wlf /F /S /Q /A
if exist *.log del *.log /F /S /Q /A
if exist work rd work /q /s
if exist covhtmlreport rd covhtmlreport /q /s
if exist *hbs del *hbs /q /s
if exist *Xil del *Xil /q /s
if exist xsim.dir del xsim.dir /q /s
if exist *.jou del *.jou /F /S /Q /A
if exist *.pb del *.pb /F /S /Q /A
clean_log:
if exist *.log del *.log /f /s /q /a
clean:
make $(DELFILES)
run_all:
make clean
make cmp
make run_sim
run_all_gui:
make clean
make cmp
make run_sim_wave
"""
makefileSVStr="""\
# @Author : {0}
# @Date : {1}
work = work
top_tb_name = {2}_tb
ifeq ($(OS),Windows_NT)
ifneq ("$(wildcard ../rtl)","")
INCRTL = +incdir+../rtl
else
INCRTL =
endif
ifneq ("$(wildcard ../rtl/*.sv)","")
RTL = ../rtl/{2}.sv
else
RTL =
endif
ifneq ("$(wildcard ../sim/tb)","")
INCTB = +incdir+../sim/tb
else
INCTB =
endif
ifneq ("$(wildcard ../sim/tb/*.sv)","")
TB = ../sim/tb/{2}_tb.sv
else
TB =
endif
else
ifneq ("$(wildcard ../rtl)","")
INCRTL = +incdir+../rtl
else
INCRTL =
endif
ifneq ("$(wildcard ../rtl/*.sv)","")
RTL = ../rtl/*.sv
else
RTL =
endif
ifneq ("$(wildcard ../sim/tb)","")
INCTB = +incdir+../sim/tb
else
INCTB =
endif
ifneq ("$(wildcard ../sim/tb/*.sv)","")
TB = ../sim/tb/*.sv
else
TB =
endif
endif
ifeq ($(OS),Windows_NT)
DELFILES = clean_dos
else
DELFILES = clean_linux
endif
cmp:
xvlog -work $(work) -i ../sim -sv $(RTL) $(TB) -L uvm -d "SIM=1"
xelab work.$(top_tb_name) -s $(top_tb_name)_sim -L uvm -timescale 1ns/1ps -debug all
run_sim_wave:
xsim -wdb sim.wdb -log session.log -t logw.tcl $(top_tb_name)_sim -testplusarg "CREATOR=pr454dP4nd!t"
xsim sim.wdb -gui
view_wave:
xsim sim.wdb -gui
run_sim:
xsim -runall -log session.log $(top_tb_name)_sim -testplusarg "CREATOR=pr454dP4nd!t"
clean_linux:
rm -rf modelsim.* transcript* vlog.* work vsim.wlf *.log *hbs *Xil xsim.dir *.jou *.pb
clear
clean_dos:
if exist modelsim.* del modelsim.* /F /S /Q /A
if exist transcript* del transcript* /F /S /Q /A
if exist vlog.* del vlog.* /F /S /Q /A
if exist vsim.wlf del vsim.wlf /F /S /Q /A
if exist *.log del *.log /F /S /Q /A
if exist work rd work /q /s
if exist covhtmlreport rd covhtmlreport /q /s
if exist *hbs del *hbs /q /s
if exist *Xil del *Xil /q /s
if exist xsim.dir del xsim.dir /q /s
if exist *.jou del *.jou /F /S /Q /A
if exist *.pb del *.pb /F /S /Q /A
clean_log:
if exist *.log del *.log /f /s /q /a
clean:
make $(DELFILES)
run_all:
make clean
make cmp
make run_sim
run_all_gui:
make clean
make cmp
make run_sim_wave
"""
xsimWaveTclStr="""\
log_wave -r *
run all
exit
"""
synthCommandStr="""\
synth:
vivado -mode batch -log ../synth/synth.log -source ./synth.tcl
"""
synthTclStr="""\
set outputDir ../synth
#Set FPGA
set_part {0}
# STEP#1: setup design sources and constraints
#read_vhdl -library bftLib [ glob ./Sources/hdl/bftLib/*.vhdl ]
#read_vhdl ./Sources/hdl/bft.vhdl
read_verilog -sv [ glob ../rtl/*.*v ]
#read_verilog [ glob ../rtl/*.v ]
#Board/FPGA XDC
read_xdc ../synth/{1}.xdc
# STEP#2: run synthesis, report utilization and timing estimates, write checkpoint design
synth_design -top {2}
write_checkpoint -force $outputDir/post_synth
report_utilization -file $outputDir/post_synth_util.rpt
report_timing -sort_by group -max_paths 5 -path_type summary
# STEP#3: run placement and logic optimization, report utilization and timing estimates
set_property SEVERITY {{Warning}} [get_drc_checks NSTD-1]
set_property SEVERITY {{Warning}} [get_drc_checks UCIO-1]
opt_design
power_opt_design
place_design
phys_opt_design
write_checkpoint -force $outputDir/post_place
report_clock_utilization -file $outputDir/clock_util.rpt
report_utilization -file $outputDir/post_place_util.rpt
report_timing -sort_by group -path_type summary
# STEP#4: run router, report actual utilization and timing, write checkpoint design, run DRCs
set_property SEVERITY {{Warning}} [get_drc_checks NSTD-1]
set_property SEVERITY {{Warning}} [get_drc_checks UCIO-1]
route_design
write_checkpoint -force $outputDir/post_route
report_timing_summary -file $outputDir/post_route_timing_summary.rpt
report_utilization -file $outputDir/post_route_util.rpt
report_power -file $outputDir/post_route_power.rpt
report_methodology -file $outputDir/post_impl_checks.rpt
report_drc -file $outputDir/post_imp_drc.rpt
write_verilog -force $outputDir/{2}_impl_netlist.v
write_xdc -no_fixed_only -force $outputDir/{1}_impl.xdc
# STEP#5: generate a bitstream
write_bitstream -force $outputDir/design.bit
# STEP#6: program device
open_hw_manager
connect_hw_server
get_hw_servers
current_hw_target
open_hw_target
set_property PROGRAM.FILE {{../synth/design.bit}} [current_hw_device]
program_hw_devices [current_hw_device]
"""
rtlModule = """\
`ifndef {0}__SV
`define {0}__SV
module {1}
(
input logic clk,
input logic we,
input logic [3:0] addr,
input logic [7:0] wdata,
output logic [7:0] rdata
);
logic [7:0] mem [16];
logic [3:0] addr_reg;
always_ff @(posedge clk) begin
if(we) begin
mem[addr] <= wdata;
end
addr_reg <= addr;
end
assign rdata = mem[addr_reg];
endmodule : {1}
`endif
//End of {1}
"""
rtlSVModule = """\
`ifndef {0}__SV
`define {0}__SV
module {1}
(
input logic clk,
input logic rst,
input logic [7:0] wdata,
output logic [7:0] rdata
);
always_ff @(posedge clk or negedge rst) begin
if(!rst) begin
rdata <= 'd0;
end
else begin
rdata <= wdata;
end
end
endmodule : {1}
`endif
//End of {1}
"""
rtlSVExModule = """\
`ifndef {0}__SV
`define {0}__SV
module {1}
(
input logic clk,
input logic rst,
output logic ledOut
);
`ifndef SIM
localparam bit [31:0] FREQCOUNT = 'd{2}000000;
`else
localparam bit [31:0] FREQCOUNT = 'd100;
`endif
logic [31:0] count;
always_ff @(posedge clk or posedge rst) begin
if (rst) begin
count <= 'd0;
ledOut <= 'd0;
end
else begin
if (count <= (FREQCOUNT-1)/2) begin
count <= count + 'd1;
end
else begin
count <= 'd0;
ledOut <= ~ledOut;
end
end
end
endmodule : {1}
`endif
//End of {1}
"""
tbModule = """\
`ifndef {0}_TB__SV
`define {0}_TB__SV
// Generated by tbengy. Created by Prasad Pandit.
`timescale 1ns/1ps
`include "uvm_macros.svh"
module {1}_tb;
import {1}_test_pkg::*;
import uvm_pkg::*;
logic clk;
{1}_intf intf(.clk(clk));
{1} DUT (
.clk(clk),
.we(intf.we),
.addr(intf.addr),
.wdata(intf.wdata),
.rdata(intf.rdata)
);
initial begin
clk = 0;
forever begin
#10 clk = ~clk;
end
end
initial begin
uvm_config_db #(virtual {1}_intf)::set(null, "*", "vintf", intf);
run_test();
end
endmodule
`endif
//End of {1}_tb
"""
tbSVModule = """\
`ifndef {0}_TB__SV
`define {0}_TB__SV
// Generated by tbengy. Created by Prasad Pandit.
`timescale 1ns/1ps
// `include "uvm_macros.svh" // Uncomment if you are adding UVM code
module {1}_tb;
// import uvm_pkg::*; // Uncomment if you are adding UVM code
logic clk;
logic rst;
logic [7:0] wdata;
logic [7:0] rdata;
{1} DUT (
.clk(clk),
.rst(rst),
.wdata(wdata),
.rdata(rdata)
);
task negDelay();
@(negedge clk);
endtask
initial begin
clk = 0;
forever begin
#10 clk = ~clk;
end
end
initial begin
rst = 0;
wdata = 0;
$display("------------- Starting Test -------------");
#10;
rst = 1;
negDelay;
wdata = 'h44;
negDelay;
wdata = 'h41;
negDelay;
wdata = 'h44;
negDelay;
wdata = 'h55;
#100 $finish;
end
endmodule
`endif
//End of {1}_tb
"""
tbSVExModule = """\
`ifndef {0}_TB__SV
`define {0}_TB__SV
// Generated by tbengy. Created by Prasad Pandit.
`timescale 1ns/1ps
// `include "uvm_macros.svh" // Uncomment if you are adding UVM code
module {1}_tb;
// import uvm_pkg::*; // Uncomment if you are adding UVM code
logic clk;
logic rst;
logic ledOut;
{1} DUT (
.clk(clk),
.rst(rst),
.ledOut(ledOut)
);
task negDelay();
@(negedge clk);
endtask
initial begin
clk = 0;
forever begin
#10 clk = ~clk;
end
end
initial begin
rst = 1;
$display("------------- Starting Test -------------");
#10;
rst = 0;
repeat(2000)
negDelay;
#100 $finish;
end
endmodule
`endif
//End of {1}_tb
"""
testPkg = """\
`ifndef {0}_TEST_PKG__SV
`define {0}_TEST_PKG__SV
package {1}_test_pkg;
// Import UVM
import uvm_pkg::*;
import {1}_seq_pkg::*;
import {1}_regs_pkg::*;
import {1}_agent_pkg::*;
import {1}_env_pkg::*;
`include "uvm_macros.svh"
// Import UVC
`include "{1}_base_test.sv"
`include "{1}_sanity_test.sv"
endpackage
`endif
//End of {1}_test_pkg
"""
baseTest = """\
`ifndef {0}_BASE_TEST__SV
`define {0}_BASE_TEST__SV
class {1}_base_test extends uvm_test;
// Factory Registration
`uvm_component_utils({1}_base_test)
// Declare UVC
{1}_env envh;
extern function new(string name = "{1}_base_test", uvm_component parent=null);
extern virtual function void build_phase(uvm_phase phase);
extern virtual function void connect_phase(uvm_phase phase);
extern virtual task run_phase(uvm_phase phase);
extern virtual function void report_phase(uvm_phase phase);
endclass
function {1}_base_test::new(string name = "{1}_base_test", uvm_component parent=null);
super.new(name, parent);
endfunction
function void {1}_base_test::build_phase(uvm_phase phase);
super.build_phase(phase);
envh = {1}_env::type_id::create("envh", this);
endfunction
function void {1}_base_test::connect_phase(uvm_phase phase);
super.connect_phase(phase);
endfunction
task {1}_base_test::run_phase(uvm_phase phase);
super.run_phase(phase);
phase.raise_objection(this);
`uvm_info(get_full_name(), "[{1}] Starting Base Test", UVM_NONE)
phase.drop_objection(this);
endtask
function void {1}_base_test::report_phase(uvm_phase phase);
uvm_top.print_topology();
endfunction
`endif
//End of {1}_base_test
"""
sanityTest = """\
`ifndef {0}_SANITY_TEST__SV
`define {0}_SANITY_TEST__SV
class {1}_sanity_test extends {1}_base_test;
// Factory Registration
`uvm_component_utils({1}_sanity_test)
// Sequence to start
{1}_sanity_seq seqh;
extern function new(string name = "{1}_sanity_test", uvm_component parent=null);
extern virtual function void build_phase(uvm_phase phase);
extern virtual function void connect_phase(uvm_phase phase);
extern virtual task run_phase(uvm_phase phase);
extern virtual function void report_phase(uvm_phase phase);
endclass
function {1}_sanity_test::new(string name = "{1}_sanity_test", uvm_component parent=null);
super.new(name, parent);
endfunction
function void {1}_sanity_test::build_phase(uvm_phase phase);
super.build_phase(phase);
endfunction
function void {1}_sanity_test::connect_phase(uvm_phase phase);
super.connect_phase(phase);
endfunction
task {1}_sanity_test::run_phase(uvm_phase phase);
super.run_phase(phase);
phase.raise_objection(this);
`uvm_info(get_full_name(), "[{1}] Starting sanity Test", UVM_NONE)
seqh = {1}_sanity_seq::type_id::create("seqh");
seqh.start(envh.agnth.seqrh);
phase.drop_objection(this);
endtask
function void {1}_sanity_test::report_phase(uvm_phase phase);
super.report_phase(phase);
endfunction
`endif
//End of {1}_sanity_test
"""
uvmEnv = """\
`ifndef {0}_ENV__SV
`define {0}_ENV__SV
class {1}_env extends uvm_env;
// Factory Registration
`uvm_component_utils({1}_env)
// Environment Variables
bit is_scoreboard_enable = 1;
bit is_coverage_enable = 1;
// Declare UVC
{1}_agent_cfg agnt_cfg;
{1}_agent agnth;
{1}_sb sbh;
{1}_cov covh;
extern function new (string name = "{1}_env", uvm_component parent = null);
extern virtual function void build_phase(uvm_phase phase);
extern virtual function void connect_phase(uvm_phase phase);
endclass
function {1}_env::new(string name = "{1}_env", uvm_component parent = null);
super.new(name, parent);
endfunction
function void {1}_env::build_phase(uvm_phase phase);
super.build_phase(phase);
`uvm_info(get_full_name(), "[{0}] Starting Build Phase", UVM_LOW)
agnt_cfg = {1}_agent_cfg::type_id::create("agnt_cfg");
uvm_config_db #({1}_agent_cfg)::set(this, "*", "agnt_cfg", agnt_cfg);
agnth = {1}_agent::type_id::create("agnth", this);
if(is_scoreboard_enable) begin
sbh = {1}_sb::type_id::create("sbh", this);
end
if(is_coverage_enable) begin
covh = {1}_cov::type_id::create("covh", this);
end
`uvm_info(get_full_name(), "[{0}] Ending Build Phase", UVM_LOW)
endfunction
function void {1}_env::connect_phase(uvm_phase phase);
super.connect_phase(phase);
`uvm_info(get_full_name(), "[{0}] Starting Connect Phase", UVM_LOW)
if(is_scoreboard_enable) begin
agnth.monh.mon_port.connect(sbh.sb_fifo.analysis_export);
end
if(is_coverage_enable) begin
agnth.monh.mon_port.connect(covh.analysis_export);
end
`uvm_info(get_full_name(), "[{0}] Ending Connect Phase", UVM_LOW)
endfunction
`endif
//End of {1}_env
"""
envPkg = """\
`ifndef {0}_ENV_PKG__SV
`define {0}_ENV_PKG__SV
package {1}_env_pkg;
// Import UVM
import uvm_pkg::*;
import {1}_seq_pkg::*;
import {1}_regs_pkg::*;
import {1}_agent_pkg::*;
`include "uvm_macros.svh"
// Import UVM
`include "{1}_sb.sv"
`include "{1}_cov.sv"
`include "{1}_env.sv"
endpackage
`endif
//End of {1}_env_pkg
"""
uvmSb = """\
`ifndef {0}_SB__SV
`define {0}_SB__SV
class {1}_sb extends uvm_scoreboard;
// Factory Registration
`uvm_component_utils({1}_sb)
// Analysis Fifo
uvm_tlm_analysis_fifo #({1}_seq_item) sb_fifo;
// Data Item
{1}_seq_item seq_item;
// Tasks and Functions
extern function new(string name = "{1}_sb", uvm_component parent = null);
extern virtual function void build_phase(uvm_phase phase);
extern virtual task run_phase(uvm_phase phase);
endclass
function {1}_sb::new(string name = "{1}_sb", uvm_component parent = null);
super.new(name, parent);
endfunction
function void {1}_sb::build_phase(uvm_phase phase);
super.build_phase(phase);
sb_fifo = new("sb_fifo", this);
endfunction
task {1}_sb::run_phase(uvm_phase phase);
forever begin
sb_fifo.get(seq_item);
`uvm_info(get_full_name(), "[{0}] Received new item in SB", UVM_LOW)
`uvm_info(get_full_name(), $sformatf("\\n[{0}] Packet Data:\\n\\twe: %0d,\\n\\taddr: %0d,\\n\\twdata: %0d,\\n\\trdata: %0d",
seq_item.we, seq_item.addr, seq_item.wdata, seq_item.rdata), UVM_LOW)
end
endtask
`endif
//End of {1}_sb
"""
uvmCov = """\
`ifndef {0}_COV__SV
`define {0}_COV__SV
class {1}_cov extends uvm_subscriber#({1}_seq_item);
// Factory Registration
`uvm_component_utils({1}_cov)
extern function new(string name = "{1}_cov", uvm_component parent = null);
extern virtual function void write({1}_seq_item t);
endclass
function {1}_cov::new(string name = "{1}_cov", uvm_component parent = null);
super.new(name, parent);
endfunction
function void {1}_cov::write({1}_seq_item t);
`uvm_info(get_full_name(), "[{0}] Received item in Subscriber", UVM_LOW)
`uvm_info(get_full_name(), $sformatf("\\n[{0}] Packet Data:\\n\\twe: %0d,\\n\\taddr: %0d,\\n\\twdata: %0d,\\n\\trdata: %0d",
t.we, t.addr, t.wdata, t.rdata), UVM_LOW)
endfunction
`endif
//End of {1}_cov
"""
agntPkg = """\
`ifndef {0}_AGENT_PKG__SV
`define {0}_AGENT_PKG__SV
package {1}_agent_pkg;
// Import UVM
import uvm_pkg::*;
import {1}_regs_pkg::*;
import {1}_seq_pkg::*;
`include "uvm_macros.svh"
// Include Agent UVCs
// `include "{1}_intf.sv"
`include "{1}_agent_cfg.sv"
`include "{1}_driver.sv"
`include "{1}_monitor.sv"