|
|
@@ -16,10 +16,13 @@ real phaseInc = 0.001;
|
|
|
real signal;
|
|
|
|
|
|
reg [31:0] tbCnt;
|
|
|
-reg [31:0] pNumCnt;
|
|
|
-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 [31:0] startValue = 32'd10;
|
|
|
+wire [31:0] pNum = 8;
|
|
|
+wire [31:0] stopValue = startValue+pNum-1;
|
|
|
+
|
|
|
+// wire oscWind = (tbCnt>=10&tbCnt<=509)? 1'b1:1'b0;
|
|
|
+wire oscWind = (tbCnt>=startValue & tbCnt<=stopValue)? 1'b1:1'b0;
|
|
|
|
|
|
wire signed [13:0] ncoSin1;
|
|
|
wire signed [13:0] ncoSin2;
|
|
|
@@ -29,7 +32,7 @@ wire signed [MaxWidth-1:0] filteredDataOut;
|
|
|
wire signed [MaxWidth-1:0] impResponse;
|
|
|
|
|
|
wire resultVal;
|
|
|
-wire respVal;
|
|
|
+wire impRespVal;
|
|
|
|
|
|
|
|
|
// wire signed [27:0] adcDataMixed = oscWind?(ncoSin1*ncoSin2):28'd0;
|
|
|
@@ -40,23 +43,25 @@ wire signed [13:0] adcDataMixedCut = adcDataMixed[26-:14];
|
|
|
wire signed [13:0] sinAdd = (ncoSin1>>>1)+(ncoSin2>>>1);
|
|
|
// wire signed [13:0] sinAdd = ncoSin1;
|
|
|
|
|
|
-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==4502)? 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;
|
|
|
+wire signed [13:0] singlePulse = (tbCnt==10)? 14'h1fff:14'h0;
|
|
|
+// wire signed [13:0] singlePulse = (tbCnt>=4500&tbCnt<=4501)? 14'h1fff:14'h0;
|
|
|
//==========================================================================================
|
|
|
//clocks gen
|
|
|
always #10 Clk50 = ~Clk50;
|
|
|
|
|
|
//==========================================================================================
|
|
|
-parameter N = 1;
|
|
|
+parameter N = 3;
|
|
|
parameter M = 1;
|
|
|
|
|
|
+always @(posedge Clk50) begin
|
|
|
+ if (!Rst) begin
|
|
|
+ decimFactor <= 2;
|
|
|
+ end else begin
|
|
|
+ decimFactor <= 0;
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
parameter LsbForR1 = 10'd16;
|
|
|
parameter LsbForR2 = 10'd18;
|
|
|
parameter LsbForR4 = 10'd18;
|
|
|
@@ -89,18 +94,6 @@ always @(posedge Clk50) begin
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-always @(posedge Clk50) begin
|
|
|
- if (!Rst) begin
|
|
|
- if (oscWind) begin
|
|
|
- pNumCnt <= pNumCnt+32'd1;
|
|
|
- end else begin
|
|
|
- pNumCnt <= 32'd0;
|
|
|
- end
|
|
|
- end else begin
|
|
|
- pNumCnt <= 32'd0;
|
|
|
- end
|
|
|
-end
|
|
|
-
|
|
|
always @ (posedge Clk50) begin
|
|
|
if (oscWind) begin
|
|
|
phase = phase + phaseInc;
|
|
|
@@ -114,30 +107,7 @@ always @ (posedge Clk50) begin
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-always @(posedge Clk50) begin
|
|
|
- if (!Rst) begin
|
|
|
- if (tbCnt == 100) begin
|
|
|
- decimFactor <= 2;
|
|
|
- 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
|
|
|
-end
|
|
|
+
|
|
|
|
|
|
CordicNco
|
|
|
#(
|
|
|
@@ -231,7 +201,7 @@ ImpulseResponseFilter
|
|
|
.Data_i (singlePulse),
|
|
|
|
|
|
.Data_o (impResponse),
|
|
|
- .DataVal_o ()
|
|
|
+ .DataVal_o (impRespVal)
|
|
|
);
|
|
|
|
|
|
|
|
|
@@ -256,7 +226,8 @@ 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-1]);
|
|
|
+// wire writeEn = (oscWindDelay[N*2+N*2+decimFactor-2]);
|
|
|
+wire writeEn = (tbCnt>= (startValue+(N*2*2)+decimFactor) & tbCnt <= (stopValue+(N*2*2)+decimFactor));
|
|
|
|
|
|
always @(posedge Clk50)begin
|
|
|
if (!Rst) begin
|
|
|
@@ -274,7 +245,6 @@ always @(posedge Clk50) begin
|
|
|
end else begin
|
|
|
if (resultVal) begin
|
|
|
$fwrite(filteredData,"%d\n", filteredDataOut);
|
|
|
- // $fwrite(filteredData,"%d\n", firDataOut);
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
@@ -284,8 +254,8 @@ 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);
|
|
|
+ if (writeEn) begin
|
|
|
+ // if (impRespVal) begin
|
|
|
$fwrite(impResp,"%d\n", impResponse);
|
|
|
end
|
|
|
end
|