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

Subversion Repositories cic_core_2

[/] [cic_core_2/] [trunk/] [rtl/] [verilog/] [cic_d.sv] - Diff between revs 7 and 9

Show entire file | Details | Blame | View Log

Rev 7 Rev 9
Line 8... Line 8...
        parameter CIC_M = 1,                    ///< delay in comb
        parameter CIC_M = 1,                    ///< delay in comb
        parameter SMALL_FOOTPRINT = 1   ///< reduced registers usage, f_clk / (f_samp/CIC_R)  > CIC_N required
        parameter SMALL_FOOTPRINT = 1   ///< reduced registers usage, f_clk / (f_samp/CIC_R)  > CIC_N required
)
)
/*********************************************************************************************/
/*********************************************************************************************/
(
(
        input                                                           clk,
        input                                                           clk,                    ///< input clock
        input                                                           reset_n,
        input                                                           reset_n,                ///< input reset
        input                                                           clear,
        input                                                           clear,                  ///< input clear integrator, set accumulator to 0
        input   wire    signed [INP_DW-1:0]     inp_samp_data,
        input   wire    signed [INP_DW-1:0]     inp_samp_data,  ///< input data
        input                                                           inp_samp_str,
        input                                                           inp_samp_str,   ///< input data ready strobe
        output  wire    signed [OUT_DW-1:0]     out_samp_data,
        output  wire    signed [OUT_DW-1:0]     out_samp_data,  ///< output data
        output                                                          out_samp_str
        output                                                          out_samp_str    ///< output data ready strobe
);
);
/*********************************************************************************************/
/*********************************************************************************************/
`include "cic_functions.vh"
`include "cic_functions.vh"
/*********************************************************************************************/
/*********************************************************************************************/
localparam      B_max = clog2_l((CIC_R * CIC_M) ** CIC_N) + INP_DW - 1;
localparam      B_max = clog2_l((CIC_R * CIC_M) ** CIC_N) + INP_DW - 1;
/*********************************************************************************************/
/*********************************************************************************************/
 
 
genvar  i;
genvar  i;
generate
generate
        for (i = 0; i < CIC_N; i = i + 1) begin : int_stage
        for (i = 0; i < CIC_N; i = i + 1) begin : int_stage
                localparam B_jm1        = B_calc(i    , CIC_N, CIC_R, CIC_M, INP_DW, OUT_DW);
                localparam B_jm1        = B_calc(i    , CIC_N, CIC_R, CIC_M, INP_DW, OUT_DW);   ///< the number of bits to prune in previous stage
                localparam B_j          = B_calc(i + 1, CIC_N, CIC_R, CIC_M, INP_DW, OUT_DW);
                localparam B_j          = B_calc(i + 1, CIC_N, CIC_R, CIC_M, INP_DW, OUT_DW);   ///< the number of bits to prune in current stage
                localparam F_sq_j = 0;
                localparam idw_cur = B_max - B_jm1 + 1;         ///< data width on the input
                localparam idw_cur = B_max - B_jm1 + 1;
                localparam odw_cur = B_max - B_j   + 1;         ///< data width on the output
                localparam odw_cur = B_max - B_j   + 1;
                wire signed [idw_cur - 1 : 0] int_in;           ///< input data bus
                localparam B_dw_prev = (i != 0) ? B_max - B_jm1 + 1 : 0;
                if ( i == 0 )   assign int_in = inp_samp_data;                          ///< if it is the first stage, then takes data from input of CIC filter
                wire signed [idw_cur - 1 : 0] int_in;
                        else            assign int_in = int_stage[i - 1].int_out;       ///< otherwise, takes data from the previous stage of the filter
                if ( i == 0 )   assign int_in = inp_samp_data;
 
                        else            assign int_in = int_stage[i - 1].int_out;
 
                wire signed [idw_cur - 1 : 0] int_inst_out;
 
                wire signed [odw_cur - 1 : 0] int_out;
                wire signed [odw_cur - 1 : 0] int_out;
                assign int_out = int_inst_out[idw_cur - 1 -: odw_cur];
 
                integrator #(
                integrator #(
                                idw_cur,
                                idw_cur,
                                idw_cur
                                odw_cur
                                )
                                )
                        int_inst(
                        int_inst(
                                .clk                    (clk),
                                .clk                    (clk),
                                .reset_n                (reset_n),
                                .reset_n                (reset_n),
                                .clear                  (clear) ,
                                .clear                  (clear) ,
                                .inp_samp_data  (int_in),
                                .inp_samp_data  (int_in),
                                .inp_samp_str   (inp_samp_str),
                                .inp_samp_str   (inp_samp_str),
                                .out_samp_data  (int_inst_out)
                                .out_samp_data  (int_out)
                                );
                                );
                initial begin
                initial begin
                        //$display("i:%d integ idw=%2d odw=%2d  B(%2d, %3d, %2d, %2d, %2d, %2d)=%2d, Bj-1=%2d, F_sq=%8d", i, idw_cur, odw_cur, i + 1, CIC_R, CIC_M, CIC_N, INP_DW, OUT_DW, B_j, B_jm1, F_sq_j);
                        //$display("i:%d integ idw=%2d odw=%2d  B(%2d, %3d, %2d, %2d, %2d, %2d)=%2d, Bj-1=%2d, F_sq=%8d", i, idw_cur, odw_cur, i + 1, CIC_R, CIC_M, CIC_N, INP_DW, OUT_DW, B_j, B_jm1, F_sq_j);
                        $display("i:%d integ idw=%d ", i, idw_cur);
                        $display("i:%d integ idw=%d ", i, idw_cur);
                end
                end
        end
        end
