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

Subversion Repositories robust_fir

[/] [robust_fir/] [trunk/] [src/] [base/] [fir_serial.v] - Diff between revs 5 and 16

Only display areas with differences | Details | Blame | View Log

Rev 5 Rev 16
<##//////////////////////////////////////////////////////////////////
<##//////////////////////////////////////////////////////////////////
////                                                             ////
////                                                             ////
////  Author: Eyal Hochberg                                      ////
////  Author: Eyal Hochberg                                      ////
////          eyal@provartec.com                                 ////
////          eyal@provartec.com                                 ////
////                                                             ////
////                                                             ////
////  Downloaded from: http://www.opencores.org                  ////
////  Downloaded from: http://www.opencores.org                  ////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
////                                                             ////
////                                                             ////
//// Copyright (C) 2010 Provartec LTD                            ////
//// Copyright (C) 2010 Provartec LTD                            ////
//// www.provartec.com                                           ////
//// www.provartec.com                                           ////
//// info@provartec.com                                          ////
//// info@provartec.com                                          ////
////                                                             ////
////                                                             ////
//// This source file may be used and distributed without        ////
//// This source file may be used and distributed without        ////
//// restriction provided that this copyright statement is not   ////
//// restriction provided that this copyright statement is not   ////
//// removed from the file and that any derivative work contains ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer.////
//// the original copyright notice and the associated disclaimer.////
////                                                             ////
////                                                             ////
//// This source file is free software; you can redistribute it  ////
//// This source file is free software; you can redistribute it  ////
//// and/or modify it under the terms of the GNU Lesser General  ////
//// and/or modify it under the terms of the GNU Lesser General  ////
//// Public License as published by the Free Software Foundation.////
//// Public License as published by the Free Software Foundation.////
////                                                             ////
////                                                             ////
//// This source is distributed in the hope that it will be      ////
//// This source is distributed in the hope that it will be      ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied  ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied  ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR     ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR     ////
//// PURPOSE.  See the GNU Lesser General Public License for more////
//// PURPOSE.  See the GNU Lesser General Public License for more////
//// details. http://www.gnu.org/licenses/lgpl.html              ////
//// details. http://www.gnu.org/licenses/lgpl.html              ////
////                                                             ////
////                                                             ////
//////////////////////////////////////////////////////////////////##>
//////////////////////////////////////////////////////////////////##>
 
 
OUTFILE fir_serial_TOPO.v
OUTFILE PREFIX_serial_TOPO.v
 
 
ITER OX ORDER
ITER OX ORDER
ITER CX COEFF_NUM
ITER CX COEFF_NUM
ITER SX ADD_STAGES
ITER SX ADD_STAGES
 
 
//  Built In Parameters:
//  Built In Parameters:
//  
//  
//    Filter Order             = ORDER
//    Filter Order             = ORDER
//    Input Precision          = DIN_BITS
//    Input Precision          = DIN_BITS
//    Coefficient Precision    = COEFF_BITS
//    Coefficient Precision    = COEFF_BITS
//    Sum of Products Latency  = LATENCY
//    Sum of Products Latency  = LATENCY
 
 
module fir_serial_TOPO (PORTS);
module PREFIX_serial_TOPO (PORTS);
 
 
        input  clk;
        input  clk;
        input  reset;
        input  reset;
    input  clken;
    input  clken;
        input  [EXPR(COEFF_BITS-1):0] kCX;
        input  [EXPR(COEFF_BITS-1):0] kCX;
        input  [EXPR(DIN_BITS-1):0] data_in;
        input  [EXPR(DIN_BITS-1):0] data_in;
        output [EXPR(DOUT_BITS-1):0] data_out;
        output [EXPR(DOUT_BITS-1):0] data_out;
        output valid;
        output valid;
 
 
    wire [EXPR(COEFF_BITS-1):0] k;
    wire [EXPR(COEFF_BITS-1):0] k;
    wire [EXPR(MULT_BITS-1):0] mult;
    wire [EXPR(MULT_BITS-1):0] mult;
    reg [EXPR(DOUT_BITS-1):0] multCX;
    reg [EXPR(DOUT_BITS-1):0] multCX;
    wire [EXPR(DOUT_BITS-1):0] add;
    wire [EXPR(DOUT_BITS-1):0] add;
        wire addCX;
        wire addCX;
        reg [EXPR(DOUT_BITS-1):0] mult_sum;
        reg [EXPR(DOUT_BITS-1):0] mult_sum;
        reg [EXPR(DOUT_BITS-1):0] data_out;
        reg [EXPR(DOUT_BITS-1):0] data_out;
        reg valid;
        reg valid;
 
 
        reg active;
        reg active;
    reg [EXPR(ADD_STAGES-1):0] phase;
    reg [EXPR(ADD_STAGES-1):0] phase;
    reg [EXPR(ADD_STAGES-1):0] cycle;
    reg [EXPR(ADD_STAGES-1):0] cycle;
 
 
        wire phaseCX;
        wire phaseCX;
        wire cycleCX;
        wire cycleCX;
 
 
        assign phaseCX = phase == 'dCX;
        assign phaseCX = phase == 'dCX;
        assign cycleCX = cycle == 'dCX;
        assign cycleCX = cycle == 'dCX;
 
 
    assign k =
    assign k =
          phaseOX ? kOX :
          phaseOX ? kOX :
          kORDER;
          kORDER;
 
 
    //a single multiplayer and a single adder
    //a single multiplayer and a single adder
    assign mult = k * data_in;
    assign mult = k * data_in;
        assign add  = mult + (
        assign add  = mult + (
                                  addOX ? multOX :
                                  addOX ? multOX :
                                          multORDER);
                                          multORDER);
 
 
 
 
    always @(posedge clk or posedge reset)
    always @(posedge clk or posedge reset)
      if (reset)
      if (reset)
        active <= #FFD 1'b0;
        active <= #FFD 1'b0;
          else if (clken)
          else if (clken)
        active <= #FFD 1'b1;
        active <= #FFD 1'b1;
          else if (phase == 'dORDER)
          else if (phase == 'dORDER)
        active <= #FFD 1'b0;
        active <= #FFD 1'b0;
 
 
    always @(posedge clk or posedge reset)
    always @(posedge clk or posedge reset)
      if (reset)
      if (reset)
        phase <= #FFD {ADD_STAGES{1'b0}};
        phase <= #FFD {ADD_STAGES{1'b0}};
      else if (phase == 'dORDER)
      else if (phase == 'dORDER)
        phase <= #FFD {ADD_STAGES{1'b0}};
        phase <= #FFD {ADD_STAGES{1'b0}};
      else if (active)
      else if (active)
        phase <= #FFD phase + 1'b1;
        phase <= #FFD phase + 1'b1;
 
 
    always @(posedge clk or posedge reset)
    always @(posedge clk or posedge reset)
      if (reset)
      if (reset)
        cycle <= #FFD {ADD_STAGES{1'b0}};
        cycle <= #FFD {ADD_STAGES{1'b0}};
          else if (phase == 'dORDER)
          else if (phase == 'dORDER)
            begin
            begin
                  if (cycle == 'dORDER)
                  if (cycle == 'dORDER)
            cycle <= #FFD {ADD_STAGES{1'b0}};
            cycle <= #FFD {ADD_STAGES{1'b0}};
                  else
                  else
            cycle <= cycle + 1'b1;
            cycle <= cycle + 1'b1;
                end
                end
 
 
LOOP PX COEFF_NUM
LOOP PX COEFF_NUM
        assign addPX = active & (
        assign addPX = active & (
            (phaseEXPR((COEFF_NUM+PX-CX)%COEFF_NUM) && cycleCX) ||
            (phaseEXPR((COEFF_NUM+PX-CX)%COEFF_NUM) && cycleCX) ||
                STOMP || );
                STOMP || );
 
 
        always @(posedge clk or posedge reset)
        always @(posedge clk or posedge reset)
          if (reset)
          if (reset)
            multPX <= #FFD {MULT_BITS{1'b0}};
            multPX <= #FFD {MULT_BITS{1'b0}};
          else if (phase1 && cyclePX)
          else if (phase1 && cyclePX)
            multPX <= #FFD {MULT_BITS{1'b0}};
            multPX <= #FFD {MULT_BITS{1'b0}};
          else if (addPX)
          else if (addPX)
            multPX <= #FFD add;
            multPX <= #FFD add;
 
 
ENDLOOP PX
ENDLOOP PX
 
 
 
 
 //sample when valid
 //sample when valid
 always @(posedge clk or posedge reset)
 always @(posedge clk or posedge reset)
  if (reset)
  if (reset)
    mult_sum <= #FFD {DOUT_BITS{1'b0}};
    mult_sum <= #FFD {DOUT_BITS{1'b0}};
  else if (phase1)
  else if (phase1)
    begin
    begin
LOOP CX COEFF_NUM
LOOP CX COEFF_NUM
        if (cycleCX)
        if (cycleCX)
    mult_sum <= #FFD multCX;
    mult_sum <= #FFD multCX;
        else
        else
STOMP NEWLINE
STOMP NEWLINE
ENDLOOP CX
ENDLOOP CX
STOMP else
STOMP else
    end
    end
 
 
 //sync to clock enable
 //sync to clock enable
 always @(posedge clk or posedge reset)
 always @(posedge clk or posedge reset)
  if (reset)
  if (reset)
    begin
    begin
      data_out <= #FFD {DOUT_BITS{1'b0}};
      data_out <= #FFD {DOUT_BITS{1'b0}};
          valid <= #FFD 1'b0;
          valid <= #FFD 1'b0;
        end
        end
  else if (clken)
  else if (clken)
    begin
    begin
      data_out <= #FFD mult_sum;
      data_out <= #FFD mult_sum;
          valid <= #FFD 1'b1;
          valid <= #FFD 1'b1;
        end
        end
  else
  else
    begin
    begin
          valid <= #FFD 1'b0;
          valid <= #FFD 1'b0;
        end
        end
 
 
 
 
endmodule
endmodule
 
 
 
 
 
 
 
 
 
 
 
 

powered by: WebSVN 2.1.0

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