source: HDLQ/Library/MajorityVoterBI6.v @ 1

Revision 1, 1.3 KB checked in by ttvmrc00, 13 years ago (diff)

upload iniziale

Line 
1module MajorityVoter_bi6 (A, B, Zp, Z,status, fault1, fault0);
2        //Z and Zp are bidirectional.
3
4        input [1:0] status; //status 00=relax, 01=switch, 10=hold, 11=release
5        input A,B;
6        input fault1, fault0;
7        inout Z,Zp;
8        wor wi1, wi2, wi3;
9        wor wi1p, wi2p, wi3p;
10        wor Z,Zp;
11        reg  latchZ, latchZp;
12        // fault1=0 fault0=0 output fault free
13        // fault1=1 fault0=0 output S a B
14        // fault1=0(1) fault0=1 output Maj(A',B,C')
15        assign wi1 = ((A & B) | (B & Z) | (A & Z));
16        assign wi1p= ((A & B) | (B & Zp) | (A & Zp));
17        assign wi3 = ((~A & B) | (B & ~Z) | (~A & ~Z));
18        assign wi3p= ((~A & B) | (B & ~Zp) | (~A & ~Zp));
19        assign wi2 = (fault1)?  B : wi1;
20        assign wi2p = (fault1)?  B : wi1p;
21       
22        assign Zp  = (status==2'b10) ? latchZp :
23                     (status==2'b01)  ?  ((fault0) ?  ((wi3===1'bx) ? 1'bz: wi3) : ((wi2===1'bx) ? 1'bz : wi2) ):
24                     1'bz;
25       
26        assign Z   = (status==2'b10 ) ? latchZ:
27                     (status==2'b01 ) ?  ((fault0) ?  ((wi3p===1'bx )? 1'bz :wi3p) : ((wi2p===1'bx)? 1'bz : wi2p) ):
28                     1'bz;
29initial
30        begin
31        latchZp =1'bZ;
32        latchZ=1'bZ;
33        end
34always@ (posedge status[0])
35begin
36        always@(Zp or Z)
37        begin
38                if (Zp ===1'bz)
39                 begin
40                    latchZp <= Z;
41                    latchZ <= Zp;
42                 end   
43                if (Z====1'bz) 
44        end
45end
46
47always@(posedge status[1])
48                begin
49                if (status[0]==0)
50                        begin
51                                latchZp <= Zp===1'bx ?  1'bz :Zp;
52                                latchZ  <= Z===1'bx ?  1'bz :Z ;
53                        end
54                end
55endmodule
Note: See TracBrowser for help on using the repository browser.