Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

kcounter loop filter

Status
Not open for further replies.

manishpatkar

Junior Member level 1
Joined
Oct 6, 2017
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
159
i am trying to code adpll on xilinx vivado , i am not ble get the logic for kcounter loop filter! if someone can help me atleast with the logic or code, it would be really helpfull!

my pfd code is here

Code:
----------------------------------------------------------------------------------
-- Company: 
-- Engineer: 
-- 
-- Create Date: 10/27/2017 12:01:45 AM
-- Design Name: 
-- Module Name: pfd1 - Behavioral
-- Project Name: 
-- Target Devices: 
-- Tool Versions: 
-- Description: 
-- 
-- Dependencies: 
-- 
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-- 
----------------------------------------------------------------------------------


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity pfd1 is
    Port ( 
           A : in STD_LOGIC;
           ref : in STD_LOGIC;
           div : in STD_LOGIC;
           UP : out STD_LOGIC;
           DOWN : out STD_LOGIC);
end pfd1;

architecture Behavioral of pfd1 is

signal up1 , down1 , reset :std_logic;

component dff is
    Port ( 
           D : in STD_LOGIC;
           clk : in STD_LOGIC;
           sync_reset : in STD_LOGIC;
           Q : out STD_LOGIC);
           
end component;           

begin
   
   D1 : dff
        port map
              (
                D => A,
                clk => ref,
                sync_reset => reset,
                Q => up1
                );
                
                
   D2 : dff
                       port map
                             (
                               D => A,
                               clk => div,
                               sync_reset => reset,
                               Q => down1
                               );  
                               
                      reset <= up1 and down1;
                      UP <= up1;
                      DOWN <= down1;            
end Behavioral;



i have found this code for loop filter , but can't seem to understand it! its down here , can someone explain the logic ?

Code:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE IEEE.numeric_std.ALL;



ENTITY loop_filter IS
-- Declarations
 port (	CLK		: in std_logic;
			RESET	: in std_logic;
			C			: in signed(7 downto 0);
			D1		: out signed(11 downto 0);
			D2		: out signed(11 downto 0)
		);
END loop_filter  ;


ARCHITECTURE behavior OF loop_filter  IS

signal E : signed(11 downto 0);
signal dtemp : signed(11 downto 0);

begin
process(CLK, RESET)
begin
        if (RESET='1') then
            D1 <= (others => '0');
						D2 <= (others => '0');
						E <= (others => '0');
						dtemp <= (others => '0');
        elsif rising_edge(CLK) then
						dtemp <=  (C(7)&C(7)&C(7)&C&'0') + dtemp - E;
						E <= dtemp(11)&dtemp(11)&dtemp(11)&dtemp(11)&dtemp(11 downto 4);
						D1 <= dtemp; 
						D2 <= dtemp(11 downto 4)&"0000";
	  end if;
end process;
END behavior;

I have attached the block diagrams of first two blocks

**broken link removed****broken link removed** Screenshot (71).pngScreenshot (70).png
 

i have written a code with k=8 , but it doesnt seem to work . i used the following in the paper for the logic

The K counter consists of two independent counters, which are usually referred to as “UP-counter” and “DOWN-counter”. In reality, however, both counters are always counting upward. K is the modulus of both counters; that is, the contents of both counters are in a range from 0 . . . k-1. K can be controlled by the K modulus control input and is always an integer power of 2. The frequency of the clock signal (K clock) is by definition M times the center frequency f0 of the ADPLL, where M is typically 8, 16, 32 . . . The operation of the K counter is controlled by the DN/UP signal. If this signal is high, the “DN-counter” is active, while the contents of the UP-counter stay frozen. In the opposite case, the “UP-counter” counts up but the DN-counter stay frozen. Both counters recycle to 0 when the contents exceed K-1. The most significant bit of the “UP-counter” is used as a “carry” output, and the most significant bit of the “DN-counter” is used as a “borrow” output. Consequently, the carry is high when the content of the UP-counter is equal to or more than K/2. In analogy, the borrow output gets high when the content of the DN-counter is equal to or more than K/2. The positive-going edges of the carry and borrow signals are used to control the frequency of a digitally controlled oscillator.



here is my code
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;


-- the value of k is 8

   
entity updown is
    Port ( clk: in std_logic; -- clock input
           reset: in std_logic; -- reset input 
     up_down: in std_logic; -- up or down
           carry: out std_logic;
           borrow: out std_logic 
     );
end updown;

architecture Behavioral of updown is
signal counter_up: std_logic_vector(3 downto 0);
signal counter_down: std_logic_vector(3 downto 0);
begin
-- down counter
process(clk,reset)
begin
if(rising_edge(clk)) then
    if(reset='1'or counter_up="1000") then
         counter_up <= x"0";
         end if;
         
         if(reset='1'or counter_down="1000") then
         counter_down <= x"0";
    elsif(up_down='1') then
         counter_down <= counter_down + x"1"; -- count 
  else 
   counter_up <= counter_up + x"1"; -- count up
    end if;
 end if;
 if(counter_up > "100") then
 carry <='1';
 else
 carry <='0';
 end if;
 if(counter_down > "100") then
  borrow <='1';
  else
  borrow <='1';
  end if;
end process;


end Behavioral;


please suggest the correct logic for the kcounter loop filter
 

The posted "loop_filter" code has nothing to do with ADPLL kcounter function.

- - - Updated - - -

i have written a code with k=8 , but it doesnt seem to work
How did you check? Can you show the respective simulation results?
 

Screenshot (75).png

i simulated without a test bench, gave two clocks for clk(kclock) and up_down.. borrow is always high in the simulation, it needs to change , idk what went wrong
 

sir, reset given forced value 0..no changeScreenshot (76).png
 

At first sight, you have undriven reset input...

- - - Updated - - -

Better, but not good. Need to apply a reset pulse to get defined counter values at the start.

You really should learn how to read a simulation, e.g. what's the meaning of 'U' and 'X' values.
 

At first sight, you have undriven reset input...

- - - Updated - - -

Better, but not good. Need to apply a reset pulse to get defined counter values at the start.

You really should learn how to read a simulation, e.g. what's the meaning of 'U' and 'X' values.

yeah sir,Screenshot (77).png i gave a clock for reset and the carry seems to be working!:) , but the borrow is propbably faulty! is the logic for kcounter loop filter correct ?
 

but the borrow is probably faulty!
Yes, a simple typo

Code:
if(counter_down > "100") then
  borrow <='1';
  else
  borrow <='1';
  end if;
 

Yes, a simple typo

Code:
if(counter_down > "100") then
  borrow <='1';
  else
  borrow <='1';
  end if;

i guess the code is working fine now! (let me know if theres still something faulty :)Screenshot (78).png)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top