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

Subversion Repositories two_dimensional_fast_hartley_transform

[/] [two_dimensional_fast_hartley_transform/] [trunk/] [fht_bfly_noFF.v] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 irezki
//
2
// File: fht_8x8_core.v
3
// Author: Ivan Rezki
4
// Topic: RTL Core
5
//                2-Dimensional Fast Hartley Transform
6
//
7
 
8
// Fast Hartley Transform ButterFly Unit without input FF
9
 
10
module fht_bfly_noFF(
11
        a,
12
        b,
13
        c,
14
        d
15
);
16
 
17
parameter N = 8;
18
 
19
input   [N-1:0]  a; // input
20
input   [N-1:0]  b; // input
21
 
22
output  [N  :0]  c; // additive output
23
output  [N  :0]  d; // subtractive output
24
 
25
assign c = rca_N(a,b);
26
assign d = rca_N(a,twos_complement(b));
27
 
28
// +--------------------------------------------------+ \\
29
// +----------- Function's Description Part ----------+ \\
30
// +--------------------------------------------------+ \\
31
// Full Adder
32
        function [1:0] full_adder;
33
        input a, b, ci;
34
        reg co, s;
35
        begin
36
                s  = (a ^ b ^ ci);
37
                co = (a & b) | (ci & (a ^ b));
38
                full_adder = {co,s};
39
        end
40
        endfunction
41
 
42
// Half Adder, i.e. without carry in
43
        function [1:0] half_adder;
44
        input a, b;
45
        reg co, s;
46
        begin
47
                s  = (a ^ b);
48
                co = (a & b);
49
                half_adder = {co,s};
50
        end
51
        endfunction
52
 
53
// Ripple Carry Adder - rca
54
// Input  vector = N     bits
55
// Output vector = N + 1 bits
56
        function [N:0] rca_N;
57
 
58
//      parameter N = 8;
59
        input [N-1:0] a;
60
        input [N-1:0] b;
61
 
62
        reg [N-1:0] co,sum;
63
 
64
                begin : RCA // RIPPLE CARRY ADDER
65
                integer i;
66
                //for (i = 0; i <= N; i = i + 1)
67
                for (i = 0; i < N; i = i + 1)
68
                if (i == 0)
69
                                        {co[i],sum[i]} = half_adder(a[i],b[i]);
70
                                else
71
                                        {co[i],sum[i]} = full_adder(a[i],b[i],co[i-1]);
72
 
73
                rca_N[N-1:0] = sum;
74
                // MSB is a sign bit
75
                rca_N[N] = (a[N-1]==b[N-1]) ? co[N-1] : sum[N-1];
76
                end
77
        endfunction
78
 
79
 
80
        function [N-1:0] twos_complement;
81
        input [N-1:0] a;
82
        reg [N-1:0] ainv;
83
        reg [N:0] plus1;
84
        begin
85
                ainv  = ~a;
86
                plus1 = rca_N(ainv,{{N-1{1'b0}},1'b1});
87
 
88
        // synopsys translate_off
89
        // The only problem is absolute minumum negative value
90
        if (a == {1'b1, {N-1{1'b0}}}) $display("--->>> 2's complement ERROR - absolute minumum negative value");
91
        // synopsys translate_on
92
 
93
                twos_complement = plus1[N-1:0];
94
        end
95
        endfunction
96
 
97
endmodule

powered by: WebSVN 2.1.0

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