CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
add2x2.vhd
Go to the documentation of this file.
1 
11 LIBRARY ieee ;
12 USE ieee.std_logic_1164.all;
13 USE ieee.numeric_std.all;
14 
15 
16 ENTITY add2x2 IS
17  PORT(
18  a : IN std_logic_vector (1 DOWNTO 0);
19  b : IN std_logic_vector (1 DOWNTO 0);
20  clk : IN std_logic;
21  sum : OUT std_logic_vector (1 DOWNTO 0)
22  );
23 
24 -- Declarations
25 
26 END add2x2 ;
27 
28 -- hds interface_end
29 ------------------------------------------------------------------------------
30 ARCHITECTURE rtl OF add2x2 IS
31 ------------------------------------------------------------------------------
32 -- 2-bit x 2 input adder, saturates at 3.
33 --
34 
35 BEGIN
36 
37  regproc1: process (a, b, clk)
38 
39  variable isum: integer;
40 
41  --
42  begin
43  if (clk'event and clk = '1') then
44  isum := to_integer(unsigned(a))
45  + to_integer(unsigned(b));
46  if (isum >= 3) then
47  sum <= "11";
48  else
49  sum <= std_logic_vector(to_unsigned(isum, 2));
50  end if;
51  end if;
52  end process;
53 
54 END rtl;
regproc1a,b,clk
Definition: add2x2.vhd:37
out sumstd_logic_vector (1 downto 0)
Definition: add2x2.vhd:21
in clkstd_logic
Definition: add2x2.vhd:20
in bstd_logic_vector (1 downto 0)
Definition: add2x2.vhd:19
in astd_logic_vector (1 downto 0)
Definition: add2x2.vhd:18
_library_ ieeeieee
Definition: parity_chk.vhd:18