|
@@ -21,9 +21,8 @@ wire oscWind = (tbCnt>=4500&tbCnt<=6499)? 1'b1:1'b0;
|
|
|
// wire oscWind = (tbCnt>=1&)? 1'b1:1'b0;
|
|
// wire oscWind = (tbCnt>=1&)? 1'b1:1'b0;
|
|
|
|
|
|
|
|
wire signed [13:0] ncoSin1;
|
|
wire signed [13:0] ncoSin1;
|
|
|
-wire signed [13:0] ncoCos1;
|
|
|
|
|
wire signed [13:0] ncoSin2;
|
|
wire signed [13:0] ncoSin2;
|
|
|
-wire signed [13:0] ncoCos2;
|
|
|
|
|
|
|
+wire signed [13:0] ncoSin3;
|
|
|
|
|
|
|
|
wire signed [15:0] filteredDataOut;
|
|
wire signed [15:0] filteredDataOut;
|
|
|
wire signed [15:0] impResponse;
|
|
wire signed [15:0] impResponse;
|
|
@@ -36,7 +35,8 @@ wire respVal;
|
|
|
wire signed [27:0] adcDataMixed = (ncoSin1*ncoSin2);
|
|
wire signed [27:0] adcDataMixed = (ncoSin1*ncoSin2);
|
|
|
wire signed [13:0] adcDataMixedCut = adcDataMixed[27-:14];
|
|
wire signed [13:0] adcDataMixedCut = adcDataMixed[27-:14];
|
|
|
|
|
|
|
|
-wire signed [13:0] sinAdd = (ncoSin1>>>1)+(ncoSin2>>>1);
|
|
|
|
|
|
|
+wire signed [13:0] sinAdd = (ncoSin1>>>2)+(ncoSin2>>>2)+(ncoSin3>>>2);
|
|
|
|
|
+// wire signed [13:0] sinAdd = (ncoSin1>>>1)+(ncoSin2>>>1);
|
|
|
|
|
|
|
|
reg signed [13:0] currTestData;
|
|
reg signed [13:0] currTestData;
|
|
|
|
|
|
|
@@ -50,10 +50,10 @@ always #10 Clk50 = ~Clk50;
|
|
|
|
|
|
|
|
//==========================================================================================
|
|
//==========================================================================================
|
|
|
|
|
|
|
|
-parameter N = 8;
|
|
|
|
|
|
|
+parameter N = 1;
|
|
|
parameter M = 1;
|
|
parameter M = 1;
|
|
|
|
|
|
|
|
-parameter MaxWidth = 23;
|
|
|
|
|
|
|
+parameter MaxWidth = 16;
|
|
|
|
|
|
|
|
initial begin
|
|
initial begin
|
|
|
Clk50 = 1'b1;
|
|
Clk50 = 1'b1;
|
|
@@ -118,12 +118,12 @@ ncoInst1
|
|
|
.Clk_i (Clk50),
|
|
.Clk_i (Clk50),
|
|
|
.Rst_i (Rst),
|
|
.Rst_i (Rst),
|
|
|
.Val_i (1'b1),
|
|
.Val_i (1'b1),
|
|
|
- .PhaseInc_i (32'h20000000),
|
|
|
|
|
|
|
+ .PhaseInc_i (32'h0f5c28f5),
|
|
|
.WindVal_i (1'b1),
|
|
.WindVal_i (1'b1),
|
|
|
.WinType_i (),
|
|
.WinType_i (),
|
|
|
.Wind_o (),
|
|
.Wind_o (),
|
|
|
.Sin_o (ncoSin1),
|
|
.Sin_o (ncoSin1),
|
|
|
- .Cos_o (ncoCos1),
|
|
|
|
|
|
|
+ .Cos_o (),
|
|
|
.Val_o ()
|
|
.Val_o ()
|
|
|
);
|
|
);
|
|
|
|
|
|
|
@@ -139,12 +139,33 @@ ncoInst2
|
|
|
.Clk_i (Clk50),
|
|
.Clk_i (Clk50),
|
|
|
.Rst_i (Rst),
|
|
.Rst_i (Rst),
|
|
|
.Val_i (1'b1),
|
|
.Val_i (1'b1),
|
|
|
- .PhaseInc_i (32'h3851eb85),
|
|
|
|
|
|
|
+ .PhaseInc_i (32'h33333333),
|
|
|
.WindVal_i (1'b1),
|
|
.WindVal_i (1'b1),
|
|
|
.WinType_i (),
|
|
.WinType_i (),
|
|
|
.Wind_o (),
|
|
.Wind_o (),
|
|
|
.Sin_o (ncoSin2),
|
|
.Sin_o (ncoSin2),
|
|
|
- .Cos_o (ncoCos2),
|
|
|
|
|
|
|
+ .Cos_o (),
|
|
|
|
|
+ .Val_o ()
|
|
|
|
|
+);
|
|
|
|
|
+
|
|
|
|
|
+CordicNco
|
|
|
|
|
+#(
|
|
|
|
|
+ .ODatWidth (14),
|
|
|
|
|
+ .PhIncWidth (32),
|
|
|
|
|
+ .IterNum (10),
|
|
|
|
|
+ .EnSinN (1)
|
|
|
|
|
+)
|
|
|
|
|
+ncoInst3
|
|
|
|
|
+(
|
|
|
|
|
+ .Clk_i (Clk50),
|
|
|
|
|
+ .Rst_i (Rst),
|
|
|
|
|
+ .Val_i (1'b1),
|
|
|
|
|
+ .PhaseInc_i (32'h4ccccccc),
|
|
|
|
|
+ .WindVal_i (1'b1),
|
|
|
|
|
+ .WinType_i (),
|
|
|
|
|
+ .Wind_o (),
|
|
|
|
|
+ .Sin_o (ncoSin3),
|
|
|
|
|
+ .Cos_o (),
|
|
|
.Val_o ()
|
|
.Val_o ()
|
|
|
);
|
|
);
|
|
|
|
|
|
|
@@ -156,7 +177,10 @@ DecimFilterWrapper
|
|
|
.M (M),
|
|
.M (M),
|
|
|
.FilteredDataWidth (MaxWidth),
|
|
.FilteredDataWidth (MaxWidth),
|
|
|
.FirOutDataWidth (48),
|
|
.FirOutDataWidth (48),
|
|
|
- .FirOutCutBit (42)
|
|
|
|
|
|
|
+ .FirOutCutBit (42),
|
|
|
|
|
+ .LsbForR1 (10'd16),
|
|
|
|
|
+ .LsbForR2 (10'd16),
|
|
|
|
|
+ .LsbForR4 (10'd16)
|
|
|
)
|
|
)
|
|
|
DecimFilter
|
|
DecimFilter
|
|
|
(
|
|
(
|
|
@@ -169,7 +193,8 @@ DecimFilter
|
|
|
.IfFtwH_i (24'h23),
|
|
.IfFtwH_i (24'h23),
|
|
|
|
|
|
|
|
// .AdcData_i (sinAdd),
|
|
// .AdcData_i (sinAdd),
|
|
|
- .AdcData_i (adcData),
|
|
|
|
|
|
|
+ .AdcData_i (adcDataMixedCut),
|
|
|
|
|
+ // .AdcData_i (adcData),
|
|
|
|
|
|
|
|
.FilteredAdcDataI_o (filteredDataOut),
|
|
.FilteredAdcDataI_o (filteredDataOut),
|
|
|
.FilteredAdcDataQ_o (),
|
|
.FilteredAdcDataQ_o (),
|
|
@@ -183,7 +208,10 @@ DecimFilterWrapper
|
|
|
.M (M),
|
|
.M (M),
|
|
|
.FilteredDataWidth (MaxWidth),
|
|
.FilteredDataWidth (MaxWidth),
|
|
|
.FirOutDataWidth (48),
|
|
.FirOutDataWidth (48),
|
|
|
- .FirOutCutBit (42)
|
|
|
|
|
|
|
+ .FirOutCutBit (42),
|
|
|
|
|
+ .LsbForR1 (10'd16),
|
|
|
|
|
+ .LsbForR2 (10'd16),
|
|
|
|
|
+ .LsbForR4 (10'd16)
|
|
|
)
|
|
)
|
|
|
ImpulseResponseFilter
|
|
ImpulseResponseFilter
|
|
|
(
|
|
(
|
|
@@ -266,16 +294,19 @@ always @(posedge Clk50) begin
|
|
|
end else begin
|
|
end else begin
|
|
|
if (oscWind) begin
|
|
if (oscWind) begin
|
|
|
// $display("AdcData is %d", sinAdd);
|
|
// $display("AdcData is %d", sinAdd);
|
|
|
- $fwrite(inSignal,"%d\n", sinAdd);
|
|
|
|
|
|
|
+ // $fwrite(inSignal,"%d\n", sinAdd);
|
|
|
|
|
+ $fwrite(inSignal,"%d\n", adcDataMixed);
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
reg [31:0] testCnt;
|
|
reg [31:0] testCnt;
|
|
|
|
|
+wire [10:0] test = N*2+N*2+decimFactor;
|
|
|
|
|
+wire writeEn = (oscWindDelay[N*2+N*2+decimFactor-1]);
|
|
|
|
|
|
|
|
always @(posedge Clk50)begin
|
|
always @(posedge Clk50)begin
|
|
|
if (!Rst) begin
|
|
if (!Rst) begin
|
|
|
- if (oscWindDelay[6]) begin
|
|
|
|
|
|
|
+ if (writeEn) begin
|
|
|
testCnt <= testCnt +1;
|
|
testCnt <= testCnt +1;
|
|
|
end
|
|
end
|
|
|
end else begin
|
|
end else begin
|
|
@@ -287,7 +318,7 @@ always @(posedge Clk50) begin
|
|
|
if (Rst) begin
|
|
if (Rst) begin
|
|
|
filteredData = $fopen("C:/S5243_FFT_REPO/src/src/Sim/FilteredData.txt","w");
|
|
filteredData = $fopen("C:/S5243_FFT_REPO/src/src/Sim/FilteredData.txt","w");
|
|
|
end else begin
|
|
end else begin
|
|
|
- if (oscWindDelay[6] &testCnt<=999) begin
|
|
|
|
|
|
|
+ if (writeEn) begin
|
|
|
$fwrite(filteredData,"%d\n", filteredDataOut);
|
|
$fwrite(filteredData,"%d\n", filteredDataOut);
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
@@ -298,7 +329,7 @@ always @(posedge Clk50) begin
|
|
|
if (Rst) begin
|
|
if (Rst) begin
|
|
|
impResp = $fopen("C:/S5243_FFT_REPO/src/src/Sim/ImpResp.txt","w");
|
|
impResp = $fopen("C:/S5243_FFT_REPO/src/src/Sim/ImpResp.txt","w");
|
|
|
end else begin
|
|
end else begin
|
|
|
- if (oscWindDelay[6] &testCnt<=999) begin
|
|
|
|
|
|
|
+ if (writeEn) begin
|
|
|
$fwrite(impResp,"%d\n", impResponse);
|
|
$fwrite(impResp,"%d\n", impResponse);
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|