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

Subversion Repositories modbus

[/] [modbus/] [trunk/] [enlace/] [voting_circuit_2_of_3.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 guanucolui
--------------------------------------------------------------------------------
2
-- Company: University of Vigo
3
-- Engineer: L. Jacobo Alvarez Ruiz de Ojeda
4
--
5
-- Create Date:    10:57:05 10/18/06
6
-- Design Name:    
7
-- Module Name:    voting_circuit_2_of_3 - Behavioral
8
-- Project Name:   
9
-- Target Device:  
10
-- Tool versions:  
11
-- Description:
12
--
13
-- Dependencies:
14
-- 
15
-- Revision:
16
-- Revision 0.01 - File Created
17
-- Additional Comments:
18
-- 
19
--------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.STD_LOGIC_ARITH.ALL;
23
use IEEE.STD_LOGIC_UNSIGNED.ALL;
24
 
25
---- Uncomment the following library declaration if instantiating
26
---- any Xilinx primitives in this code.
27
--library UNISIM;
28
--use UNISIM.VComponents.all;
29
 
30
entity voting_circuit_2_of_3 is
31
    Port ( clk : in std_logic;
32
           reset : in std_logic;
33
           load_sample_1 : in std_logic;
34
           load_sample_2 : in std_logic;
35
           load_sample_3 : in std_logic;
36
           bit_input : in std_logic;
37
           sampled_bit : out std_logic;
38
           discrepancy : out std_logic);
39
end voting_circuit_2_of_3;
40
 
41
architecture Behavioral of voting_circuit_2_of_3 is
42
 
43
-- Signals declaration
44
signal sample_1, sample_2, sample_3: std_logic;
45
signal sample_vector: std_logic_vector (2 downto 0);
46
 
47
begin
48
 
49
-- Vector of samples
50
sample_vector <= sample_3 & sample_2 & sample_1;
51
 
52
-- Sample 1 register
53
Sample_1_register: process (clk, reset, load_sample_1)
54
begin
55
if reset = '1' then
56
        sample_1 <= '0';
57
elsif clk'event and clk ='1' then
58
        if load_sample_1 = '1' then sample_1 <= bit_input;
59
        end if;
60
end if;
61
end process;
62
 
63
-- Sample 2 register
64
Sample_2_register: process (clk, reset, load_sample_2)
65
begin
66
if reset = '1' then
67
        sample_2 <= '0';
68
elsif clk'event and clk ='1' then
69
        if load_sample_2 = '1' then sample_2 <= bit_input;
70
        end if;
71
end if;
72
end process;
73
 
74
-- Sample 3 register
75
Sample_3_register: process (clk, reset, load_sample_3)
76
begin
77
if reset = '1' then
78
        sample_3 <= '0';
79
elsif clk'event and clk ='1' then
80
        if load_sample_3 = '1' then sample_3 <= bit_input;
81
        end if;
82
end if;
83
end process;
84
 
85
-- Voting circuit (2 of 3)
86
with sample_vector select
87
        sampled_bit <= '1' when "011"|"101"|"110"|"111",
88
                                                '0' when others;
89
 
90
with sample_vector select
91
        discrepancy <= '0' when "000"|"111",
92
                                                '1' when others;
93
 
94
end Behavioral;

powered by: WebSVN 2.1.0

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