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

Subversion Repositories pairing

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

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 8 homer.xing
    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 2 homer.xing
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 22 homer.xing
    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 2 homer.xing
endmodule
35
 
36 8 homer.xing
// c == a+1 (mod 3)
37
module f3_add1(a, c);
38
    input [1:0] a;
39
    output [1:0] c;
40
    assign c[0] = (~a[0]) & (~a[1]);
41
    assign c[1] = a[0] & (~a[1]);
42
endmodule
43
 
44
// c == a-1 (mod 3)
45
module f3_sub1(a, c);
46
    input [1:0] a;
47
    output [1:0] c;
48
    assign c[0] = (~a[0]) & a[1];
49
    assign c[1] = (~a[0]) & (~a[1]);
50
endmodule

powered by: WebSVN 2.1.0

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