yhatagishi
Junior Member level 3
- Joined
- Apr 10, 2013
- Messages
- 26
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,508
The paper gives a good introduction to CIC filters. But the overflow problem isn't discussed in depth therein.The document I read is below. It gave me good ideas about CIC filter but never mentioned about modular arithemetic.
www.dspguru.com/sites/dspguru/files/cic.pdf
Thanks anyway!!
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY DSADC IS -- a delta sigma analog to digital converter
PORT (
clock : IN STD_LOGIC;
reset : IN STD_LOGIC;
data_in : IN STD_LOGIC;
dac_out : OUT STD_LOGIC; -- 1 bit out for dac
data_out : OUT STD_LOGIC_VECTOR(9 DOWNTO 0) -- the result of adc
);
END ENTITY;
ARCHITECTURE behavior OF DSADC IS
COMPONENT OverSampler IS -- a simple flip flop
PORT (
clock : IN STD_LOGIC;
reset : IN STD_LOGIC;
data_in : IN STD_LOGIC;
data_out : OUT STD_LOGIC
);
END COMPONENT OverSampler;
COMPONENT cic_filter IS -- the cic filter
PORT (
clock : IN STD_LOGIC;
reset : IN STD_LOGIC;
data_in : IN STD_LOGIC;
data_out : OUT STD_LOGIC_VECTOR(9 DOWNTO 0)
);
END COMPONENT cic_filter;
SIGNAL oversampled_data : STD_LOGIC;
BEGIN
dac_out <= oversampled_data;
compOverSampler : OverSampler
PORT MAP(clock, reset, data_in, oversampled_data);
compCIC : cic_filter
PORT MAP(clock, reset, oversampled_data, data_out);
END ARCHITECTURE behavior;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY cic_filter IS
PORT (
clock : IN STD_LOGIC;
reset : IN STD_LOGIC;
data_in : IN STD_LOGIC;
data_out : OUT STD_LOGIC_VECTOR(9 DOWNTO 0)
);
END ENTITY cic_filter;
ARCHITECTURE behavior OF cic_filter IS
COMPONENT integrator IS
PORT (
clock : IN STD_LOGIC; -- original clock
reset : IN STD_LOGIC;
bit_in : IN STD_LOGIC;
data_out : OUT STD_LOGIC_VECTOR(9 DOWNTO 0)
);
END COMPONENT integrator;
COMPONENT decimator IS
GENERIC (
decimation_rate : INTEGER RANGE 0 TO 1023 := 500
);
PORT (
clock : IN STD_LOGIC;
reset : IN STD_LOGIC;
data_in : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
decimated_clock : OUT STD_LOGIC;
data_out : OUT STD_LOGIC_VECTOR(9 DOWNTO 0)
);
END COMPONENT decimator;
COMPONENT comb IS
PORT (
clock : IN STD_LOGIC; -- decimated clock
reset : IN STD_LOGIC;
data_in : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
data_out : OUT STD_LOGIC_VECTOR(9 DOWNTO 0)
);
END COMPONENT comb;
SIGNAL int_result : STD_LOGIC_VECTOR(9 DOWNTO 0); -- corresponds to "data_out" of integrator and "data_in" of decimator
SIGNAL decimated_clock : STD_LOGIC; -- decimated by 512, corresponds to "clock" of comb
SIGNAL dec_result : STD_LOGIC_VECTOR(9 DOWNTO 0); -- corresponds to "data_out" of data_out" of decimation and "data_in" of comb
BEGIN
compIntegrator : integrator
PORT MAP(clock, reset, data_in, int_result);
compDecimator : decimator
GENERIC MAP(512)
PORT MAP(clock, reset, int_result, decimated_clock, dec_result);
compComb : comb
PORT MAP(decimated_clock, reset, dec_result, data_out);
END ARCHITECTURE behavior;
--------------------------------------------------------------------------------
-- integrator
-- works at original clock rate
--------------------------------------------------------------------------------
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY integrator IS
PORT (
clock : IN STD_LOGIC; -- original clock
reset : IN STD_LOGIC;
bit_in : IN STD_LOGIC;
data_out : OUT STD_LOGIC_VECTOR(9 DOWNTO 0)
);
END ENTITY integrator;
ARCHITECTURE behavior OF integrator IS
SIGNAL reg_data_out : STD_LOGIC_VECTOR(9 DOWNTO 0);
SIGNAL buf_data_out : STD_LOGIC_VECTOR(9 DOWNTO 0);
BEGIN
reg_data_out <= bit_in + buf_data_out;
data_out <= reg_data_out;
PROCESS(reset, clock)
BEGIN
IF (RISING_EDGE(clock)) THEN
IF (reset = '1') THEN
buf_data_out <= (OTHERS => '0');
ELSE
buf_data_out <= reg_data_out;
END IF;
END IF;
END PROCESS;
END ARCHITECTURE behavior;
--------------------------------------------------------------------------------
-- decimator
-- works at original clock rate and decimates it by rate of 512
--------------------------------------------------------------------------------
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.NUMERIC_STD.ALL;
ENTITY decimator IS
GENERIC (
decimation_rate : INTEGER RANGE 0 TO 1023 := 512
);
PORT (
clock : IN STD_LOGIC;
reset : IN STD_LOGIC;
data_in : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
decimated_clock : OUT STD_LOGIC;
data_out : OUT STD_LOGIC_VECTOR(9 DOWNTO 0)
);
END ENTITY decimator;
ARCHITECTURE behavior OF decimator IS
SIGNAL reg_data_out : STD_LOGIC_VECTOR(9 DOWNTO 0);
SIGNAL counter : INTEGER RANGE 0 TO decimation_rate - 1;
BEGIN
data_out <= reg_data_out;
PROCESS(reset, clock)
BEGIN
IF (RISING_EDGE(clock)) THEN
IF (reset = '1') THEN
decimated_clock <= '0';
reg_data_out <= (OTHERS => '0');
counter <= 0;
ELSE
IF (counter = (decimation_rate - 1)) THEN
reg_data_out <= data_in;
decimated_clock <= '1';
counter <= 0;
ELSE
decimated_clock <= '0';
counter <= counter + 1;
END IF;
END IF;
END IF;
END PROCESS;
END ARCHITECTURE behavior;
--------------------------------------------------------------------------------
-- comb
-- basically a fir filter with one negative feedfoward
--------------------------------------------------------------------------------
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY comb IS
PORT (
clock : IN STD_LOGIC; -- decimated clock
reset : IN STD_LOGIC;
data_in : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
data_out : OUT STD_LOGIC_VECTOR(9 DOWNTO 0)
);
END ENTITY comb;
ARCHITECTURE behavior OF comb IS
SIGNAL buf_data_in : STD_LOGIC_VECTOR(9 DOWNTO 0);
BEGIN
data_out <= data_in - buf_data_in;
PROCESS (reset, clock)
BEGIN
IF (RISING_EDGE(clock)) THEN
IF (reset = '1') THEN
buf_data_in <= (OTHERS => '0');
ELSE
buf_data_in <= data_in;
END IF;
END IF;
END PROCESS;
END ARCHITECTURE behavior;
IF (RISING_EDGE(clock)) THEN
IF (decimated_clock = '1') THEN
buf_data_in <= data_in;
END IF;
END IF;
Can you tell me what "stobing signal" is??There are many solution : try to check each step by mark LED warnning on you algorihm that call "Stobing Signal" , and you should design circuit for noise also by make delay time for seqence signal.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?