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 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 irezki
/**********************************************************************
2
 * File  : fht_8x8_core.v
3
 * Author: Ivan Rezki
4
 * email : irezki@gmail.com
5
 * Topic : RTL Core
6
 *                2-Dimensional Fast Hartley Transform
7
 *
8
 * Function: Fast Hartley Transform ButterFly Unit without input FF
9
 *
10
 * RIGHT TO USE: This code example, or any portion thereof, may be
11
 * used and distributed without restriction, provided that this entire
12
 * comment block is included with the example.
13
 *
14
 * DISCLAIMER: THIS CODE EXAMPLE IS PROVIDED "AS IS" WITHOUT WARRANTY
15
 * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED
16
 * TO WARRANTIES OF MERCHANTABILITY, FITNESS OR CORRECTNESS. IN NO
17
 * EVENT SHALL THE AUTHOR OR AUTHORS BE LIABLE FOR ANY DAMAGES,
18
 * INCLUDING INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF THE
19
 * USE OF THIS CODE.
20
 **********************************************************************/
21 2 irezki
 
22
module fht_bfly_noFF(
23
        a,
24
        b,
25
        c,
26
        d
27
);
28
 
29
parameter N = 8;
30
 
31
input   [N-1:0]  a; // input
32
input   [N-1:0]  b; // input
33
 
34
output  [N  :0]  c; // additive output
35
output  [N  :0]  d; // subtractive output
36
 
37
assign c = rca_N(a,b);
38
assign d = rca_N(a,twos_complement(b));
39
 
40
// +--------------------------------------------------+ \\
41
// +----------- Function's Description Part ----------+ \\
42
// +--------------------------------------------------+ \\
43
// Full Adder
44
        function [1:0] full_adder;
45
        input a, b, ci;
46
        reg co, s;
47
        begin
48
                s  = (a ^ b ^ ci);
49
                co = (a & b) | (ci & (a ^ b));
50
                full_adder = {co,s};
51
        end
52
        endfunction
53
 
54
// Half Adder, i.e. without carry in
55
        function [1:0] half_adder;
56
        input a, b;
57
        reg co, s;
58
        begin
59
                s  = (a ^ b);
60
                co = (a & b);
61
                half_adder = {co,s};
62
        end
63
        endfunction
64
 
65
// Ripple Carry Adder - rca
66
// Input  vector = N     bits
67
// Output vector = N + 1 bits
68
        function [N:0] rca_N;
69
 
70
//      parameter N = 8;
71
        input [N-1:0] a;
72
        input [N-1:0] b;
73
 
74
        reg [N-1:0] co,sum;
75
 
76
                begin : RCA // RIPPLE CARRY ADDER
77
                integer i;
78
                //for (i = 0; i <= N; i = i + 1)
79
                for (i = 0; i < N; i = i + 1)
80
                if (i == 0)
81
                                        {co[i],sum[i]} = half_adder(a[i],b[i]);
82
                                else
83
                                        {co[i],sum[i]} = full_adder(a[i],b[i],co[i-1]);
84
 
85
                rca_N[N-1:0] = sum;
86
                // MSB is a sign bit
87
                rca_N[N] = (a[N-1]==b[N-1]) ? co[N-1] : sum[N-1];
88
                end
89
        endfunction
90
 
91
 
92
        function [N-1:0] twos_complement;
93
        input [N-1:0] a;
94
        reg [N-1:0] ainv;
95
        reg [N:0] plus1;
96
        begin
97
                ainv  = ~a;
98
                plus1 = rca_N(ainv,{{N-1{1'b0}},1'b1});
99
 
100 6 irezki
                // pragma coverage block = off
101
                // synopsys translate_off
102
                // The only problem is absolute minumum negative value
103
                if (a == {1'b1, {N-1{1'b0}}})
104
                        $display("--->>> 2's complement ERROR - absolute minimum negative value: %0b\n\t %m",a);
105
                // synopsys translate_on
106
                // pragma coverage block = on
107 2 irezki
 
108
                twos_complement = plus1[N-1:0];
109
        end
110
        endfunction
111
 
112
endmodule
113 6 irezki
 
114
// Update Log:
115
// 27 Jul. 2011
116
// added pragmas for coverage

powered by: WebSVN 2.1.0

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