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

Subversion Repositories dblclockfft

[/] [dblclockfft/] [trunk/] [bench/] [formal/] [abs_mpy.v] - Blame information for rev 40

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 36 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    abs_mpy.v
4
//
5 40 dgisselq
// Project:     A General Purpose Pipelined FFT Implementation
6 36 dgisselq
//
7
// Purpose:     This code has been modified from the mpyop.v file so as to
8
//              abstract the multiply that formal methods struggle so hard to
9
//      deal with.  It also simplifies the interface so that (if enabled)
10
//      the multiply will return in 1-6 clocks, rather than the specified
11
//      number for the given architecture.
12
//
13
//
14
// Creator:     Dan Gisselquist, Ph.D.
15
//              Gisselquist Technology, LLC
16
//
17
////////////////////////////////////////////////////////////////////////////////
18
//
19
// Copyright (C) 2015-2018, Gisselquist Technology, LLC
20
//
21
// This program is free software (firmware): you can redistribute it and/or
22
// modify it under the terms of  the GNU General Public License as published
23
// by the Free Software Foundation, either version 3 of the License, or (at
24
// your option) any later version.
25
//
26
// This program is distributed in the hope that it will be useful, but WITHOUT
27
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
28
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
29
// for more details.
30
//
31
// You should have received a copy of the GNU General Public License along
32
// with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
33
// target there if the PDF file isn't present.)  If not, see
34
// <http://www.gnu.org/licenses/> for a copy.
35
//
36
// License:     GPL, v3, as defined and found on www.gnu.org,
37
//              http://www.gnu.org/licenses/gpl.html
38
//
39
//
40
////////////////////////////////////////////////////////////////////////////////
41
//
42
//
43
`default_nettype        none
44
//
45
module  abs_mpy(i_a, i_b, o_result);
46
        parameter       AW = 32, BW=32;
47
        parameter [0:0]   OPT_SIGNED = 1'b1;
48
        input   wire    [(AW-1):0]       i_a;
49
        input   wire    [(BW-1):0]       i_b;
50
        output  wire    [(AW+BW-1):0]    o_result;
51
 
52
        wire    [(AW+BW-1):0]    any_result;
53
        assign  any_result = $anyseq;
54
 
55
        reg     [AW-1:0] u_a;
56
        reg     [BW-1:0] u_b;
57
 
58
        always @(*)
59
        begin
60
                u_a = ((i_a[AW-1])&&(OPT_SIGNED)) ? -i_a : i_a;
61
                u_b = ((i_b[BW-1])&&(OPT_SIGNED)) ? -i_b : i_b;
62
        end
63
 
64
        reg     [(AW+BW-1):0]    u_result;
65
        always @(*)
66
        if ((OPT_SIGNED)&&(any_result[AW+BW-1]))
67
                u_result = - { 1'b1, any_result };
68
        else
69
                u_result =  { 1'b0, any_result };
70
 
71
        always @(*)
72
        begin
73
                // Constrain our result among many possibilities
74
                if ((i_a == 0)||(i_b == 0))
75
                        assume(any_result == 0);
76
                else if (OPT_SIGNED)
77
                        assume(any_result[AW+BW-1]
78
                                == (i_a[AW-1] ^ i_b[BW-1]));
79
 
80
                assume(u_result[AW+BW-1:BW] <= u_a);
81
                assume(u_result[AW+BW-1:AW] <= u_b);
82
        end
83
 
84
        genvar  k;
85
        generate
86
        begin
87
                for(k=0; k<AW-1; k=k+1)
88
                begin
89
                        always @(*)
90
                        if (u_a == (1<<k))
91
                                assume(u_result == (u_b << k));
92
                end
93
 
94
                for(k=0; k<BW; k=k+1)
95
                begin
96
                        always @(*)
97
                        if (u_b == (1<<k))
98
                                assume(u_result== (u_a << k));
99
                end
100
 
101
        end endgenerate
102
 
103
        assign  o_result = any_result;
104
 
105
        /*
106
        always @(*)
107
        if (i_a == 1)
108
                assert(o_result == {{(AW){i_b[BW-1]}}, i_b });
109
 
110
        always @(*)
111
        if (i_b == 1)
112
                assert(o_result == {{(BW){i_a[AW-1]}}, i_a });
113
        */
114
endmodule

powered by: WebSVN 2.1.0

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