OpenCores
URL https://opencores.org/ocsvn/pltbutils/pltbutils/trunk

Subversion Repositories pltbutils

[/] [pltbutils/] [branches/] [dev_beta0002/] [examples/] [vhdl/] [rtl_example/] [dut_example.vhd] - Blame information for rev 96

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 pela
----------------------------------------------------------------------
2
----                                                              ----
3
---- PlTbUtils Example DUT                                        ----
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 component for use as DUT             ----
14
---- (Device Under Test) in tb_example.vhd, which demonstrates    ----
15
---- how PlTbUtils can be used.                                   ----
16
----                                                              ----
17
----                                                              ----
18
---- To Do:                                                       ----
19
---- -                                                            ----
20
----                                                              ----
21
---- Author(s):                                                   ----
22 96 pela
---- - Per Larsson, pela.opencores@gmail.com                      ----
23 2 pela
----                                                              ----
24
----------------------------------------------------------------------
25
----                                                              ----
26
---- Copyright (C) 2013 Authors and OPENCORES.ORG                 ----
27
----                                                              ----
28
---- This source file may be used and distributed without         ----
29
---- restriction provided that this copyright statement is not    ----
30
---- removed from the file and that any derivative work contains  ----
31
---- the original copyright notice and the associated disclaimer. ----
32
----                                                              ----
33
---- This source file is free software; you can redistribute it   ----
34
---- and/or modify it under the terms of the GNU Lesser General   ----
35
---- Public License as published by the Free Software Foundation; ----
36
---- either version 2.1 of the License, or (at your option) any   ----
37
---- later version.                                               ----
38
----                                                              ----
39
---- This source is distributed in the hope that it will be       ----
40
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
41
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
42
---- PURPOSE. See the GNU Lesser General Public License for more  ----
43
---- details.                                                     ----
44
----                                                              ----
45
---- You should have received a copy of the GNU Lesser General    ----
46
---- Public License along with this source; if not, download it   ----
47
---- from http://www.opencores.org/lgpl.shtml                     ----
48
----                                                              ----
49
----------------------------------------------------------------------
50
library ieee;
51
use ieee.std_logic_1164.all;
52
use ieee.numeric_std.all;
53
 
54
entity dut_example is
55
  generic (
56
    G_WIDTH         : integer := 8;
57
    G_DISABLE_BUGS  : integer range 0 to 1 := 1
58
  );
59
  port (
60
    clk_i           : in  std_logic;
61
    rst_i           : in  std_logic;
62
    carry_i         : in  std_logic;
63
    x_i             : in  std_logic_vector(G_WIDTH-1 downto 0);
64
    y_i             : in  std_logic_vector(G_WIDTH-1 downto 0);
65
    sum_o           : out std_logic_vector(G_WIDTH-1 downto 0);
66
    carry_o         : out std_logic
67
  );
68
end entity dut_example;
69
 
70
architecture rtl of dut_example is
71
  signal x          : unsigned(G_WIDTH downto 0);
72
  signal y          : unsigned(G_WIDTH downto 0);
73
  signal c          : unsigned(G_WIDTH downto 0);
74
  signal sum        : unsigned(G_WIDTH downto 0);
75
begin
76
 
77
  x <= resize(unsigned(x_i), G_WIDTH+1);
78
  y <= resize(unsigned(y_i), G_WIDTH+1);
79
  c <= resize(unsigned(std_logic_vector'('0' & carry_i)), G_WIDTH+1);
80
 
81
  p_sum : process(clk_i)
82
  begin
83
    if rising_edge(clk_i) then
84
      if rst_i = '1' then
85
        sum <= (others => '0');
86
      else
87
        if G_DISABLE_BUGS = 1 then
88
          sum <= x + y + c;
89
        else
90
          sum <= x + y;
91
        end if;
92
      end if;
93
    end if;
94
  end process;
95
 
96
  sum_o <= std_logic_vector(sum(sum'high-1 downto 0));
97
  carry_o <= sum(sum'high);
98
 
99
end architecture rtl;
100
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.