1 |
75 |
pela |
----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- PlTbUtils Testbench Template 1 ----
|
4 |
|
|
---- ----
|
5 |
|
|
---- This file is part of the PlTbUtils project ----
|
6 |
|
|
---- http://opencores.org/project,pltbutils ----
|
7 |
|
|
---- ----
|
8 |
|
|
---- Description: ----
|
9 |
|
|
---- PlTbUtils is a collection of functions, procedures and ----
|
10 |
|
|
---- components for easily creating stimuli and checking response ----
|
11 |
|
|
---- in automatic self-checking testbenches. ----
|
12 |
|
|
---- ----
|
13 |
|
|
---- This file is a template, which can be used as a base when ----
|
14 |
|
|
---- testbenches which use PlTbUtils. ----
|
15 |
|
|
---- Copy this file to your preferred location and rename the ----
|
16 |
|
|
---- copied file and its contents, by replacing the word ----
|
17 |
|
|
---- "template" with a name for your design. ----
|
18 |
|
|
---- Also remove informative comments enclosed in < ... > . ----
|
19 |
|
|
---- ----
|
20 |
|
|
---- ----
|
21 |
|
|
---- To Do: ----
|
22 |
|
|
---- - ----
|
23 |
|
|
---- ----
|
24 |
|
|
---- Author(s): ----
|
25 |
96 |
pela |
---- - Per Larsson, pela.opencores@gmail.com ----
|
26 |
75 |
pela |
---- ----
|
27 |
|
|
----------------------------------------------------------------------
|
28 |
|
|
---- ----
|
29 |
|
|
---- Copyright (C) 2013-2014 Authors and OPENCORES.ORG ----
|
30 |
|
|
---- ----
|
31 |
|
|
---- This source file may be used and distributed without ----
|
32 |
|
|
---- restriction provided that this copyright statement is not ----
|
33 |
|
|
---- removed from the file and that any derivative work contains ----
|
34 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
35 |
|
|
---- ----
|
36 |
|
|
---- This source file is free software; you can redistribute it ----
|
37 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
38 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
39 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
40 |
|
|
---- later version. ----
|
41 |
|
|
---- ----
|
42 |
|
|
---- This source is distributed in the hope that it will be ----
|
43 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
44 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
45 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
46 |
|
|
---- details. ----
|
47 |
|
|
---- ----
|
48 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
49 |
|
|
---- Public License along with this source; if not, download it ----
|
50 |
|
|
---- from http://www.opencores.org/lgpl.shtml ----
|
51 |
|
|
---- ----
|
52 |
|
|
----------------------------------------------------------------------
|
53 |
|
|
library ieee;
|
54 |
|
|
use ieee.std_logic_1164.all;
|
55 |
|
|
use std.textio.all;
|
56 |
|
|
use work.txt_util.all;
|
57 |
|
|
use work.pltbutils_func_pkg.all;
|
58 |
|
|
use work.pltbutils_comp_pkg.all;
|
59 |
|
|
-- < Template info: add more libraries here, if needed >
|
60 |
|
|
|
61 |
|
|
entity tb_template1 is
|
62 |
|
|
generic (
|
63 |
|
|
-- < Template info: add generics here if needed, or remove the generic block >
|
64 |
|
|
);
|
65 |
|
|
end entity tb_template1;
|
66 |
|
|
|
67 |
|
|
architecture bhv of tb_template1 is
|
68 |
|
|
|
69 |
|
|
-- Simulation status- and control signals
|
70 |
|
|
-- for accessing .stop_sim and for viewing in waveform window
|
71 |
|
|
signal pltbs : pltbs_t := C_PLTBS_INIT;
|
72 |
|
|
|
73 |
|
|
-- DUT stimuli and response signals
|
74 |
|
|
signal clk : std_logic;
|
75 |
|
|
signal rst : std_logic;
|
76 |
|
|
-- < Template info: add more DUT stimuli and response signals here. >
|
77 |
|
|
|
78 |
|
|
begin
|
79 |
|
|
|
80 |
|
|
dut0 : entity work.template
|
81 |
|
|
generic map (
|
82 |
|
|
-- < Template info: add DUT generics here, if any. >
|
83 |
|
|
)
|
84 |
|
|
port map (
|
85 |
|
|
clk_i => clk, -- Template example
|
86 |
|
|
rst_i => rst, -- Template example
|
87 |
|
|
-- < Template info: add more DUT ports here. >
|
88 |
|
|
);
|
89 |
|
|
|
90 |
|
|
clkgen0 : pltbutils_clkgen
|
91 |
|
|
generic map(
|
92 |
|
|
G_PERIOD => G_CLK_PERIOD
|
93 |
|
|
)
|
94 |
|
|
port map(
|
95 |
|
|
clk_o => clk,
|
96 |
|
|
stop_sim_i => pltbs.stop_sim
|
97 |
|
|
);
|
98 |
|
|
|
99 |
|
|
-- Testcase process
|
100 |
|
|
p_tc1 : process
|
101 |
|
|
variable pltbv : pltbv_t := C_PLTBV_INIT;
|
102 |
|
|
begin
|
103 |
|
|
startsim("tc1", pltbv, pltbs);
|
104 |
|
|
rst <= '1'; -- Template example
|
105 |
|
|
-- < Template info: initialize other DUT stimuli here. >
|
106 |
|
|
|
107 |
|
|
starttest(1, "Reset test", pltbv, pltbs); -- Template example
|
108 |
|
|
waitclks(2, clk, pltbv, pltbs); -- Template example
|
109 |
|
|
check("template_signal during reset", template_signal, 0, pltbv, pltbs); -- Template example
|
110 |
|
|
-- < Template info: check other DUT outputs here.
|
111 |
|
|
rst <= '0'; -- Template example
|
112 |
|
|
endtest(pltbv, pltbs);
|
113 |
|
|
|
114 |
|
|
starttest(2, "Template test", pltbv, pltbs);
|
115 |
|
|
-- < Template info: set all relevant DUT inputs here. >
|
116 |
|
|
waitclks(2, clk, pltbv, pltbs); -- Template example
|
117 |
|
|
-- < Template info: check all relevant DUT outputs here. >
|
118 |
|
|
endtest(pltbv, pltbs);
|
119 |
|
|
-- < Template info: add more tests here. >
|
120 |
|
|
|
121 |
|
|
endsim(pltbv, pltbs, true);
|
122 |
|
|
wait;
|
123 |
|
|
end process p_tc1;
|
124 |
|
|
|
125 |
|
|
end architecture bhv;
|