|
|
@@ -17,7 +17,7 @@ real signal;
|
|
|
reg [31:0] tbCnt;
|
|
|
reg [31:0] pNumCnt;
|
|
|
// wire oscWind = (tbCnt==4505)? 1'b1:1'b0;
|
|
|
-wire oscWind = (tbCnt>=4500&tbCnt<=6499)? 1'b1:1'b0;
|
|
|
+wire oscWind = (tbCnt>=4500&tbCnt<=4999)||(tbCnt>=5500&tbCnt<=5999)||(tbCnt>=6500&tbCnt<=6999)||(tbCnt>=7500&tbCnt<=7999)||(tbCnt>=8500&tbCnt<=8999)||(tbCnt>=9500&tbCnt<=9999)? 1'b1:1'b0;
|
|
|
// wire oscWind = (tbCnt>=1&)? 1'b1:1'b0;
|
|
|
|
|
|
wire signed [13:0] ncoSin1;
|
|
|
@@ -108,21 +108,33 @@ always @(posedge Clk50) begin
|
|
|
end
|
|
|
|
|
|
always @ (posedge Clk50) begin
|
|
|
- if (tbCnt >= 4505) begin
|
|
|
+ if (oscWind) begin
|
|
|
phase = phase + phaseInc;
|
|
|
phaseInc <= phaseInc + 0.0005;
|
|
|
signal = $sin(2*pi*phase);
|
|
|
adcData = 2**12 * signal;
|
|
|
end else begin
|
|
|
adcData = 0;
|
|
|
+ phase = 0;
|
|
|
+ phaseInc = 0.001;
|
|
|
end
|
|
|
end
|
|
|
|
|
|
always @(posedge Clk50) begin
|
|
|
if (!Rst) begin
|
|
|
if (tbCnt == 100) begin
|
|
|
- decimFactor <= 1;
|
|
|
- end
|
|
|
+ decimFactor <= 2;
|
|
|
+ end else if (tbCnt == 5400) begin
|
|
|
+ decimFactor <= 3;
|
|
|
+ end else if (tbCnt == 6400) begin
|
|
|
+ decimFactor <= 4;
|
|
|
+ end else if (tbCnt == 7400) begin
|
|
|
+ decimFactor <= 5;
|
|
|
+ end else if (tbCnt == 8400) begin
|
|
|
+ decimFactor <= 6;
|
|
|
+ end else if (tbCnt == 9400) begin
|
|
|
+ decimFactor <= 7;
|
|
|
+ end
|
|
|
end else begin
|
|
|
decimFactor <= 0;
|
|
|
end
|
|
|
@@ -208,7 +220,7 @@ DecimFilter
|
|
|
(
|
|
|
.Clk_i (Clk50),
|
|
|
.DecimFactor_i (decimFactor),
|
|
|
- .Rst_i (Rst),
|
|
|
+ .Rst_i (Rst|!oscWind),
|
|
|
.OscWind_i (oscWind),
|
|
|
|
|
|
.IfFtwL_i (24'h51eb85),
|
|
|
@@ -223,137 +235,137 @@ DecimFilter
|
|
|
.FilteredDataVal_o (resultVal)
|
|
|
);
|
|
|
|
|
|
-DecimFilterWrapper
|
|
|
-#(
|
|
|
- .AdcDataWidth (14),
|
|
|
- .N (N),
|
|
|
- .M (M),
|
|
|
- .FilteredDataWidth (MaxWidth),
|
|
|
- .FirOutDataWidth (48),
|
|
|
- .FirOutCutBit (42),
|
|
|
- .LsbForR1 (LsbForR1),
|
|
|
- .LsbForR2 (LsbForR2),
|
|
|
- .LsbForR4 (LsbForR4)
|
|
|
-)
|
|
|
-ImpulseResponseFilter
|
|
|
-(
|
|
|
- .Clk_i (Clk50),
|
|
|
- .DecimFactor_i (decimFactor),
|
|
|
- .Rst_i (Rst),
|
|
|
- .OscWind_i (oscWind),
|
|
|
+// DecimFilterWrapper
|
|
|
+// #(
|
|
|
+ // .AdcDataWidth (14),
|
|
|
+ // .N (N),
|
|
|
+ // .M (M),
|
|
|
+ // .FilteredDataWidth (MaxWidth),
|
|
|
+ // .FirOutDataWidth (48),
|
|
|
+ // .FirOutCutBit (42),
|
|
|
+ // .LsbForR1 (LsbForR1),
|
|
|
+ // .LsbForR2 (LsbForR2),
|
|
|
+ // .LsbForR4 (LsbForR4)
|
|
|
+// )
|
|
|
+// ImpulseResponseFilter
|
|
|
+// (
|
|
|
+ // .Clk_i (Clk50),
|
|
|
+ // .DecimFactor_i (decimFactor),
|
|
|
+ // .Rst_i (Rst),
|
|
|
+ // .OscWind_i (oscWind),
|
|
|
|
|
|
- .IfFtwL_i (24'h51eb85),
|
|
|
- .IfFtwH_i (24'h23),
|
|
|
+ // .IfFtwL_i (24'h51eb85),
|
|
|
+ // .IfFtwH_i (24'h23),
|
|
|
|
|
|
- .AdcData_i (singlePulse),
|
|
|
+ // .AdcData_i (singlePulse),
|
|
|
|
|
|
- .FilteredAdcDataI_o (impResponse),
|
|
|
- .FilteredAdcDataQ_o (),
|
|
|
- .FilteredDataVal_o ()
|
|
|
-);
|
|
|
+ // .FilteredAdcDataI_o (impResponse),
|
|
|
+ // .FilteredAdcDataQ_o (),
|
|
|
+ // .FilteredDataVal_o ()
|
|
|
+// );
|
|
|
|
|
|
-reg [32-1:0] windArg;
|
|
|
-wire [31:0] WindPhInc = 32'h418937<<<decimFactor-2;
|
|
|
+// reg [32-1:0] windArg;
|
|
|
+// wire [31:0] WindPhInc = 32'h418937<<<decimFactor-2;
|
|
|
|
|
|
-always @(posedge Clk50) begin
|
|
|
- if (!Rst) begin
|
|
|
- if (resultVal) begin
|
|
|
- windArg <= windArg+WindPhInc;
|
|
|
- end
|
|
|
- end else begin
|
|
|
- windArg <= WindPhInc>>1;
|
|
|
- end
|
|
|
-end
|
|
|
+// always @(posedge Clk50) begin
|
|
|
+ // if (!Rst) begin
|
|
|
+ // if (resultVal) begin
|
|
|
+ // windArg <= windArg+WindPhInc;
|
|
|
+ // end
|
|
|
+ // end else begin
|
|
|
+ // windArg <= WindPhInc>>1;
|
|
|
+ // end
|
|
|
+// end
|
|
|
|
|
|
-reg [1:0] valReg;
|
|
|
-always @(posedge Clk50) begin
|
|
|
- if (!Rst) begin
|
|
|
- valReg[0] <= resultVal;
|
|
|
- valReg[1] <= valReg[0];
|
|
|
- end else begin
|
|
|
- valReg <= 2'b0;
|
|
|
- end
|
|
|
-end
|
|
|
+// reg [1:0] valReg;
|
|
|
+// always @(posedge Clk50) begin
|
|
|
+ // if (!Rst) begin
|
|
|
+ // valReg[0] <= resultVal;
|
|
|
+ // valReg[1] <= valReg[0];
|
|
|
+ // end else begin
|
|
|
+ // valReg <= 2'b0;
|
|
|
+ // end
|
|
|
+// end
|
|
|
|
|
|
|
|
|
|
|
|
-integer inSignal,filteredData, impResp;
|
|
|
-parameter PNum = 5000;
|
|
|
+// integer inSignal,filteredData, impResp;
|
|
|
+// parameter PNum = 5000;
|
|
|
|
|
|
-wire signed [17:0] firDataOut;
|
|
|
-wire signed [17:0] firRespout;
|
|
|
-wire firDataVal;
|
|
|
-wire firRespVal;
|
|
|
+// wire signed [17:0] firDataOut;
|
|
|
+// wire signed [17:0] firRespout;
|
|
|
+// wire firDataVal;
|
|
|
+// wire firRespVal;
|
|
|
|
|
|
-systolicFilter DataFitler (
|
|
|
- .Clk_i(Clk50),
|
|
|
- .Rst_i(Rst),
|
|
|
- .Data_i(sinAddExt18),
|
|
|
- .DataNd_i(oscWind),
|
|
|
- .Data_o(firDataOut),
|
|
|
- .DataValid_o(firDataVal)
|
|
|
-);
|
|
|
+// systolicFilter DataFitler (
|
|
|
+ // .Clk_i(Clk50),
|
|
|
+ // .Rst_i(Rst),
|
|
|
+ // .Data_i(sinAddExt18),
|
|
|
+ // .DataNd_i(oscWind),
|
|
|
+ // .Data_o(firDataOut),
|
|
|
+ // .DataValid_o(firDataVal)
|
|
|
+// );
|
|
|
|
|
|
-systolicFilter RespFilter (
|
|
|
- .Clk_i(Clk50),
|
|
|
- .Rst_i(Rst),
|
|
|
- .Data_i(singlePulseExt),
|
|
|
- .DataNd_i(oscWind),
|
|
|
- .Data_o(firRespout),
|
|
|
- .DataValid_o(firRespVal)
|
|
|
-);
|
|
|
+// systolicFilter RespFilter (
|
|
|
+ // .Clk_i(Clk50),
|
|
|
+ // .Rst_i(Rst),
|
|
|
+ // .Data_i(singlePulseExt),
|
|
|
+ // .DataNd_i(oscWind),
|
|
|
+ // .Data_o(firRespout),
|
|
|
+ // .DataValid_o(firRespVal)
|
|
|
+// );
|
|
|
|
|
|
|
|
|
|
|
|
-always @(posedge Clk50) begin
|
|
|
- if (Rst) begin
|
|
|
- inSignal = $fopen("C:/S5243_FFT_REPO/src/src/Sim/InputSignal.txt","w");
|
|
|
- end else begin
|
|
|
- if (oscWind) begin
|
|
|
+// always @(posedge Clk50) begin
|
|
|
+ // if (Rst) begin
|
|
|
+ // inSignal = $fopen("C:/S5243_FFT_REPO/src/src/Sim/InputSignal.txt","w");
|
|
|
+ // end else begin
|
|
|
+ // if (oscWind) begin
|
|
|
// $display("AdcData is %d", sinAdd);
|
|
|
- $fwrite(inSignal,"%d\n", sinAddExt18);
|
|
|
+ // $fwrite(inSignal,"%d\n", sinAddExt18);
|
|
|
// $fwrite(inSignal,"%d\n", sinAdd);
|
|
|
- end
|
|
|
- end
|
|
|
-end
|
|
|
-
|
|
|
-reg [31:0] testCnt;
|
|
|
-wire [10:0] test = N*2+N*2+decimFactor;
|
|
|
-wire [10:0] test1 = N*2+N*2+decimFactor-1;
|
|
|
-wire writeEn = (oscWindDelay[N*2+N*2+decimFactor]);
|
|
|
-
|
|
|
-always @(posedge Clk50)begin
|
|
|
- if (!Rst) begin
|
|
|
- if (writeEn) begin
|
|
|
- testCnt <= testCnt +1;
|
|
|
- end
|
|
|
- end else begin
|
|
|
- testCnt <= 0;
|
|
|
- end
|
|
|
-end
|
|
|
+ // end
|
|
|
+ // end
|
|
|
+// end
|
|
|
+
|
|
|
+// reg [31:0] testCnt;
|
|
|
+// wire [10:0] test = N*2+N*2+decimFactor;
|
|
|
+// wire [10:0] test1 = N*2+N*2+decimFactor-1;
|
|
|
+// wire writeEn = (oscWindDelay[N*2+N*2+decimFactor]);
|
|
|
+
|
|
|
+// always @(posedge Clk50)begin
|
|
|
+ // if (!Rst) begin
|
|
|
+ // if (writeEn) 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 (firDataVal) begin
|
|
|
+// always @(posedge Clk50) begin
|
|
|
+ // if (Rst) begin
|
|
|
+ // filteredData = $fopen("C:/S5243_FFT_REPO/src/src/Sim/FilteredData.txt","w");
|
|
|
+ // end else begin
|
|
|
+ // if (firDataVal) begin
|
|
|
// $fwrite(filteredData,"%d\n", filteredDataOut);
|
|
|
- $fwrite(filteredData,"%d\n", firDataOut);
|
|
|
- end
|
|
|
- end
|
|
|
-end
|
|
|
+ // $fwrite(filteredData,"%d\n", firDataOut);
|
|
|
+ // 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 (firDataVal) begin
|
|
|
- $fwrite(impResp,"%d\n", firRespout);
|
|
|
+// always @(posedge Clk50) begin
|
|
|
+ // if (Rst) begin
|
|
|
+ // impResp = $fopen("C:/S5243_FFT_REPO/src/src/Sim/ImpResp.txt","w");
|
|
|
+ // end else begin
|
|
|
+ // if (firDataVal) begin
|
|
|
+ // $fwrite(impResp,"%d\n", firRespout);
|
|
|
// $fwrite(impResp,"%d\n", m_axis_data_tdata_imp);
|
|
|
- end
|
|
|
- end
|
|
|
-end
|
|
|
+ // end
|
|
|
+ // end
|
|
|
+// end
|
|
|
|
|
|
// always @(posedge Clk50) begin
|
|
|
// if (Rst) begin
|