SlideShare una empresa de Scribd logo
1 de 10
FPGA
Counter Seven Segment


              Created by
              Akhmad Hendriawan
              hendri@eepis-its.edu
You are free:
to Share — to copy, distribute and transmit the work
Under the following conditions:
Attribution — You must attribute the work in the manner specified by the author
or licensor (but not in any way that suggests that they endorse you or your use
of the work).
Noncommercial — You may not use this work for commercial purposes.
No Derivative Works — You may not alter, transform, or build upon this work.
Background




I try implement counter seven segmen in FPGA
●
Problem and solution

Problem:
First I don't know how to combine counter and decoder in HDL top level.
Usualy for my previous project , I do combining design with TOP level
schematic.

Solution:
I learn about portmap syntax for wiring component in HDL top level
My Design
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity counter is
  Port ( clk_i : in STD_LOGIC;
                                                              Counter.vhd
        systick : out STD_LOGIC;
        counter_o : out STD_LOGIC_VECTOR (3 downto 0));
end counter;

architecture Behavioral of counter is
signal psc: std_logic_vector(23 downto 0) :=(others=>'0');
signal clk_r: std_logic_vector(3 downto 0) :=(others=>'0');
signal tick: std_logic :='0';
begin
process (clk_i)
begin
  if rising_edge(clk_i) then
            if psc<= "11111111111111111111111" then
                    psc<= psc+1;
                  else
                    psc<= (others=>'0');
                          tick <= tick xor '1';
                          if clk_r<9 then
                             clk_r <= clk_r +1;
                          else
                              clk_r<=(others=>'0');
                    end if;
                  end if;
          end if;
end process;
counter_o<=clk_r;
systick <= tick;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity decoder is
  Port ( clk : in STD_LOGIC;
        bcd : in STD_LOGIC_VECTOR (3 downto 0);
        segment7 : out STD_LOGIC_VECTOR (6 downto 0));
end decoder;                                                     Decoder
architecture Behavioral of decoder is

begin
process (clk,bcd)
begin
  if (clk'event and clk='1') then
           case bcd is
                  --common anoda       gfedcba
       when "0000"=> segment7 <="0000001"; -- '0'
       when "0001"=> segment7 <="1001111"; -- '1'
                  when "0010"=> segment7 <="0010010";   -- '2'
                  when "0011"=> segment7 <="0000110";   -- '3'
                  when "0100"=> segment7 <="1001100";   -- '4'
                  when "0101"=> segment7 <="0100100";   -- '5'
                  when "0110"=> segment7 <="0100000";   -- '6'
                  when "0111"=> segment7 <="0001111";   -- '7'
                  when "1000"=> segment7 <="0000000";   -- '8'
                  when "1001"=> segment7 <="0000100";   -- '9'
       when others=> segment7 <="1111111";
    end case;
         end if;
end process;

end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity systemSeg is
  Port ( clk : in STD_LOGIC;
        systick : out STD_LOGIC;
        counter_out : out STD_LOGIC_VECTOR (6 downto 0));
end systemSeg;

architecture Behavioral of systemSeg is

        COMPONENT counter
        PORT(
              clk_i : IN std_logic;
              systick : OUT std_logic;
              counter_o : OUT std_logic_vector(3 downto 0)
              );
        END COMPONENT;

        COMPONENT decoder
        PORT(
                clk : IN std_logic;
                bcd : IN std_logic_vector(3 downto 0);
                segment7 : OUT std_logic_vector(6 downto 0)
                );
        END COMPONENT;
        signal cable : std_logic_vector(3 downto 0);
begin

        Inst_counter: counter PORT MAP(
               clk_i => clk,
               systick => systick,
               counter_o => cable
        );

        Inst_decoder: decoder PORT MAP(
               clk => clk,
               bcd => cable ,
               segment7 => counter_out
        );

end Behavioral;
Resume / Conclusion


●Portmap usefull to wiring between component in
Top level HDL.
●Design must be synchronous with clock

●Prescaller output from clock source need clock

buffer for to being clock output to another
component
Resume / Conclusion


●Portmap usefull to wiring between component in
Top level HDL.
●Design must be synchronous with clock

●Prescaller output from clock source need clock

buffer for to being clock output to another
component

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Programs of VHDL
Programs of VHDLPrograms of VHDL
Programs of VHDL
 
Lecture 2 verilog
Lecture 2   verilogLecture 2   verilog
Lecture 2 verilog
 
Session1
Session1Session1
Session1
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
 
Switch level modeling
Switch level modelingSwitch level modeling
Switch level modeling
 
Digital system design lab manual
Digital system design lab manualDigital system design lab manual
Digital system design lab manual
 
Verilog 語法教學
Verilog 語法教學 Verilog 語法教學
Verilog 語法教學
 
Practical file
Practical filePractical file
Practical file
 
Embedded system design psoc lab report
Embedded system design psoc lab reportEmbedded system design psoc lab report
Embedded system design psoc lab report
 
REPORT
REPORTREPORT
REPORT
 
DHow2 - L6 VHDL
DHow2 - L6 VHDLDHow2 - L6 VHDL
DHow2 - L6 VHDL
 
Crash course in verilog
Crash course in verilogCrash course in verilog
Crash course in verilog
 
Delays in verilog
Delays in verilogDelays in verilog
Delays in verilog
 
8 bit single cycle processor
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processor
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhts
 
برمجة الأردوينو - اليوم الثاني
برمجة الأردوينو - اليوم الثانيبرمجة الأردوينو - اليوم الثاني
برمجة الأردوينو - اليوم الثاني
 
Diseño de sistemas
Diseño de sistemasDiseño de sistemas
Diseño de sistemas
 
ECAD lab manual
ECAD lab manualECAD lab manual
ECAD lab manual
 
Verilog lab manual (ECAD and VLSI Lab)
Verilog lab manual (ECAD and VLSI Lab)Verilog lab manual (ECAD and VLSI Lab)
Verilog lab manual (ECAD and VLSI Lab)
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manual
 

Similar a Fpga creating counter with internal clock

Digital to analog -Sqaure waveform generator in VHDL
Digital to analog -Sqaure waveform generator in VHDLDigital to analog -Sqaure waveform generator in VHDL
Digital to analog -Sqaure waveform generator in VHDLOmkar Rane
 
Pipeline stalling in vhdl
Pipeline stalling in vhdlPipeline stalling in vhdl
Pipeline stalling in vhdlSai Malleswar
 
Data Acquisition
Data AcquisitionData Acquisition
Data Acquisitionazhar557
 
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)Shinya Takamaeda-Y
 
