|
|
@@ -16,20 +16,21 @@ real signal;
|
|
|
|
|
|
reg [31:0] tbCnt;
|
|
|
reg [31:0] pNumCnt;
|
|
|
-// wire oscWind = (tbCnt>=4500&tbCnt<=5499)? 1'b1:1'b0;
|
|
|
+// wire oscWind = (tbCnt==4505)? 1'b1:1'b0;
|
|
|
wire oscWind = (tbCnt>=4500&tbCnt<=6499)? 1'b1:1'b0;
|
|
|
+// wire oscWind = (tbCnt>=1&)? 1'b1:1'b0;
|
|
|
|
|
|
wire signed [13:0] ncoSin1;
|
|
|
wire signed [13:0] ncoCos1;
|
|
|
wire signed [13:0] ncoSin2;
|
|
|
wire signed [13:0] ncoCos2;
|
|
|
|
|
|
-wire signed [15:0] resultI;
|
|
|
-wire signed [15:0] resultQ;
|
|
|
+wire signed [15:0] filteredDataOut;
|
|
|
+wire signed [15:0] impResponse;
|
|
|
+
|
|
|
wire resultVal;
|
|
|
+wire respVal;
|
|
|
|
|
|
-wire signed [13:0] resultICut = resultI[0+:14];
|
|
|
-wire signed [13:0] resultQCut = resultQ[0+:14];
|
|
|
|
|
|
// wire signed [27:0] adcDataMixed = oscWind?(ncoSin1*ncoSin2):28'd0;
|
|
|
wire signed [27:0] adcDataMixed = (ncoSin1*ncoSin2);
|
|
|
@@ -37,10 +38,12 @@ wire signed [13:0] adcDataMixedCut = adcDataMixed[27-:14];
|
|
|
|
|
|
wire signed [13:0] sinAdd = (ncoSin1>>>1)+(ncoSin2>>>1);
|
|
|
|
|
|
+reg signed [13:0] currTestData;
|
|
|
+
|
|
|
wire signed [17:0] wind;
|
|
|
|
|
|
-wire signed [13:0] singlePulse = (tbCnt>=4500&tbCnt<=4532)? 14'h1fff:14'h0;
|
|
|
-// wire signed [13:0] singlePulse = (tbCnt==4505)? 14'h1fff:14'h0;
|
|
|
+// wire signed [13:0] singlePulse = (tbCnt>=4500&tbCnt<=4550)? 14'h1fff:14'h0;
|
|
|
+wire signed [13:0] singlePulse = (tbCnt==4500)? 14'h1fff:14'h0;
|
|
|
//==========================================================================================
|
|
|
//clocks gen
|
|
|
always #10 Clk50 = ~Clk50;
|
|
|
@@ -50,7 +53,7 @@ always #10 Clk50 = ~Clk50;
|
|
|
parameter N = 8;
|
|
|
parameter M = 1;
|
|
|
|
|
|
-parameter MaxWidth = 38;
|
|
|
+parameter MaxWidth = 23;
|
|
|
|
|
|
initial begin
|
|
|
Clk50 = 1'b1;
|
|
|
@@ -60,6 +63,8 @@ initial begin
|
|
|
Rst = 1'b0;
|
|
|
end
|
|
|
|
|
|
+
|
|
|
+
|
|
|
always @(posedge Clk50) begin
|
|
|
if (!Rst) begin
|
|
|
tbCnt <= tbCnt+32'd1;
|
|
|
@@ -68,6 +73,16 @@ always @(posedge Clk50) begin
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+reg [10:0] oscWindDelay;
|
|
|
+
|
|
|
+always @(posedge Clk50) begin
|
|
|
+ if (!Rst) begin
|
|
|
+ oscWindDelay <= {oscWindDelay[20:0],oscWind};
|
|
|
+ end else begin
|
|
|
+ oscWindDelay <= 22'd0;
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
always @(posedge Clk50) begin
|
|
|
if (!Rst) begin
|
|
|
if (oscWind) begin
|
|
|
@@ -103,7 +118,7 @@ ncoInst1
|
|
|
.Clk_i (Clk50),
|
|
|
.Rst_i (Rst),
|
|
|
.Val_i (1'b1),
|
|
|
- .PhaseInc_i (32'h19999999),
|
|
|
+ .PhaseInc_i (32'h20000000),
|
|
|
.WindVal_i (1'b1),
|
|
|
.WinType_i (),
|
|
|
.Wind_o (),
|
|
|
@@ -124,7 +139,7 @@ ncoInst2
|
|
|
.Clk_i (Clk50),
|
|
|
.Rst_i (Rst),
|
|
|
.Val_i (1'b1),
|
|
|
- .PhaseInc_i (32'h428f5c28),
|
|
|
+ .PhaseInc_i (32'h3851eb85),
|
|
|
.WindVal_i (1'b1),
|
|
|
.WinType_i (),
|
|
|
.Wind_o (),
|
|
|
@@ -153,15 +168,40 @@ DecimFilter
|
|
|
.IfFtwL_i (24'h51eb85),
|
|
|
.IfFtwH_i (24'h23),
|
|
|
|
|
|
- .AdcData_i (singlePulse),
|
|
|
// .AdcData_i (sinAdd),
|
|
|
- // .AdcData_i (adcDataMixedCut),
|
|
|
+ .AdcData_i (adcData),
|
|
|
|
|
|
- .FilteredAdcDataI_o (resultI),
|
|
|
- .FilteredAdcDataQ_o (resultQ),
|
|
|
+ .FilteredAdcDataI_o (filteredDataOut),
|
|
|
+ .FilteredAdcDataQ_o (),
|
|
|
.FilteredDataVal_o (resultVal)
|
|
|
);
|
|
|
|
|
|
+DecimFilterWrapper
|
|
|
+#(
|
|
|
+ .AdcDataWidth (14),
|
|
|
+ .N (N),
|
|
|
+ .M (M),
|
|
|
+ .FilteredDataWidth (MaxWidth),
|
|
|
+ .FirOutDataWidth (48),
|
|
|
+ .FirOutCutBit (42)
|
|
|
+)
|
|
|
+ImpulseResponseFilter
|
|
|
+(
|
|
|
+ .Clk_i (Clk50),
|
|
|
+ .DecimFactor_i (decimFactor),
|
|
|
+ .Rst_i (Rst),
|
|
|
+ .OscWind_i (oscWind),
|
|
|
+
|
|
|
+ .IfFtwL_i (24'h51eb85),
|
|
|
+ .IfFtwH_i (24'h23),
|
|
|
+
|
|
|
+ .AdcData_i (singlePulse),
|
|
|
+
|
|
|
+ .FilteredAdcDataI_o (impResponse),
|
|
|
+ .FilteredAdcDataQ_o (),
|
|
|
+ .FilteredDataVal_o ()
|
|
|
+);
|
|
|
+
|
|
|
reg [32-1:0] windArg;
|
|
|
wire [31:0] WindPhInc = 32'h418937<<<decimFactor-2;
|
|
|
|
|
|
@@ -191,7 +231,7 @@ reg windResultVal;
|
|
|
always @(posedge Clk50) begin
|
|
|
if (!Rst) begin
|
|
|
if (valReg[1]) begin
|
|
|
- windResult <= wind*resultI;
|
|
|
+ windResult <= wind*filteredDataOut;
|
|
|
windResultVal <= 1'b1;
|
|
|
end else begin
|
|
|
windResultVal <= 1'b0;
|
|
|
@@ -217,7 +257,7 @@ wire signed [15:0] windResultCut = windResult[32-:16];
|
|
|
// .win_o (wind)
|
|
|
// );
|
|
|
|
|
|
-integer inSignal,filteredData;
|
|
|
+integer inSignal,filteredData, impResp;
|
|
|
parameter PNum = 5000;
|
|
|
|
|
|
always @(posedge Clk50) begin
|
|
|
@@ -226,22 +266,44 @@ always @(posedge Clk50) begin
|
|
|
end else begin
|
|
|
if (oscWind) begin
|
|
|
// $display("AdcData is %d", sinAdd);
|
|
|
- // $fwrite(inSignal,"%d\n", sinAdd);
|
|
|
- $fwrite(inSignal,"%d\n", singlePulse);
|
|
|
+ $fwrite(inSignal,"%d\n", sinAdd);
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+reg [31:0] testCnt;
|
|
|
+
|
|
|
+always @(posedge Clk50)begin
|
|
|
+ if (!Rst) begin
|
|
|
+ if (oscWindDelay[6]) begin
|
|
|
+ testCnt <= testCnt +1;
|
|
|
+ end
|
|
|
+ end else begin
|
|
|
+ testCnt <= 0;
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
always @(posedge Clk50) begin
|
|
|
if (Rst) begin
|
|
|
filteredData = $fopen("C:/S5243_FFT_REPO/src/src/Sim/FilteredData.txt","w");
|
|
|
end else begin
|
|
|
- if (resultVal) begin
|
|
|
- $fwrite(filteredData,"%d\n", resultI);
|
|
|
+ if (oscWindDelay[6] &testCnt<=999) begin
|
|
|
+ $fwrite(filteredData,"%d\n", filteredDataOut);
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+
|
|
|
+always @(posedge Clk50) begin
|
|
|
+ if (Rst) begin
|
|
|
+ impResp = $fopen("C:/S5243_FFT_REPO/src/src/Sim/ImpResp.txt","w");
|
|
|
+ end else begin
|
|
|
+ if (oscWindDelay[6] &testCnt<=999) begin
|
|
|
+ $fwrite(impResp,"%d\n", impResponse);
|
|
|
+ end
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
// always @(posedge Clk50) begin
|
|
|
// if (Rst) begin
|
|
|
// filteredData = $fopen("C:/Users/Stepan/Desktop/4portCompact/S5443Current/S5443_M/S5443.srcs/sources_1/new/filteredData.txt","w");
|