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 13

Go to most recent revision | 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
 
30
OUTFILE prgen_bintree_adder_INPUT_NUM.v
31
 
32
STARTDEF
33
SWAP ADD_STAGES LOG2(INPUT_NUM)
34
ENDDEF
35
 
36
CHECK CONST (INPUT_NUM)
37
 
38
ITER TX INPUT_NUM
39
ITER SX ADD_STAGES
40
 
41
module prgen_bintree_adder_INPUT_NUM(PORTS);
42
 
43
        parameter BITS = 0;
44
 
45
        input  clk;
46
        input  reset;
47
        input [BITS-1:0] data_inTX;
48
        output [BITS-1+ADD_STAGES:0] data_out;
49
        input valid_in;
50
        output valid_out;
51
 
52
 
53
        LOOP EX INPUT_NUM EXPR(2^LOG2(INPUT_NUM))
54
        wire [BITS-1:0] data_inEX = {BITS{1'b0}}; //complete power of 2 input data
55
        ENDLOOP EX
56
        STOMP LINE
57
 
58
        wire [BITS-1:0] sum_stageADD_STAGES_TX;
59
 
60
        LOOP TX EXPR(2^LOG2(INPUT_NUM))
61
        assign sum_stageADD_STAGES_TX = data_inTX;
62
        ENDLOOP TX
63
 
64
 
65
LOOP SX ADD_STAGES
66
  ITER AX EXPR(2^SX)
67
        reg [BITS-1+EXPR(ADD_STAGES-SX):0] sum_stageSX_AX;
68
  ENDITER AX
69
ENDLOOP SX
70
 
71
        wire valid_dSX;
72
        wire valid_dADD_STAGES;
73
    CREATE prgen_delayN.v DEFCMD(SWAP DELAY 1)
74
        prgen_delay1 #(1) delay_validSX(clk, reset, valid_dSX, valid_dEXPR(SX+1));
75
        assign valid_d0 = valid_in;
76
        assign valid_out = valid_dADD_STAGES;
77
 
78
LOOP SX ADD_STAGES
79
  ITER AX EXPR(2^SX)
80
        always @(posedge clk or posedge reset)
81
          if (reset)
82
            begin
83
                sum_stageSX_AX <= #FFD {BITS+EXPR(ADD_STAGES-SX){1'b0}};
84
                end
85
          else
86
          STOMP NEWLINE
87
          if (valid_dEXPR(ADD_STAGES-SX-1))
88
            begin
89
                sum_stageSX_AX <= #FFD sum_stageEXPR(SX+1)_EXPR(2*AX) + sum_stageEXPR(SX+1)_EXPR(2*AX+1);
90
                end
91
  ENDITER AX
92
 
93
ENDLOOP SX
94
 
95
        assign data_out = sum_stage0_0;
96
 
97
endmodule
98
 
99
 
100
 

powered by: WebSVN 2.1.0

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