hdl timer ppt.pptx
hdl timer ppt.pptxhdl timer ppt.pptx
hdl timer ppt.pptxChethaSp
 
VHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESVHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESkarthik kadava
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorDaniel Roggen
 
Digital logic circuit
Digital logic circuit Digital logic circuit
Digital logic circuit Prabhu R
 
Writing more complex models (continued)
Writing more complex models (continued)Writing more complex models (continued)
Writing more complex models (continued)Mohamed Samy
 

Similar a Fpga creating counter with internal clock (20)

Uart
UartUart
Uart
 
Reporte vhdl9
Reporte vhdl9Reporte vhdl9
Reporte vhdl9
 
vhdll.docx
vhdll.docxvhdll.docx
vhdll.docx
 
Digital to analog -Sqaure waveform generator in VHDL
Digital to analog -Sqaure waveform generator in VHDLDigital to analog -Sqaure waveform generator in VHDL
Digital to analog -Sqaure waveform generator in VHDL
 
Tdm to vo ip 2
Tdm to vo ip 2Tdm to vo ip 2
Tdm to vo ip 2
 
Pipeline stalling in vhdl
Pipeline stalling in vhdlPipeline stalling in vhdl
Pipeline stalling in vhdl
 
Reporte vhd10
Reporte vhd10Reporte vhd10
Reporte vhd10
 
Vhdl programs
Vhdl programsVhdl programs
Vhdl programs
 
Data Acquisition
Data AcquisitionData Acquisition
Data Acquisition
 
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
 
hdl timer ppt.pptx
hdl timer ppt.pptxhdl timer ppt.pptx
hdl timer ppt.pptx
 
VHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESVHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLES
 
VLSI lab manual
VLSI lab manualVLSI lab manual
VLSI lab manual
 
Timer ppt
Timer pptTimer ppt
Timer ppt
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational Processor
 
Digital logic circuit
Digital logic circuit Digital logic circuit
Digital logic circuit
 
Writing more complex models (continued)
Writing more complex models (continued)Writing more complex models (continued)
Writing more complex models (continued)
 
VHDL Programs
VHDL ProgramsVHDL Programs
VHDL Programs
 
chapter 4
chapter 4chapter 4
chapter 4
 
گزارش کار
گزارش کارگزارش کار
گزارش کار
 

