|
|
@@ -7,6 +7,7 @@ reg Rst;
|
|
|
|
|
|
reg [2:0] decimFactor;
|
|
|
|
|
|
+parameter MaxWidth = 32;
|
|
|
|
|
|
reg [13:0] adcData;
|
|
|
real pi = 3.14159265358;
|
|
|
@@ -16,8 +17,8 @@ real signal;
|
|
|
|
|
|
reg [31:0] tbCnt;
|
|
|
reg [31:0] pNumCnt;
|
|
|
-// wire oscWind = (tbCnt==4505)? 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>=4500&tbCnt<=4999)? 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;
|
|
|
@@ -25,7 +26,7 @@ wire signed [13:0] ncoSin2;
|
|
|
wire signed [13:0] ncoSin3;
|
|
|
|
|
|
wire signed [15:0] filteredDataOut;
|
|
|
-wire signed [15:0] impResponse;
|
|
|
+wire signed [MaxWidth-1:0] impResponse;
|
|
|
|
|
|
wire resultVal;
|
|
|
wire respVal;
|
|
|
@@ -46,7 +47,7 @@ reg signed [13:0] currTestData;
|
|
|
wire signed [17:0] wind;
|
|
|
|
|
|
// wire signed [13:0] singlePulse = (tbCnt>=4500&tbCnt<=4550)? 14'h1fff:14'h0;
|
|
|
-wire signed [13:0] singlePulse = (tbCnt==5550)? 14'h1fff:14'h0;
|
|
|
+wire signed [13:0] singlePulse = (tbCnt==4551)? 14'h1fff:14'h0;
|
|
|
wire signed [17:0] singlePulseExt = (tbCnt==4500)? 18'h1ffff:14'h0;
|
|
|
// wire signed [15:0] singlePulseExt = (tbCnt>=4500&tbCnt<=4501)? 16'h7fff:14'h0;
|
|
|
wire inglePulseExtVal = (tbCnt==4500)? 1:0;
|
|
|
@@ -55,18 +56,17 @@ wire inglePulseExtVal = (tbCnt==4500)? 1:0;
|
|
|
always #10 Clk50 = ~Clk50;
|
|
|
|
|
|
//==========================================================================================
|
|
|
-parameter N = 4;
|
|
|
-parameter M = 1;
|
|
|
+parameter N = 8;
|
|
|
+parameter M = 2;
|
|
|
+
|
|
|
|
|
|
-parameter MaxWidth = 18;
|
|
|
|
|
|
parameter LsbForR1 = 10'd16;
|
|
|
parameter LsbForR2 = 10'd18;
|
|
|
parameter LsbForR4 = 10'd18;
|
|
|
|
|
|
-parameter [31:0] Nco1PhaseInc = 32'ha0000000;
|
|
|
-// parameter [31:0] Nco2PhaseInc = 32'h428f5c28;
|
|
|
-parameter [31:0] Nco2PhaseInc = 32'hf5c28f5;
|
|
|
+parameter [31:0] Nco1PhaseInc = 32'h051eb852; //3mhz
|
|
|
+parameter [31:0] Nco2PhaseInc = 32'h40000000; //15
|
|
|
parameter [31:0] Nco3PhaseInc = 32'h428f5c28;
|
|
|
|
|
|
initial begin
|
|
|
@@ -111,7 +111,7 @@ end
|
|
|
always @ (posedge Clk50) begin
|
|
|
if (oscWind) begin
|
|
|
phase = phase + phaseInc;
|
|
|
- phaseInc <= phaseInc + 0.0005;
|
|
|
+ phaseInc <= phaseInc + 0.003;
|
|
|
signal = $sin(2*pi*phase);
|
|
|
adcData = 2**12 * signal;
|
|
|
end else begin
|
|
|
@@ -124,22 +124,23 @@ end
|
|
|
always @(posedge Clk50) begin
|
|
|
if (!Rst) begin
|
|
|
if (tbCnt == 100) begin
|
|
|
- decimFactor <= 0;
|
|
|
- end else if (tbCnt == 5400) begin
|
|
|
- decimFactor <= 1;
|
|
|
- end else if (tbCnt == 6400) begin
|
|
|
decimFactor <= 2;
|
|
|
- end else if (tbCnt == 7400) begin
|
|
|
- decimFactor <= 3;
|
|
|
- end else if (tbCnt == 8400) begin
|
|
|
- decimFactor <= 4;
|
|
|
- end else if (tbCnt == 9400) begin
|
|
|
- decimFactor <= 5;
|
|
|
- end else if (tbCnt == 10400) begin
|
|
|
- decimFactor <= 6;
|
|
|
- end else if (tbCnt == 11400) begin
|
|
|
- decimFactor <= 7;
|
|
|
end
|
|
|
+ // end else if (tbCnt == 5400) begin
|
|
|
+ // decimFactor <= 1;
|
|
|
+ // end else if (tbCnt == 6400) begin
|
|
|
+ // decimFactor <= 2;
|
|
|
+ // end else if (tbCnt == 7400) begin
|
|
|
+ // decimFactor <= 3;
|
|
|
+ // end else if (tbCnt == 8400) begin
|
|
|
+ // decimFactor <= 4;
|
|
|
+ // end else if (tbCnt == 9400) begin
|
|
|
+ // decimFactor <= 5;
|
|
|
+ // end else if (tbCnt == 10400) begin
|
|
|
+ // decimFactor <= 6;
|
|
|
+ // end else if (tbCnt == 11400) begin
|
|
|
+ // decimFactor <= 7;
|
|
|
+ // end
|
|
|
end else begin
|
|
|
decimFactor <= 2;
|
|
|
end
|
|
|
@@ -209,7 +210,7 @@ ncoInst3
|
|
|
);
|
|
|
|
|
|
|
|
|
-DecimFilterWrapper
|
|
|
+DecimFilterWrapperTest
|
|
|
#(
|
|
|
.AdcDataWidth (14),
|
|
|
.N (N),
|
|
|
@@ -229,15 +230,15 @@ DecimFilter
|
|
|
.DataVal_i (oscWind),
|
|
|
|
|
|
// .Data_i (sinAdd),
|
|
|
- // .Data_i (adcDataMixedCut),
|
|
|
+ .Data_i (adcDataMixedCut),
|
|
|
// .Data_i (adcData),
|
|
|
- .Data_i (ncoSin2),
|
|
|
+ // .Data_i (ncoSin2),
|
|
|
|
|
|
.Data_o (filteredDataOut),
|
|
|
.DataVal_o (resultVal)
|
|
|
);
|
|
|
|
|
|
-DecimFilterWrapper
|
|
|
+DecimFilterWrapperTest
|
|
|
#(
|
|
|
.AdcDataWidth (14),
|
|
|
.N (N),
|
|
|
@@ -287,8 +288,8 @@ ImpulseResponseFilter
|
|
|
|
|
|
|
|
|
|
|
|
-// integer inSignal,filteredData, impResp;
|
|
|
-// parameter PNum = 5000;
|
|
|
+integer inSignal,filteredData, impResp;
|
|
|
+parameter PNum = 5000;
|
|
|
|
|
|
// wire signed [17:0] firDataOut;
|
|
|
// wire signed [17:0] firRespout;
|
|
|
@@ -315,65 +316,56 @@ ImpulseResponseFilter
|
|
|
|
|
|
|
|
|
|
|
|
-// 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 (tbCnt==32'd1) 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", sinAdd);
|
|
|
- // end
|
|
|
- // end
|
|
|
-// end
|
|
|
+ $fwrite(inSignal,"%d\n", adcDataMixedCut);
|
|
|
+ // $fwrite(inSignal,"%d\n", adcData);
|
|
|
+ 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]);
|
|
|
+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
|
|
|
+ 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
|
|
|
- // $fwrite(filteredData,"%d\n", filteredDataOut);
|
|
|
+always @(posedge Clk50) begin
|
|
|
+ if (tbCnt==32'd1) begin
|
|
|
+ filteredData = $fopen("C:/S5243_FFT_REPO/src/src/Sim/FilteredData.txt","w");
|
|
|
+ end else begin
|
|
|
+ if (resultVal) begin
|
|
|
+ $fwrite(filteredData,"%d\n", filteredDataOut);
|
|
|
// $fwrite(filteredData,"%d\n", firDataOut);
|
|
|
- // end
|
|
|
- // end
|
|
|
-// end
|
|
|
+ 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
|
|
|
+always @(posedge Clk50) begin
|
|
|
+ if (tbCnt==32'd1) begin
|
|
|
+ impResp = $fopen("C:/S5243_FFT_REPO/src/src/Sim/ImpResp.txt","w");
|
|
|
+ end else begin
|
|
|
+ if (resultVal) begin
|
|
|
// $fwrite(impResp,"%d\n", firRespout);
|
|
|
- // $fwrite(impResp,"%d\n", m_axis_data_tdata_imp);
|
|
|
- // 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");
|
|
|
- // end else begin
|
|
|
- // if (windResultVal) begin
|
|
|
- // $fwrite(filteredData,"%d\n", windResultCut);
|
|
|
- // end
|
|
|
- // end
|
|
|
-// end
|
|
|
+ $fwrite(impResp,"%d\n", impResponse);
|
|
|
+ end
|
|
|
+ end
|
|
|
+end
|
|
|
|
|
|
endmodule
|
|
|
|