VHDL CODE....Please Check....

Joined
Mar 30, 2010
Messages
1
Reaction score
0
Heya....i want to implement a 8 bit binary counter....will the following code work???I dont hav access to the s/w n so cant check myself....

library ieee;
use ieee.std_logic_1164.all;

entity counter is
port(CLK,RST:IN std_logic;
Q,QN:OUT std_logic_vector(7 downto 0));
end counter;

architecture arch of counter is
begin
process(CLK,RST)
begin
if(RST='0')
then Q<="00000000";
elsif (CLK='1' and CLK'event)
then Q=Q+;
end if;
end process;
QN<=not Q;
end arch;

RST is low enable and the counter is +ve edge triggered.....
 
Joined
Mar 10, 2008
Messages
348
Reaction score
0
Code:
library ieee;
use ieee.std_logic_1164.all;
[COLOR="Sienna"]use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;[/COLOR]

entity counter is
    port(CLK,RST:IN std_logic;
    Q,QN:OUT std_logic_vector(7 downto 0));
end counter;

architecture arch of counter is
    [COLOR="sienna"]signal Qtemp: std_logic_vector(7 downto 0);[/COLOR]
begin
    process(CLK,RST)
    begin
        if(RST='0')
            then Qtemp<="00000000";
            elsif (CLK='1' and CLK'event)
            then Qtemp=Qtemp+[COLOR="sienna"]1[/COLOR];
       end if;
     end process;
    [COLOR="sienna"]Q  <= Qtemp;[/COLOR]
    QN<=not Qtemp;
end arch;

This more likely to work - an alternative to Qtemp could be the INOUT attribute.
You need the extra libraries in order to perform the +1

your welcome
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Query related to division of 1.122 in mentioned code. 0
Multiplication VHDL 4
Help code VHDL 2
Array VHDL 3
code vhdl 1
2 JK Circuit in VHDL 0
erreur VHDL 3
pls help me ; vhdl; 0

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top