element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
FPGA
  • Technologies
  • More
FPGA
Forum Elbert V2 - Spartan 3A FPGA Development Board
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join FPGA to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 4 replies
  • Answers 1 answer
  • Subscribers 559 subscribers
  • Views 2103 views
  • Users 0 members are here
  • frontpage
Related

Elbert V2 - Spartan 3A FPGA Development Board

terabyte21
terabyte21 over 10 years ago

Does anyone have this same model of card?


I need some help , because I 'm trying to implement a counter from 0 to 99. But so far it has not worked for me.


It is a sample code I found on the web.



library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity cotador is
  Port ( reloj : in std_logic;
  reset : in std_logic;
  habent : in std_logic;
  habsal : out std_logic;
  cuentamax: in std_logic_vector (3 downto 0);
  selec:in std_logic_vector (3 downto 0);
anodosut std_logic_vector (3 downto 0);
salida : out std_logic_vector (6 downto 0));

end cotador;

architecture Behavioral of cotador is
 signal clock:std_logic; 
 signal count:std_logic_vector (3 downto 0);
 begin

process(reloj)
  variable conta : integer range 0 to 50000000 :=0;
  begin
  if reloj = '1' and reloj'event then
  if conta =50000000 then
conta :=0;
clock <='1';
else
conta:=conta+1;
clock<='0';
end if;
end if;
 end process;  




  process (cuentamax,clock, reset)
  variable cuenta: std_logic_vector (3 downto 0):="0000";
  begin
  if reset = '1' then
  count<="0000";
  elsif clock='1' and clock'event then
  if habent='0' then 
  if count = cuentamax then
  count<="0000";
  else
  count<=count+1;
  end if;
  end if;
  end if;


   
   
  if count=cuentamax and habent = '0' and clock = '1' then
  habsal<='0';
  else
  habsal<='1';

end if;

  end process;

with count select
salida<="1111001" when "0001",
"0100100" when "0010",
"0110000" when "0011",
"0011001" when "0100",
"0010010" when "0101",
"0000010" when "0110",
"1111000" when "0111",
"0000000" when "1000",
"0010000" when "1001",
"1000000" when others;

anodos<=selec;

end Behavioral;

  • Sign in to reply
  • Cancel

Top Replies

  • michaelkellett
    michaelkellett over 10 years ago in reply to terabyte21 +2 verified
    Hello Pablo, You are starting out so it's time to get into good habits - don't use IEEE.STD_LOGIC_ARITH.ALL; but use NUMERIC_STD instead - there are very good reasons for this which you can check out on…
  • terabyte21
    terabyte21 over 10 years ago in reply to johnbeetem +1
    Thank you very much for your advice
  • johnbeetem
    0 johnbeetem over 10 years ago

    I don't have an Elbert V2 and I my FPGA expertise is primarily Verilog, but I'll try to make some general suggestions.

     

    First, numato.com has some tutorials for Elbert V2.  Look near the bottom of the Elbert V2 page and click on the Tutorials tab: http://numato.com/elbert-v2-spartan-3a-fpga-development-board.html

     

    I haven't looked at the tutorials myself, but maybe one provides a step-by-step guide to compiling a VHDL design and downloading it.  Getting your first FPGA design to download and work is difficult, so I recommend doing it first with a simple working design, preferably from a tutorial that's been tested.

     

    Second, from what I can tell of the example given my limited VHDL, it seems that it can only count up to 10.  process(reloj) begins some code to divide by 50 million, which I assume is dividing Elbert's clock oscillator down to 1 Hz so you can watch the counting.  process(cuentamax, clock, reset) begins code for a 4-bit counter that increments count from 0 up to (and I think including) cuentamax.  salida is a 7-bit vector that displays a 7-segment digit for count.

     

    There doesn't seem to be a main program that sets a value for cuentamax, or maybe you're supposed to input it from the DIP switch.

     

    You need a User Constraint File (UCF) to define the pinout, or you can use the GUI tool in the Xilinx ISE software.  Use the Elbert V2 schematic to see which pin numbers are connected to switches, LEDs, and the clock oscillator.

     

    If you're programming the FPGA using JTAG over USB, be sure you set the start-up clock to the JTAG clock in the options for bitstream generation.  That's an easy thing to miss.

     

    Hope this helps!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • terabyte21
    0 terabyte21 over 10 years ago in reply to johnbeetem

    Thank you very much for your advice

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michaelkellett
    0 michaelkellett over 10 years ago in reply to terabyte21

    Hello Pablo,

     

    You are starting out so it's time to get into good habits - don't use IEEE.STD_LOGIC_ARITH.ALL;   but use NUMERIC_STD instead - there are very good reasons for this which you can check out on the web.

    http://vhdlguru.blogspot.co.uk/2010/03/why-library-numericstd-is-preferred.html

    http://www.alteraforum.com/forum/showthread.php?t=20925

    There are many more references to be looked at if you like.

     

    John has explained some of the issues in the code - if cuentmax is input on pins nothing will happen unless it's set up. And as John has pointed out it will never count to 99.

    So - how have you tested it and what did you see.

    (There are other bad things in this design as well - clocking a process from the output of another process will often cause timing issues. Processes should ALWAYS have names - so we can refer to them easily !)

     

     

    And most importantly - how are simulating it.

    Simulation is the key to FPGA development - you will never get anything complex to work unless you learn how to do simulation.

     

    The Xilinx tools will include  a simulator.

     

     

    MK

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • terabyte21
    0 terabyte21 over 10 years ago in reply to michaelkellett

    Thank you MIchael  and Jhon. I changed the code, this works.

     

    library IEEE;
    use IEEE.STD_LOGIC_1164.ALL;
    use IEEE.NUMERIC_STD.ALL;
    
    -- Uncomment the following library declaration if instantiating
    -- any Xilinx primitives in this code.
    --library UNISIM;
    --use UNISIM.VComponents.all;
    
    entity numeros is
    port (
    relojito: in  std_logic;
    sel: out STD_LOGIC_VECTOR (2 downto 0);
    display: out STD_LOGIC_VECTOR (7 downto 0)
    );
    end numeros;
    
    architecture Behavioral of numeros is
    signal segundo:integer range 0 to 119999999;
    signal unidad: integer range 0 to 9;
    signal decenas: integer range 0 to 9;
    signal banderita: STD_LOGIC;
    signal numero: integer  range 0 to 9;
    signal msegundo: integer range 0 to 119999;
    
    begin
    
    process(unidad, decenas, relojito)
    
    begin
    if (rising_edge(relojito)) then
    if (segundo =  11999999) then
    segundo <=0;
    
    
    if (unidad =9) then
    unidad <=0;
    
    
    else
    unidad <= unidad +1;
    end if;
    if(unidad=9 ) then
    decenas <= decenas+1;
    end if;
    if( decenas=9)then
    unidad<=unidad+1;
    end if;
    if(decenas=9 and unidad= 9)then
    decenas<=0;
    end if;
    else
    segundo <= segundo+1;
    end if;
    
    end if;
    end process;
    
    process (relojito, unidad, decenas)
    
    begin
    if (rising_edge(relojito))then
    if (msegundo= 119999)then
    msegundo<= 0;
     banderita<= not(banderita);
    
    
    if( banderita = '0') then
    numero <= unidad;
    sel <="110";
    
    else
    numero <= decenas;
    sel <="101";
    
    
    end if;
    else
    msegundo <= msegundo + 1;
    end if;
    
    case numero is
    when 0=> display <="11000000";
    when 1=> display <= "11111001";
    when 2=> display <= "10100100";
    when 3=> display <= "10110000";
    when 4 => display <= "10011001";
    when 5 => display <= "10010010";
    when 6 => display <= "10000010";
    when 7 => display <= "11111000";
    when 8 => display <= "10000000";
    when 9 => display <= "10011000";
    when others => display <="11111111";
    
    end case;
    end if;
    end process;
    end Behavioral;

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube