vlsibank

Log in or Sign up.
Main EDA Embedded Systems ASIC FPGA VHDL Verilog CMOS Semiconductors DSP Mixed Signal Architecture Miscellaneous

<-- Previous Next -- > TOPIC: divide by n counter vhdl code
Posted by: vhdllearner     4/27/2009 7:55:57 AM     Category: VHDL
Questions posted: 1         Comments Posted: 0
Hello
I want to design a divide by n counter, where n is changing in different differnet cases, between 2 to 16, can anybody will help me by giving vhdl code for the same.

Regards

Posted by: jrrahul.pand     7/29/2010 9:21:49 AM
Comments Posted:1       

i want to write a code which has 50mhz input but o/p will be below 16hz, how can i implement it ? can any one help me out?


Posted by: $---jay---$     5/6/2009 3:33:29 AM
Comments Posted:100       Questions Posted:1

hope the following code will help u out,

************************************************************************

library ieee ;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

----------------------------------------------------

entity counter is

generic(n: natural :=2);
port( clock: in std_logic;
clear: in std_logic;
count: in std_logic;
Q: out std_logic_vector(n-1 downto 0)
);
end counter;

----------------------------------------------------

architecture behv of counter is  

   signal Pre_Q: std_logic_vector(n-1 downto 0);

begin

   -- behavior describe the counter

   process(clock, count, clear)
   begin
if clear = '1' then
   Pre_Q <= Pre_Q - Pre_Q;
elsif (clock='1' and clock'event) then
   if count = '1' then
Pre_Q <= Pre_Q + 1;
   end if;
end if;
   end process;

   -- concurrent assignment statement
   Q <= Pre_Q;

end behv;

-----------------------------------------------------




You have to be logged in to be able to post a comment. To login click here. First time? Sign up. It just takes a few minutes to sign up.

Login to access the site

  Username:
  Password:
   Signup Forgot Password?    

Users with most replies

   User
 No. of Replies
100
86
77
76
70
66
61
57
54