summaryrefslogtreecommitdiff
path: root/A5.1/MyHDL/a5_homelien.v
blob: 9e07a556aab0b71772428c353ba78c39dcad6265 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// File: a5_homelien.v
// Generated by MyHDL 0.6
// Date: Sun Jan 18 02:22:21 2009

`timescale 1ns/10ps

module a5_homelien (
    clk,
    i,
    o
);

input clk;
input [2:0] i;
output o;
wire o;

wire r1_out;
reg [18:0] r1_reg;
wire r1_bit;
wire r3_out;
wire r2_clk;
reg [21:0] r2_reg;
wire r3_bit;
wire majority;
wire r3_clk;
reg [22:0] r3_reg;
wire r2_bit;
wire r2_out;
wire r1_clk;



always @(posedge clk) begin: A5_HOMELIEN_R1_1
    if (i[2]) begin
        r1_reg <= 0;
    end
    else if ((i[1] || (majority == r1_reg[8]))) begin
        r1_reg <= {r1_reg[(19 - 1)-1:0], r1_bit};
    end
end


assign r1_clk = r1_reg[8];
assign r1_out = r1_reg[(19 - 1)];

always @(posedge clk) begin: A5_HOMELIEN_R2_1
    if (i[2]) begin
        r2_reg <= 0;
    end
    else if ((i[1] || (majority == r2_reg[10]))) begin
        r2_reg <= {r2_reg[(22 - 1)-1:0], r2_bit};
    end
end


assign r2_clk = r2_reg[10];
assign r2_out = r2_reg[(22 - 1)];

always @(posedge clk) begin: A5_HOMELIEN_R3_1
    if (i[2]) begin
        r3_reg <= 0;
    end
    else if ((i[1] || (majority == r3_reg[10]))) begin
        r3_reg <= {r3_reg[(23 - 1)-1:0], r3_bit};
    end
end


assign r3_clk = r3_reg[10];
assign r3_out = r3_reg[(23 - 1)];


assign majority = (((r1_clk + r2_clk) + r3_clk) >= 2);
assign o = (r1_out ^ r2_out ^ r3_out);


assign r1_bit = (i[0] ^ r1_reg[13] ^ r1_reg[16] ^ r1_reg[17] ^ r1_reg[18]);
assign r2_bit = (i[0] ^ r2_reg[20] ^ r2_reg[21]);
assign r3_bit = (i[0] ^ r3_reg[7] ^ r3_reg[20] ^ r3_reg[21] ^ r3_reg[22]);

endmodule
personal git repositories of Harald Welte. Your mileage may vary