PlTbUtils  1.3
PlTbUtils is a collection of functions, procedures and components for easily creating stimuli and checking response in automatic self-checking testbenches.
dut_example.vhd
Go to the documentation of this file.
1 
38 
39 library ieee;
40  use ieee.std_logic_1164.all;
41  use ieee.numeric_std.all;
42 
43 entity dut_example is
44  generic (
45  G_WIDTH : integer := 8;
46  G_DISABLE_BUGS : integer range 0 to 1 := 1
47  );
48  port (
49  clk_i : in std_logic;
50  rst_i : in std_logic;
51  carry_i : in std_logic;
52  x_i : in std_logic_vector(G_WIDTH - 1 downto 0);
53  y_i : in std_logic_vector(G_WIDTH - 1 downto 0);
54  sum_o : out std_logic_vector(G_WIDTH - 1 downto 0);
55  carry_o : out std_logic
56  );
57 end entity dut_example;
58 
59 architecture rtl of dut_example is
60 
61  signal x : unsigned(G_WIDTH downto 0);
62  signal y : unsigned(G_WIDTH downto 0);
63  signal c : unsigned(G_WIDTH downto 0);
64  signal sum : unsigned(G_WIDTH downto 0);
65 
66 begin
67 
68  x <= resize(unsigned(x_i), G_WIDTH + 1);
69  y <= resize(unsigned(y_i), G_WIDTH + 1);
70  c <= resize(unsigned(std_logic_vector('0' & carry_i)), G_WIDTH + 1);
71 
72  p_sum : process (clk_i) is
73  begin
74 
75  if (clk_i'event and clk_i = '1') then
76  if (rst_i = '1') then
77  sum <= (others => '0');
78  else
79  if (G_DISABLE_BUGS = 1) then
80  sum <= x + y + c;
81  else
82  sum <= x + y;
83  end if;
84  end if;
85  end if;
86 
87  end process p_sum;
88 
89  sum_o <= std_logic_vector(sum(sum'high - 1 downto 0));
90  carry_o <= sum(sum'high);
91 
92 end architecture rtl;
93 
unsigned( G_WIDTH downto 0) x
Definition: dut_example.vhd:61
unsigned( G_WIDTH downto 0) c
Definition: dut_example.vhd:63
unsigned( G_WIDTH downto 0) y
Definition: dut_example.vhd:62
unsigned( G_WIDTH downto 0) sum
Definition: dut_example.vhd:64
in y_i std_logic_vector( G_WIDTH- 1 downto 0)
Definition: dut_example.vhd:53
G_WIDTH integer := 8
Definition: dut_example.vhd:45
G_DISABLE_BUGS integer range 0 to 1:= 1
Definition: dut_example.vhd:47
out carry_o std_logic
Definition: dut_example.vhd:56
in carry_i std_logic
Definition: dut_example.vhd:51
in x_i std_logic_vector( G_WIDTH- 1 downto 0)
Definition: dut_example.vhd:52
in rst_i std_logic
Definition: dut_example.vhd:50
out sum_o std_logic_vector( G_WIDTH- 1 downto 0)
Definition: dut_example.vhd:54
in clk_i std_logic
Definition: dut_example.vhd:49