ΔΣ-ADC実験編 その21 補償フィルタらしきものが、出来ました 1.なんとか、できました module myADC(
clk,D,neg_q,q ); input
clk; ////////////////////////////////////// reg [19:0]
data=0; singleRAM singleRAM (.Clock(clkop),
.ClockEn(1'b1), .Reset(reset), .WE(we), .Address(address),
.Data(result_wire_out), .Q(q_out)); assign
neg_q=~Qinner; assign
fir_result_unsigned=fir_result +
30'h1fff_ffff; accum #(
OUTPUT_WIDTH+4) accum(clkop,fir_result_unsigned,q); always @(posedge
clkop) begin end endmodule parameter OUTPUT_WIDTH=26; input clk; reg signed[OUTPUT_WIDTH:0]yn=0; always@(posedge
clk) begin end module accum(clk,VDA,cy_out); parameter
DATA_WIDTH2=18; ///// internal variables
//////// assign cy_out= cy; always @(posedge clk)
begin endmodule
20KHz
input (出力あり)
40KHz input(出力無し)
複雑に絡み合う要素を、前節で、整理したお陰で、タイミングが掴めました。
\(^_^)\
皆さん、ありがとうございます、 m(_ _)m
元のsampling周波数 56.8MHzまで、全体を眺めてみると
40KHz output時
40KHzを超える周波数の入力では、上図のように、なります。(つまり、出力がない状態)
仕様としては
入力周波数が 7080KHzだとすると
1bit
bandpass ΔΣ-ADC(7100KHzが中心)を通す -> 7100KHz
out NCOとmix ->その差 20KHzを出力
-> CICフィルタ1段にて、1/256分割 (
fs=56800KHz/256 = 221.875KHz )
-> fs=221.875KHz
にて、 255taps の補償フィルタ( fir flter : cutoff
=30KHz)を通す。
-> Pulse Desity Modulation にて、 1bit 出力 ( no LowPass filter : bare
output )
NCO
:18bits 7100KHz output
CIC filter : input 18bits
mixed_sin -> output 27bits
singleRAM : 27bits (Q26) data, 256
address
fir
coef : 20bits (Q19) data, 256
address
mac
: input 27bits (Q26) , 20bits
(Q19) : output 30bits ( accumulator[45:16]
) : accumulator 63bits (Q45)
20KHz output
fir filterの仕様を、変えています。
Lattice
Diamond の Reports 及び verilog HDL 記述の全プログラムは
Design
Information
Command line: map -a
LatticeXP2 -p LFXP2-5E -t TQFP144 -s 5 -oc
Commercial
myADC_CIC1_FIR2_myADC_CIC1_FIR2.ngd
-o
myADC_CIC1_FIR2_myADC_CIC1_FIR2_map.ncd
-pr
myADC_CIC1_FIR2_myADC_CIC1_FIR2.prf -mp
myADC_CIC1_FIR2_myADC_CIC1_FIR2.mrp
D:/Diamond/myADC__CIC1_FIR2/myADC_CIC1_FIR2.lpf
Target Vendor:
LATTICE
Target Device: LFXP2-5ETQFP144
Target
Speed: 5
Mapper: mg5a00, version:
Diamond_1.0_Production (529)
Mapped on: 10/15/10
11:32:26
Design
Summary
Number of
registers: 269
PFU
registers: 268
PIO
registers: 1
Number of
SLICEs: 264
out of 2376 (11%)
SLICEs(logic/ROM): 264 out of
1971 (13%)
SLICEs(logic/ROM/RAM): 0 out of 405
(0%)
As
RAM: 0
out of 405
(0%)
As
Logic/ROM: 0 out of 405
(0%)
Number of logic LUT4s:
147
Number of distributed RAM: 0 (0
LUT4s)
Number of ripple logic: 123 (246
LUT4s)
Number of shift registers:
0
Total number of LUT4s:
393
Number of PIO sites used: 4 out of 100
(4%)
Number of PIO FIXEDDELAY:
0
Number of DQSDLLs: 0 out of 2 (0%)
Number of PLLs: 1 out of 2 (50%)
Number of block
RAMs: 3 out of 9 (33%)
Number of CLKDIVs: 0
out of 2 (0%)
Number of GSRs: 0 out of 1
(0%)
JTAG used :
No
Readback used : No
Oscillator
used : No
Startup used :
No
Notes:-
1. Total
number of LUT4s = (Number of logic LUT4s) + 2*(Number
of
distributed RAMs) + 2*(Number of ripple
logic)
2. Number of logic LUT4s does not
include count of distributed RAM and
ripple
logic.
Number Of Mapped DSP
Components:
--------------------------------
MULT36X36B
1
MULT18X18B
0
MULT18X18MACB
0
MULT18X18ADDSUBB 0
MULT18X18ADDSUBSUMB 0
MULT9X9B
0
MULT9X9ADDSUBB
0
MULT9X9ADDSUBSUMB 0
--------------------------------
Number of Used DSP
Sites: 8 out of 24 (33 %)
Number of
clocks: 2
Net clk_c: 21 loads, 21
rising, 0 falling (Driver: PIO clk )
Net
clkop_c: 132 loads, 132 rising, 0 falling (Driver: myPLL/PLLInst_0
)
Number of Clock Enables:
5
Net lock: 6 loads, 6
LSLICEs
Net N_154_i: 4 loads, 4
LSLICEs
Net cic/z_1_2: 28 loads, 28
LSLICEs
Net fir_result_1_sqmuxa: 15 loads, 15
LSLICEs
Net m5_e_1: 5 loads, 5
LSLICEs
Number of LSRs: 0
Number of
nets driven by tri-state buffers:
0
Memory Usage
INFO: Design contains EBR with ASYNC Reset Mode that has a limitation:
The use of the EBR block asynchronous reset requires that certain timing
be met between the clock and the reset within the memory block.
See the device specific data sheet for additional details.
/fir_rom:
EBRs: 1
RAM SLICEs: 0
Logic SLICEs: 0
PFU Registers: 0
-Contains EBR fir_rom_0_0_0: TYPE= DP16KB, Width_A= 18, Width_B= 2,
Depth_A= 256, Depth_B= 256, REGMODE_A= OUTREG, REGMODE_B= OUTREG,
RESETMODE= SYNC, WRITEMODE_A= NORMAL, WRITEMODE_B= NORMAL, GSR=
DISABLED, MEM_INIT_FILE= fir_256_2.mem, MEM_LPC_FILE= fir_rom.lpc
/sin:
EBRs: 1
RAM SLICEs: 0
Logic SLICEs: 30
PFU Registers: 30
-Contains EBR triglut_1_0_0_0: TYPE= DP16KB, Width_A= 18, Depth_A= 256,
REGMODE_A= NOREG, REGMODE_B= NOREG, RESETMODE= ASYNC, WRITEMODE_A=
NORMAL, WRITEMODE_B= NORMAL, GSR= DISABLED, MEM_LPC_FILE= sin.lpc
/singleRAM:
EBRs: 1
RAM SLICEs: 0
Logic SLICEs: 0
PFU Registers: 0
-Contains EBR singleRAM_0_0_0: TYPE= DP16KB, Width_A= 18, Width_B= 9,
Depth_A= 256, Depth_B= 256, REGMODE_A= OUTREG, REGMODE_B= OUTREG,
RESETMODE= SYNC, WRITEMODE_A= NORMAL, WRITEMODE_B= NORMAL, GSR=
DISABLED, MEM_LPC_FILE= singleRAM.lpc
DSP Component Details
. MULT36X36B mac/dsp_0:
Multiplier
Operation Signed
Operation Registers CLK CE RST
--------------------------------------------
Input
Pipeline
Operation Registers CLK CE RST
--------------------------------------------
Input
Pipeline
Data
Input Registers CLK CE RST
--------------------------------------------
A CLK0 CE0 RST0
B CLK0 CE0 RST0
Pipeline Registers CLK CE RST
--------------------------------------------
Pipe CLK0 CE0 RST0
Output Register CLK CE RST
--------------------------------------------
Output
Other
GSR DISABLED
PLL/DLL Summary
---------------
PLL 1: Pin/Node Value
PLL Instance Name: myPLL/PLLInst_0
PLL Type: EPLLD
Input Clock: PIN clk_c
Output Clock(P): NODE clkop_c
Output Clock(S): NONE
Output Clock(K): NONE
PLL Feedback Signal: NODE clkop_c
PLL Reset Signal: NONE
PLL K Divider Reset Signal: NONE
PLL LOCK Signal: NODE lock
Dynamic Phase Adjust Input 0: NONE
Dynamic Phase Adjust Input 1: NONE
Dynamic Phase Adjust Input 2: NONE
Dynamic Phase Adjust Input 3: NONE
Dynamic Duty Adjust Input 0: NONE
Dynamic Duty Adjust Input 1: NONE
Dynamic Duty Adjust Input 2: NONE
Dynamic Duty Adjust Input 3: NONE
Input Clock Frequency (MHz): 113.6000
Output Clock(P) Frequency (MHz): 56.8000
Output Clock(K) Frequency (MHz): NA
Output Clock(P) Actual Frequency: 57.0000
CLKOP BYPASS: DISABLED
CLKOS BYPASS: DISABLED
CLKOK BYPASS: DISABLED
CLKI Divider: 2
CLKFB Divider: 1
CLKOP Divider: 8
CLKOK Divider: 2
CLKOS Phase Shift (degree): 0.0
CLKOS Duty Cycle (*1/16): 8
Phase_Duty Control: STATIC
FB_MODE: NONE
-------------------------------------------------------------------------------
Preference Summary
///////////////////////////////////////////////
verilog HDL 記述 program
///////////////////////////////////////////
input D;
output
neg_q;
output q;
wire
clkop;
wire lock;
reg
Qinner=0;
parameter OUTPUT_WIDTH=26;
parameter R =
256;
reg [9:0]theta=0;
wire signed[18:0]sine;
wire signed[18:0]mixed_sin;
wire signed[
OUTPUT_WIDTH:0]result_wire;
wire signed[19:0]result_wire_out; //signed 20bits
out
//singleRAM
wire reset;
reg we = 0;
reg [7:0] address =
0;
reg [7:0] wr_address = 0;
// reg
[7:0] i;
reg [7:0] count = 0; //[7:0] =256
count [6:0] 128 count
// wire [19:0]
data;
wire signed[19:0]
q_out;
// reg start=1;
// reg [7:0] decim_count
= 0;
reg decim_clk = 0;
//// mac
///////////////////
reg accumsload =1;
wire
overflow;
wire signed[55:0] accumulator;
// reg signed[55:0] ld = 0;
//// fir rom
////////////////
reg [7:0] rom_address =
255;
wire reset_fir;
wire signed[19:0]
rom_data;
//////////////////////////
reg
signed[29:0] fir_result;
wire [29:0]
fir_result_unsigned;
/*
////////////////////////////////////////////////////
GSR GSR_INST (.GSR(1'b1));
PUR PUR_INST
(.PUR(1'b1));
///////////////////////////////////////////////////
*/
//use myPLL
instance
myPLL myPLL(.CLK(clk),.CLKOP(clkop),.LOCK(lock));
sin sin(.Clock(clk),
.ClkEn(1'b1), .Reset(1'b0), .Theta(theta),
.Sine(sine));
cic_filter cic(clkop,mixed_sin,result_wire);
fir_rom
fir_rom(.Address(rom_address), .OutClock(clkop),
.OutClockEn(1'b1), .Reset(1'b0), .Q(rom_data));
mac
mac(.CLK0(clkop), .ACCUMSLOAD(accumsload),
.A(q_out), .B(rom_data), .LD(56'd0), .OVERFLOW(overflow),
.ACCUM(accumulator));
assign mixed_sin=(Qinner ? sine :
-sine);
assign
result_wire_out=result_wire[OUTPUT_WIDTH:7]; //20bits
if(lock)
begin
count = count +1;
we = 0;
address =
address - 1;
rom_address = rom_address +
1'b1;
accumsload =
0;
case (count)
0:
begin
we = 1;
address
=wr_address;
data =
address;
wr_address = wr_address +
1;
decim_clk = ~decim_clk;
end
1: address = address
+1;
2: accumsload
=1;
3:fir_result = accumulator[38:9]; //
convolution result
128: decim_clk =
~decim_clk;
default
:;
endcase
end
always@(posedge
clkop) begin
Qinner
=D;
end
always@(posedge
clk) begin
theta=theta+64;
end
module
cic_filter(clk,data_input,data_out);
input signed[18:0]data_input;
output signed[OUTPUT_WIDTH:0]data_out;
reg signed[OUTPUT_WIDTH:0]yn_1=0;
reg signed[OUTPUT_WIDTH:0]z[1:0];
reg signed[OUTPUT_WIDTH:0]result=0;//
output
reg [7:0]count=0; //256
count
assign
data_out=result;
//scaling factor :
MOVING_AVEは、省略する。
//integrator
yn=yn_1+data_input;
yn_1=yn;
count=count+1;
if(count==0)
begin //decimation
ratio
z[1]=z[0];
z[0]=yn;
//differentiator
result=z[0]-z[1];
end
endmodule
input clk;
input
[DATA_WIDTH2-1:0] VDA;
output cy_out;
reg [DATA_WIDTH2-1:0] R=0;
reg cy=0;
{cy,R} <=R+VDA;
end