endgenerate
endgenerate
/*********************************************************************************************/
/*********************************************************************************************/
localparam B_m = B_calc(CIC_N, CIC_N, CIC_R, CIC_M, INP_DW, OUT_DW);
/// downsampler takes data from m-th stage
localparam ds_dw = B_max - B_m + 1;
localparam B_m = B_calc(CIC_N, CIC_N, CIC_R, CIC_M, INP_DW, OUT_DW);    ///< bits to prune on the m-th stage
 
localparam ds_dw = B_max - B_m + 1;                                                                             ///< data width of the downsampler
wire    signed [ds_dw - 1 : 0]  ds_out_samp_data;
wire    signed [ds_dw - 1 : 0]  ds_out_samp_data;
wire                                                    ds_out_samp_str;
wire                                                    ds_out_samp_str;
/*********************************************************************************************/
/*********************************************************************************************/
initial begin
initial begin
        //$display("i downsamp dw %d , int_stage[%2d].dw_out = %2d", ds_dw, CIC_N - 1, int_stage[CIC_N - 1].odw_cur);
        //$display("i downsamp dw %d , int_stage[%2d].dw_out = %2d", ds_dw, CIC_N - 1, int_stage[CIC_N - 1].odw_cur);
Line 85... Line 81...
genvar  j;
genvar  j;
wire comb_chain_out_str;
wire comb_chain_out_str;
reg     [CIC_N : 0]     comb_inp_str_d;
reg     [CIC_N : 0]     comb_inp_str_d;
generate
generate
        wire summ_rdy_str;
        wire summ_rdy_str;
        if (SMALL_FOOTPRINT != 0) begin
        if (SMALL_FOOTPRINT != 0) begin ///< generate comb for small footprint
                always @(negedge reset_n or posedge clk)
                always @(negedge reset_n or posedge clk)        ///< shift register for strobe from datasampler, used to latch data from comb at N'th clock after downsamplers strobe
                        if              (~reset_n)      comb_inp_str_d <= '0;
                        if              (~reset_n)      comb_inp_str_d <= '0;
                        else if (clear)         comb_inp_str_d <= '0;
                        else if (clear)         comb_inp_str_d <= '0;
                        else                            comb_inp_str_d <= {comb_inp_str_d[CIC_N - 1 : 0], ds_out_samp_str};
                        else                            comb_inp_str_d <= {comb_inp_str_d[CIC_N - 1 : 0], ds_out_samp_str};
        end
        end
 
 
Line 99... Line 95...
 
 
 
 
        for (j = 0; j < CIC_N; j = j + 1) begin : comb_stage
        for (j = 0; j < CIC_N; j = j + 1) begin : comb_stage
                localparam B_m_j_m1             =    B_calc(CIC_N + j    ,      CIC_N, CIC_R, CIC_M, INP_DW, OUT_DW);
                localparam B_m_j_m1             =    B_calc(CIC_N + j    ,      CIC_N, CIC_R, CIC_M, INP_DW, OUT_DW);
                localparam B_m_j                =    B_calc(CIC_N + j + 1,      CIC_N, CIC_R, CIC_M, INP_DW, OUT_DW);
                localparam B_m_j                =    B_calc(CIC_N + j + 1,      CIC_N, CIC_R, CIC_M, INP_DW, OUT_DW);
                localparam F_sq_j               = 1;
 
                localparam idw_cur = B_max - B_m_j_m1 + 1;
                localparam idw_cur = B_max - B_m_j_m1 + 1;
                localparam odw_cur = B_max - B_m_j + 1;
                localparam odw_cur = B_max - B_m_j + 1;
                wire signed [idw_cur - 1 : 0] comb_in;
                wire signed [idw_cur - 1 : 0] comb_in;
                wire signed [idw_cur - 1 : 0] comb_inst_out;
                wire signed [idw_cur - 1 : 0] comb_inst_out;
                wire signed [odw_cur - 1 : 0] comb_out;
                wire signed [odw_cur - 1 : 0] comb_out;
Line 127... Line 122...
                                .samp_out_data  (comb_inst_out)
                                .samp_out_data  (comb_inst_out)
                                );
                                );
                if (SMALL_FOOTPRINT == 0)       assign comb_chain_out_str = comb_stage[CIC_N - 1].comb_dv;
                if (SMALL_FOOTPRINT == 0)       assign comb_chain_out_str = comb_stage[CIC_N - 1].comb_dv;
                else                                            assign comb_chain_out_str = comb_inp_str_d[CIC_N - 1];
                else                                            assign comb_chain_out_str = comb_inp_str_d[CIC_N - 1];
                initial begin
                initial begin
                        //$display("i:%d  comb idw=%2d odw=%2d  B(%2d, %3d, %2d, %2d, %2d, %2d)=%2d, ln(F_sq)=%4d, F_sq=%8d", j, idw_cur, odw_cur, CIC_N + j + 1, CIC_R, CIC_M, CIC_N, INP_DW, OUT_DW, B_m_j, $ln(F_sq_j), F_sq_j);
                        //$display("i:%d  comb idw=%2d odw=%2d  B(%2d, %3d, %2d, %2d, %2d, %2d)=%2d", j, idw_cur, odw_cur, CIC_N + j + 1, CIC_R, CIC_M, CIC_N, INP_DW, OUT_DW, B_m_j);
                        //if (j != 0) $display("odw_prev=%2d, comb_stage[j - 1].odw_cur=%2d", odw_prev, comb_stage[j - 1].odw_cur);
                        //if (j != 0) $display("odw_prev=%2d, comb_stage[j - 1].odw_cur=%2d", odw_prev, comb_stage[j - 1].odw_cur);
                        $display("i:%d  comb idw=%d", j, idw_cur);
                        $display("i:%d  comb idw=%d", j, idw_cur);
                end
                end
        end
        end
endgenerate
endgenerate

powered by: WebSVN 2.1.0

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