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

Subversion Repositories robust_fir

[/] [robust_fir/] [trunk/] [src/] [gen/] [prgen_bintree_adder.v] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 eyalhoc
<##//////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  Author: Eyal Hochberg                                      ////
4
////          eyal@provartec.com                                 ////
5
////                                                             ////
6
////  Downloaded from: http://www.opencores.org                  ////
7
/////////////////////////////////////////////////////////////////////
8
////                                                             ////
9
//// Copyright (C) 2010 Provartec LTD                            ////
10
//// www.provartec.com                                           ////
11
//// info@provartec.com                                          ////
12
////                                                             ////
13
//// This source file may be used and distributed without        ////
14
//// restriction provided that this copyright statement is not   ////
15
//// removed from the file and that any derivative work contains ////
16
//// the original copyright notice and the associated disclaimer.////
17
////                                                             ////
18
//// This source file is free software; you can redistribute it  ////
19
//// and/or modify it under the terms of the GNU Lesser General  ////
20
//// Public License as published by the Free Software Foundation.////
21
////                                                             ////
22
//// This source is distributed in the hope that it will be      ////
23
//// useful, but WITHOUT ANY WARRANTY; without even the implied  ////
24
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR     ////
25
//// PURPOSE.  See the GNU Lesser General Public License for more////
26
//// details. http://www.gnu.org/licenses/lgpl.html              ////
27
////                                                             ////
28
//////////////////////////////////////////////////////////////////##>
29
OUTFILE prgen_bintree_adder_INPUT_NUM.v
30
 
31
STARTDEF
32
SWAP ADD_STAGES LOG2(INPUT_NUM)
33
ENDDEF
34
 
35
CHECK CONST (INPUT_NUM)
36
 
37
ITER TX INPUT_NUM
38
ITER SX ADD_STAGES
39
 
40
module prgen_bintree_adder_INPUT_NUM(PORTS);
41
 
42
        parameter BITS = 0;
43
 
44
        input  clk;
45
        input  reset;
46
        input [BITS-1:0] data_inTX;
47
        output [BITS-1+ADD_STAGES:0] data_out;
48
        input valid_in;
49
        output valid_out;
50
 
51
 
52
        LOOP EX INPUT_NUM EXPR(2^LOG2(INPUT_NUM))
53
        wire [BITS-1:0] data_inEX = {BITS{1'b0}}; //complete power of 2 input data
54
        ENDLOOP EX
55
        STOMP LINE
56
 
57 16 eyalhoc
 
58
        LOOP TX EXPR(2^LOG2(INPUT_NUM)) ##round up
59 13 eyalhoc
        wire [BITS-1:0] sum_stageADD_STAGES_TX;
60
        assign sum_stageADD_STAGES_TX = data_inTX;
61
        ENDLOOP TX
62
 
63
 
64
LOOP SX ADD_STAGES
65
  ITER AX EXPR(2^SX)
66
        reg [BITS-1+EXPR(ADD_STAGES-SX):0] sum_stageSX_AX;
67
  ENDITER AX
68
ENDLOOP SX
69
 
70
        wire valid_dSX;
71
        wire valid_dADD_STAGES;
72
    CREATE prgen_delayN.v DEFCMD(SWAP DELAY 1)
73
        prgen_delay1 #(1) delay_validSX(clk, reset, valid_dSX, valid_dEXPR(SX+1));
74
        assign valid_d0 = valid_in;
75
        assign valid_out = valid_dADD_STAGES;
76
 
77
LOOP SX ADD_STAGES
78
  ITER AX EXPR(2^SX)
79
        always @(posedge clk or posedge reset)
80
          if (reset)
81
            begin
82
                sum_stageSX_AX <= #FFD {BITS+EXPR(ADD_STAGES-SX){1'b0}};
83
                end
84
          else
85
          STOMP NEWLINE
86
          if (valid_dEXPR(ADD_STAGES-SX-1))
87
            begin
88
                sum_stageSX_AX <= #FFD sum_stageEXPR(SX+1)_EXPR(2*AX) + sum_stageEXPR(SX+1)_EXPR(2*AX+1);
89
                end
90
  ENDITER AX
91
 
92
ENDLOOP SX
93
 
94
        assign data_out = sum_stage0_0;
95
 
96
endmodule
97
 
98
 
99
 

powered by: WebSVN 2.1.0

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