1 |
36 |
dgisselq |
////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
//
|
3 |
|
|
// Filename: ../rtl/bimpy.v
|
4 |
|
|
//
|
5 |
|
|
// Project: A General Purpose Pipelined FFT Implementation
|
6 |
|
|
//
|
7 |
|
|
// Purpose: A simple 2-bit multiply based upon the fact that LUT's allow
|
8 |
|
|
// 6-bits of input. In other words, I could build a 3-bit
|
9 |
|
|
// multiply from 6 LUTs (5 actually, since the first could have two
|
10 |
|
|
// outputs). This would allow multiplication of three bit digits, save
|
11 |
|
|
// only for the fact that you would need two bits of carry. The bimpy
|
12 |
|
|
// approach throttles back a bit and does a 2x2 bit multiply in a LUT,
|
13 |
|
|
// guaranteeing that it will never carry more than one bit. While this
|
14 |
|
|
// multiply is hardware independent (and can still run under Verilator
|
15 |
|
|
// therefore), it is really motivated by trying to optimize for a
|
16 |
|
|
// specific piece of hardware (Xilinx-7 series ...) that has at least
|
17 |
|
|
// 4-input LUT's with carry chains.
|
18 |
|
|
//
|
19 |
|
|
//
|
20 |
|
|
//
|
21 |
|
|
// Creator: Dan Gisselquist, Ph.D.
|
22 |
|
|
// Gisselquist Technology, LLC
|
23 |
|
|
//
|
24 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
25 |
|
|
//
|
26 |
|
|
// Copyright (C) 2015-2018, Gisselquist Technology, LLC
|
27 |
|
|
//
|
28 |
39 |
dgisselq |
// This file is part of the general purpose pipelined FFT project.
|
29 |
36 |
dgisselq |
//
|
30 |
39 |
dgisselq |
// The pipelined FFT project is free software (firmware): you can redistribute
|
31 |
|
|
// it and/or modify it under the terms of the GNU Lesser General Public License
|
32 |
|
|
// as published by the Free Software Foundation, either version 3 of the
|
33 |
|
|
// License, or (at your option) any later version.
|
34 |
36 |
dgisselq |
//
|
35 |
39 |
dgisselq |
// The pipelined FFT project is distributed in the hope that it will be useful,
|
36 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
37 |
|
|
// MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
38 |
|
|
// General Public License for more details.
|
39 |
|
|
//
|
40 |
|
|
// You should have received a copy of the GNU Lesser General Public License
|
41 |
|
|
// along with this program. (It's in the $(ROOT)/doc directory. Run make
|
42 |
|
|
// with no target there if the PDF file isn't present.) If not, see
|
43 |
36 |
dgisselq |
// <http://www.gnu.org/licenses/> for a copy.
|
44 |
|
|
//
|
45 |
39 |
dgisselq |
// License: LGPL, v3, as defined and found on www.gnu.org,
|
46 |
|
|
// http://www.gnu.org/licenses/lgpl.html
|
47 |
36 |
dgisselq |
//
|
48 |
|
|
//
|
49 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
50 |
|
|
//
|
51 |
|
|
//
|
52 |
|
|
`default_nettype none
|
53 |
|
|
//
|
54 |
|
|
module bimpy(i_clk, i_ce, i_a, i_b, o_r);
|
55 |
39 |
dgisselq |
parameter BW=18; // Number of bits in i_b
|
56 |
|
|
localparam LUTB=2; // Number of bits in i_a for our LUT multiply
|
57 |
|
|
input wire i_clk, i_ce;
|
58 |
|
|
input wire [(LUTB-1):0] i_a;
|
59 |
|
|
input wire [(BW-1):0] i_b;
|
60 |
36 |
dgisselq |
output reg [(BW+LUTB-1):0] o_r;
|
61 |
|
|
|
62 |
|
|
wire [(BW+LUTB-2):0] w_r;
|
63 |
|
|
wire [(BW+LUTB-3):1] c;
|
64 |
|
|
|
65 |
|
|
assign w_r = { ((i_a[1])?i_b:{(BW){1'b0}}), 1'b0 }
|
66 |
|
|
^ { 1'b0, ((i_a[0])?i_b:{(BW){1'b0}}) };
|
67 |
|
|
assign c = { ((i_a[1])?i_b[(BW-2):0]:{(BW-1){1'b0}}) }
|
68 |
|
|
& ((i_a[0])?i_b[(BW-1):1]:{(BW-1){1'b0}});
|
69 |
|
|
|
70 |
39 |
dgisselq |
initial o_r = 0;
|
71 |
36 |
dgisselq |
always @(posedge i_clk)
|
72 |
39 |
dgisselq |
if (i_ce)
|
73 |
|
|
o_r <= w_r + { c, 2'b0 };
|
74 |
36 |
dgisselq |
|
75 |
39 |
dgisselq |
`ifdef FORMAL
|
76 |
|
|
reg f_past_valid;
|
77 |
|
|
|
78 |
|
|
initial f_past_valid = 1'b0;
|
79 |
|
|
always @(posedge i_clk)
|
80 |
|
|
f_past_valid <= 1'b1;
|
81 |
|
|
|
82 |
|
|
`define ASSERT assert
|
83 |
|
|
|
84 |
|
|
always @(posedge i_clk)
|
85 |
|
|
if ((f_past_valid)&&($past(i_ce)))
|
86 |
|
|
begin
|
87 |
|
|
if ($past(i_a)==0)
|
88 |
|
|
`ASSERT(o_r == 0);
|
89 |
|
|
else if ($past(i_a) == 1)
|
90 |
|
|
`ASSERT(o_r == $past(i_b));
|
91 |
|
|
|
92 |
|
|
if ($past(i_b)==0)
|
93 |
|
|
`ASSERT(o_r == 0);
|
94 |
|
|
else if ($past(i_b) == 1)
|
95 |
|
|
`ASSERT(o_r[(LUTB-1):0] == $past(i_a));
|
96 |
|
|
end
|
97 |
|
|
`endif
|
98 |
36 |
dgisselq |
endmodule
|