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

Subversion Repositories pairing

[/] [pairing/] [trunk/] [rtl/] [f3.v] - Blame information for rev 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 homer.xing
// f3_add: C == A+B (mod 3)
2
module f3_add(A, B, C);
3
    input [1:0] A, B;
4
    output [1:0] C;
5
    wire a0, a1, b0, b1, c0, c1;
6
    assign {a1, a0} = A;
7
    assign {b1, b0} = B;
8
    assign C = {c1, c0};
9
    assign c0 = ( a0 & !a1 & !b0 & !b1) |
10
                (!a0 & !a1 &  b0 & !b1) |
11
                (!a0 &  a1 & !b0 &  b1) ;
12
    assign c1 = (!a0 &  a1 & !b0 & !b1) |
13
                ( a0 & !a1 &  b0 & !b1) |
14
                (!a0 & !a1 & !b0 &  b1) ;
15
endmodule
16
 
17
// f3_sub: C == A-B (mod 3)
18
module f3_sub(A, B, C);
19
    input [1:0] A, B;
20
    output [1:0] C;
21
    f3_add m1(A, {B[0], B[1]}, C);
22
endmodule
23
 
24
// f3_mult: C = A*B (mod 3)
25
module f3_mult(A, B, C);
26
        input [1:0] A;
27
        input [1:0] B;
28
        output [1:0] C;
29
        wire a0, a1, b0, b1;
30
        assign {a1, a0} = A;
31
        assign {b1, b0} = B;
32
        assign C[0] = (!a1 & a0 & !b1 & b0) | (a1 & !a0 & b1 & !b0);
33
        assign C[1] = (!a1 & a0 & b1 & !b0) | (a1 & !a0 & !b1 & b0);
34
endmodule
35
 

powered by: WebSVN 2.1.0

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