electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

Special counter: set&reset triggered by rising edge of p


Post new topic  Reply to topic    EDAboard.com Forum Index -> PLD, SPLD, GAL, CPLD, FPGA Design -> Special counter: set&reset triggered by rising edge of p
Author Message
Danielye



Joined: 10 Dec 2003
Posts: 29


Post02 Dec 2004 2:17   

Special counter: set&reset triggered by rising edge of p


Could this counter can be implemented?

This counter has three input, reset (clear),set(stop the counter),clock,
I want all these inputs can triggered the counter by rising edge.
How to implement this logic? Could someone kindly provide the VHDL code?

Thanks a lot!
Back to top
Google
AdSense
Google Adsense




Post02 Dec 2004 2:17   

Ads




Back to top
Black Jack



Joined: 02 Dec 2003
Posts: 221
Helped: 11
Location: UKRAINE


Post02 Dec 2004 13:09   

Re: Special counter: set&reset triggered by rising edge


Danielye wrote:
Could this counter can be implemented?

This counter has three input, reset (clear),set(stop the counter),clock,
I want all these inputs can triggered the counter by rising edge.
How to implement this logic? Could someone kindly provide the VHDL code?

Thanks a lot!


DDF with Synchronous Preset

Code:

library IEEE;
use IEEE.std_logic_1164.all;

entity act_dff_sync_pre is
port (data, clk, preset   : in std_logic;
      q                  : out std_logic);
end act_dff_sync_pre;

architecture behave of act_dff_sync_pre is
begin
process (clk)
begin
   if (clk'event and clk = '1') then
      if (preset = '0') then
         q <= '1';
      else
         q <= data;
      end if;
   end if;
end process;
end behave;


DDF with Synchronous Reset
Code:

library IEEE;
use IEEE.std_logic_1164.all;

entity act_dff_sync_rst is
port (data, clk, reset   : in std_logic;
      q                  : out std_logic);
end act_dff_sync_rst;

architecture behave of act_dff_sync_rst is
begin
process (clk)
begin
   if (clk'event and clk = '1') then
      if (reset = '0') then
         q <= '0';
      else
         q <= data;
      end if;
    end if;
end process;
end behave;
Back to top
Black Jack



Joined: 02 Dec 2003
Posts: 221
Helped: 11
Location: UKRAINE


Post02 Dec 2004 13:18   

Re: Special counter: set&reset triggered by rising edge


8-bit rising edge up counter with synch. reset, preset
Code:

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;

entity counter is
   port
   (
      clk, set, rst   : in std_logic;
      count         : out std_logic_vector (7 downto 0)
   );
end counter;

architecture behave of counter is
   signal   cnt:   std_logic_vector (7 downto 0);
begin
   process (clk, cnt, rst, set)
      begin
      
         if (clk'event and clk = '1') then
            if (rst = '0') then
               cnt <= (others => '0');
            elsif (set = '0') then
               cnt <= (others => '1');
            else
               cnt <= cnt + '1';
            end if;
         end if;
   end process;
         count <= cnt;
end behave;
Back to top
Git



Joined: 12 Dec 2001
Posts: 1118
Helped: 1
Location: Torino


Post02 Dec 2004 13:36   

Re: Special counter: set&reset triggered by rising edge


You could use a single JK flip flop to do that. Just drag one into a schematic and see what code it generates for an idea of how to implement it in VHDL.
Code:

architecture Behavioral of fjkc is
  begin
   process (C, CLR)
     begin
     if (CLR=’1’) then
       Q <= ’0’;
     elsif (C’event and C=’1’) then
       if (J=’0’) then
         if (K=’1’) then
           Q <= ’0’;
         end if;
       else
         if (K=’0’) then
           Q <= ’1’;
         else
           Q <= not Q;
         end if;
       end if;
     end if;
   end process;
end Behavioral


Git
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> PLD, SPLD, GAL, CPLD, FPGA Design -> Special counter: set&reset triggered by rising edge of p
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
Counter with asynchronous edge-triggered reset in VHDL (2)
edge triggered and level triggered interrputs (2)
to detect clock's rising edge and falling edge (3)
Rising edge of clock... (2)
perceiving rising or falling edge (8)
Two rising edge in one process (5)
Rising Edge Detection of digital signal (9)
simultaneous use of rising and falling edge (15)
FPGA Logic Help Rising' Edge detection (4)
sample data at rising/falling edge of clock? (1)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS