1 |
2 |
pela |
----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- PlTbUtils Example Testbench ----
|
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 an example which demonstrates how PlTbUtils ----
|
14 |
|
|
---- can be used. ----
|
15 |
|
|
---- ----
|
16 |
|
|
---- ----
|
17 |
|
|
---- To Do: ----
|
18 |
|
|
---- - ----
|
19 |
|
|
---- ----
|
20 |
|
|
---- Author(s): ----
|
21 |
|
|
---- - Per Larsson, pela@opencores.org ----
|
22 |
|
|
---- ----
|
23 |
|
|
----------------------------------------------------------------------
|
24 |
|
|
---- ----
|
25 |
|
|
---- Copyright (C) 2013 Authors and OPENCORES.ORG ----
|
26 |
|
|
---- ----
|
27 |
|
|
---- This source file may be used and distributed without ----
|
28 |
|
|
---- restriction provided that this copyright statement is not ----
|
29 |
|
|
---- removed from the file and that any derivative work contains ----
|
30 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
31 |
|
|
---- ----
|
32 |
|
|
---- This source file is free software; you can redistribute it ----
|
33 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
34 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
35 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
36 |
|
|
---- later version. ----
|
37 |
|
|
---- ----
|
38 |
|
|
---- This source is distributed in the hope that it will be ----
|
39 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
40 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
41 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
42 |
|
|
---- details. ----
|
43 |
|
|
---- ----
|
44 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
45 |
|
|
---- Public License along with this source; if not, download it ----
|
46 |
|
|
---- from http://www.opencores.org/lgpl.shtml ----
|
47 |
|
|
---- ----
|
48 |
|
|
----------------------------------------------------------------------
|
49 |
|
|
library ieee;
|
50 |
|
|
use ieee.std_logic_1164.all;
|
51 |
|
|
use std.textio.all;
|
52 |
|
|
use work.txt_util.all;
|
53 |
|
|
use work.pltbutils_func_pkg.all;
|
54 |
|
|
use work.pltbutils_comp_pkg.all;
|
55 |
|
|
|
56 |
|
|
entity tb_example is
|
57 |
|
|
generic (
|
58 |
|
|
G_WIDTH : integer := 8;
|
59 |
|
|
G_CLK_PERIOD : time := 10 ns;
|
60 |
|
|
G_DISABLE_BUGS : integer range 0 to 1 := 0
|
61 |
|
|
);
|
62 |
|
|
end entity tb_example;
|
63 |
|
|
|
64 |
|
|
architecture bhv of tb_example is
|
65 |
|
|
|
66 |
|
|
-- Simulation status- and control signals
|
67 |
|
|
signal test_num : integer;
|
68 |
|
|
-- VHDL-1993:
|
69 |
|
|
--signal test_name : string(pltbutils_test_name'range);
|
70 |
|
|
--signal info : string(pltbutils_info'range);
|
71 |
|
|
-- VHDL-2002:
|
72 |
|
|
signal test_name : string(pltbutils_sc.test_name'range);
|
73 |
|
|
signal info : string(pltbutils_sc.info'range);
|
74 |
|
|
|
75 |
|
|
signal checks : integer;
|
76 |
|
|
signal errors : integer;
|
77 |
|
|
signal stop_sim : std_logic;
|
78 |
|
|
|
79 |
|
|
-- DUT stimuli and response signals
|
80 |
|
|
signal clk : std_logic;
|
81 |
|
|
signal rst : std_logic;
|
82 |
|
|
signal carry_in : std_logic;
|
83 |
|
|
signal x : std_logic_vector(G_WIDTH-1 downto 0);
|
84 |
|
|
signal y : std_logic_vector(G_WIDTH-1 downto 0);
|
85 |
|
|
signal sum : std_logic_vector(G_WIDTH-1 downto 0);
|
86 |
|
|
signal carry_out : std_logic;
|
87 |
|
|
|
88 |
|
|
begin
|
89 |
|
|
|
90 |
|
|
-- Simulation status and control for viewing in waveform window
|
91 |
|
|
-- VHDL-1993:
|
92 |
|
|
--test_num <= pltbutils_test_num;
|
93 |
|
|
--test_name <= pltbutils_test_name;
|
94 |
|
|
--checks <= pltbutils_chk_cnt;
|
95 |
|
|
--errors <= pltbutils_err_cnt;
|
96 |
|
|
-- VHDL-2002:
|
97 |
|
|
test_num <= pltbutils_sc.test_num;
|
98 |
|
|
test_name <= pltbutils_sc.test_name;
|
99 |
|
|
info <= pltbutils_sc.info;
|
100 |
|
|
checks <= pltbutils_sc.chk_cnt;
|
101 |
|
|
errors <= pltbutils_sc.err_cnt;
|
102 |
|
|
stop_sim <= pltbutils_sc.stop_sim;
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
dut0 : entity work.dut_example
|
106 |
|
|
generic map (
|
107 |
|
|
G_WIDTH => G_WIDTH,
|
108 |
|
|
G_DISABLE_BUGS => G_DISABLE_BUGS
|
109 |
|
|
)
|
110 |
|
|
port map (
|
111 |
|
|
clk_i => clk,
|
112 |
|
|
rst_i => rst,
|
113 |
|
|
carry_i => carry_in,
|
114 |
|
|
x_i => x,
|
115 |
|
|
y_i => y,
|
116 |
|
|
sum_o => sum,
|
117 |
|
|
carry_o => carry_out
|
118 |
|
|
);
|
119 |
|
|
|
120 |
|
|
clkgen0 : pltbutils_clkgen
|
121 |
|
|
generic map(
|
122 |
|
|
G_PERIOD => G_CLK_PERIOD
|
123 |
|
|
)
|
124 |
|
|
port map(
|
125 |
|
|
clk_o => clk,
|
126 |
|
|
stop_sim_i => stop_sim
|
127 |
|
|
);
|
128 |
|
|
|
129 |
|
|
tc0 : entity work.tc_example
|
130 |
|
|
generic map (
|
131 |
|
|
G_WIDTH => G_WIDTH
|
132 |
|
|
)
|
133 |
|
|
port map(
|
134 |
|
|
clk => clk,
|
135 |
|
|
rst => rst,
|
136 |
|
|
carry_in => carry_in,
|
137 |
|
|
x => x,
|
138 |
|
|
y => y,
|
139 |
|
|
sum => sum,
|
140 |
|
|
carry_out => carry_out
|
141 |
|
|
);
|
142 |
|
|
|
143 |
|
|
end architecture bhv;
|