Más de Politeknik Elektronika Negeri Surabaya (6)

Memulai AVR WINAVR
Memulai AVR WINAVRMemulai AVR WINAVR
Memulai AVR WINAVR
 
Interfacing to lcd with arduino
Interfacing  to lcd with arduinoInterfacing  to lcd with arduino
Interfacing to lcd with arduino
 
Modul2 setting xctu
Modul2 setting xctuModul2 setting xctu
Modul2 setting xctu
 
My Linux
My LinuxMy Linux
My Linux
 
Embedded lcd
Embedded lcdEmbedded lcd
Embedded lcd
 
winavr tutorial
winavr tutorial winavr tutorial
winavr tutorial
 

Fpga creating counter with internal clock

  • 1. FPGA Counter Seven Segment Created by Akhmad Hendriawan hendri@eepis-its.edu
  • 2. You are free: to Share — to copy, distribute and transmit the work Under the following conditions: Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Noncommercial — You may not use this work for commercial purposes. No Derivative Works — You may not alter, transform, or build upon this work.
  • 3. Background I try implement counter seven segmen in FPGA ●
  • 4. Problem and solution Problem: First I don't know how to combine counter and decoder in HDL top level. Usualy for my previous project , I do combining design with TOP level schematic. Solution: I learn about portmap syntax for wiring component in HDL top level
  • 6. library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity counter is Port ( clk_i : in STD_LOGIC; Counter.vhd systick : out STD_LOGIC; counter_o : out STD_LOGIC_VECTOR (3 downto 0)); end counter; architecture Behavioral of counter is signal psc: std_logic_vector(23 downto 0) :=(others=>'0'); signal clk_r: std_logic_vector(3 downto 0) :=(others=>'0'); signal tick: std_logic :='0'; begin process (clk_i) begin if rising_edge(clk_i) then if psc<= "11111111111111111111111" then psc<= psc+1; else psc<= (others=>'0'); tick <= tick xor '1'; if clk_r<9 then clk_r <= clk_r +1; else clk_r<=(others=>'0'); end if; end if; end if; end process; counter_o<=clk_r; systick <= tick; end Behavioral;
  • 7. library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity decoder is Port ( clk : in STD_LOGIC; bcd : in STD_LOGIC_VECTOR (3 downto 0); segment7 : out STD_LOGIC_VECTOR (6 downto 0)); end decoder; Decoder architecture Behavioral of decoder is begin process (clk,bcd) begin if (clk'event and clk='1') then case bcd is --common anoda gfedcba when "0000"=> segment7 <="0000001"; -- '0' when "0001"=> segment7 <="1001111"; -- '1' when "0010"=> segment7 <="0010010"; -- '2' when "0011"=> segment7 <="0000110"; -- '3' when "0100"=> segment7 <="1001100"; -- '4' when "0101"=> segment7 <="0100100"; -- '5' when "0110"=> segment7 <="0100000"; -- '6' when "0111"=> segment7 <="0001111"; -- '7' when "1000"=> segment7 <="0000000"; -- '8' when "1001"=> segment7 <="0000100"; -- '9' when others=> segment7 <="1111111"; end case; end if; end process; end Behavioral;
  • 8. library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity systemSeg is Port ( clk : in STD_LOGIC; systick : out STD_LOGIC; counter_out : out STD_LOGIC_VECTOR (6 downto 0)); end systemSeg; architecture Behavioral of systemSeg is COMPONENT counter PORT( clk_i : IN std_logic; systick : OUT std_logic; counter_o : OUT std_logic_vector(3 downto 0) ); END COMPONENT; COMPONENT decoder PORT( clk : IN std_logic; bcd : IN std_logic_vector(3 downto 0); segment7 : OUT std_logic_vector(6 downto 0) ); END COMPONENT; signal cable : std_logic_vector(3 downto 0); begin Inst_counter: counter PORT MAP( clk_i => clk, systick => systick, counter_o => cable ); Inst_decoder: decoder PORT MAP( clk => clk, bcd => cable , segment7 => counter_out ); end Behavioral;
  • 9. Resume / Conclusion ●Portmap usefull to wiring between component in Top level HDL. ●Design must be synchronous with clock ●Prescaller output from clock source need clock buffer for to being clock output to another component
  • 10. Resume / Conclusion ●Portmap usefull to wiring between component in Top level HDL. ●Design must be synchronous with clock ●Prescaller output from clock source need clock buffer for to being clock output to another component