summaryrefslogtreecommitdiff
path: root/A5.1/Verilog/Piotr/majority.v
blob: c957d93594f9d04737b557d789c17cd18e2d1bf9 (plain)
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
//                              -*- Mode: Verilog -*-
// Filename        : majority.v
// Description     : Majority function
// Author          : piotr
// Created On      : Sun Jan 18 23:16:04 2009
// Last Modified By: .
// Last Modified On: .
// Update Count    : 0
// Status          : Unknown, Use with caution!

module majority(
		R1_clk_bit,
		R2_clk_bit,
		R3_clk_bit,
		R1_clk_out,
		R2_clk_out,
		R3_clk_out,
		);

   input R1_clk_bit;   
   input R2_clk_bit;   
   input R3_clk_bit;   
   output R1_clk_out;
   output R2_clk_out;   
   output R3_clk_out;

   wire   majority_bit;

   assign majority_bit = ( R1_clk_bit & R2_clk_bit ) ^ ( R2_clk_bit & R3_clk_bit ) ^ ( R1_clk_bit & R3_clk_bit );

   assign R1_clk_out = ! majority_bit ^ R1_clk_bit;
   assign R2_clk_out = ! majority_bit ^ R2_clk_bit;
   assign R3_clk_out = ! majority_bit ^ R3_clk_bit;
   
endmodule
personal git repositories of Harald Welte. Your mileage may vary