-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathComparator.vhd
More file actions
42 lines (36 loc) · 873 Bytes
/
Comparator.vhd
File metadata and controls
42 lines (36 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
-- VHDL code for Comparator
-- Header file declaration
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Entity declaration
ENTITY Comparator IS
GENERIC (n : NATURAL := 2);
PORT (
A : IN STD_LOGIC_VECTOR(n - 1 DOWNTO 0);
B : IN STD_LOGIC_VECTOR(n - 1 DOWNTO 0);
less : OUT STD_LOGIC;
equal : OUT STD_LOGIC;
greater : OUT STD_LOGIC
);
END Comparator;
-- Dataflow Modelling Style
-- Architecture declaration
ARCHITECTURE behv OF Comparator IS
BEGIN
PROCESS (A, B)
BEGIN
IF (A < B) THEN
less <= '1';
equal <= '0';
greater <= '0';
ELSIF (A = B) THEN
less <= '0';
equal <= '1';
greater <= '0';
ELSE
less <= '0';
equal <= '0';
greater <= '1';
END IF;
END PROCESS;
END behv;