vlsi_freak
Full Member level 2
vhdl frequency divider
Hi.
I am trying to divide a clock by 2, and have the VHDL code is given below.
Now the clock here is divided by 4,,OOOppsss.
How can i write a VHDL code to divide the frequency by 2.
Thanks.
entity freq_div is
port (
clk, rst, d : inout std_logic;
q, qbar : inout std_logic
);
end freq_div;
architecture freq_div_a of freq_div is
begin
process(clk, rst)
begin
if (clk'event and clk='1') then
if rst ='1' then
q <= '0';
qbar <= '1';
d <= '0';
else
q <= d;
qbar <= not d;
d <= qbar;
end if;
end if;
end process;
end freq_div_a;
Please share your ideas.
Thanks
Hi.
I am trying to divide a clock by 2, and have the VHDL code is given below.
Now the clock here is divided by 4,,OOOppsss.
How can i write a VHDL code to divide the frequency by 2.
Thanks.
entity freq_div is
port (
clk, rst, d : inout std_logic;
q, qbar : inout std_logic
);
end freq_div;
architecture freq_div_a of freq_div is
begin
process(clk, rst)
begin
if (clk'event and clk='1') then
if rst ='1' then
q <= '0';
qbar <= '1';
d <= '0';
else
q <= d;
qbar <= not d;
d <= qbar;
end if;
end if;
end process;
end freq_div_a;
Please share your ideas.
Thanks