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

Subversion Repositories simple_uart_for_fpga

[/] [simple_uart_for_fpga/] [trunk/] [source/] [comp/] [uart_parity.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jakubcabal
--------------------------------------------------------------------------------
2
-- PROJECT: SIMPLE UART FOR FPGA
3
--------------------------------------------------------------------------------
4
-- MODULE:  UART PARITY BIT GENERATOR
5
-- AUTHORS: Jakub Cabal <jakubcabal@gmail.com>
6
-- lICENSE: The MIT License (MIT)
7
-- WEBSITE: https://github.com/jakubcabal/uart_for_fpga
8
--------------------------------------------------------------------------------
9
 
10
library IEEE;
11
use IEEE.STD_LOGIC_1164.ALL;
12
use IEEE.NUMERIC_STD.ALL;
13
 
14
entity UART_PARITY is
15
    Generic (
16
        DATA_WIDTH  : integer := 8;
17
        PARITY_TYPE : string  := "none" -- legal values: "none", "even", "odd", "mark", "space"
18
    );
19
    Port (
20
        DATA_IN     : in  std_logic_vector(DATA_WIDTH-1 downto 0);
21
        PARITY_OUT  : out std_logic
22
    );
23
end UART_PARITY;
24
 
25
architecture FULL of UART_PARITY is
26
 
27
begin
28
 
29
    -- -------------------------------------------------------------------------
30
    -- PARITY BIT GENERATOR
31
    -- -------------------------------------------------------------------------
32
 
33
    even_parity_g : if (PARITY_TYPE = "even") generate
34
 
35
        process (DATA_IN)
36
                variable parity_temp : std_logic;
37
        begin
38
            parity_temp := '0';
39
            for i in DATA_IN'range loop
40
                parity_temp := parity_temp XOR DATA_IN(i);
41
            end loop;
42
            PARITY_OUT <= parity_temp;
43
        end process;
44
 
45
    end generate;
46
 
47
    odd_parity_g : if (PARITY_TYPE = "odd") generate
48
 
49
        process (DATA_IN)
50
                variable parity_temp : std_logic;
51
        begin
52
            parity_temp := '1';
53
            for i in DATA_IN'range loop
54
                parity_temp := parity_temp XOR DATA_IN(i);
55
            end loop;
56
            PARITY_OUT <= parity_temp;
57
        end process;
58
 
59
    end generate;
60
 
61
    mark_parity_g : if (PARITY_TYPE = "mark") generate
62
 
63
        PARITY_OUT <= '1';
64
 
65
    end generate;
66
 
67
    space_parity_g : if (PARITY_TYPE = "space") generate
68
 
69
        PARITY_OUT <= '0';
70
 
71
    end generate;
72
 
73
end FULL;

powered by: WebSVN 2.1.0

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