Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

toggling led in FPGA spartan6 XC6SLX16

Status
Not open for further replies.

hannachifaten

Member level 2
Member level 2
Joined
May 1, 2013
Messages
44
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,769
Hello every one ,
i write an example of toggling led , the synthese is check but when i tried to see the simulation in the board that is not done :( ,
my card has up to 250 MHZ i convert this to get toggling led in every 500 ms , i show you the programme , any help please ,
i want to add a switch which i command the led but usually i didnt see the toggling led
entity main is
port (
clk:in std_logic;
--SW0:in std_logic;
led1:eek:ut std_logic;
led2:eek:ut std_logic
);

end main;

architecture Behavioral of main is
signal counter: std_logic_vector(32 downto 0) := (others =>'0');
signal bit1:std_logic :='0';
signal bit2:std_logic :='0';

begin
timer_process:process(clk)
begin
-- if SW0 ='1' THEN
if rising_edge(clk) then
if (counter(31 downto 0) = "1001010100000010111110010000000") then --count upto 250M
led1 <= bit1;
led2 <= bit2;
counter <= (others =>'0') ;
bit1 <= not bit1;
bit2 <= not bit2;
else
counter <= counter+1;
end if;
end if;
--ELSE
-- led1 <= '0';
-- led2 <= '0';
--end if ;
end process;
end Behavioral;


i have doubt to the value of counter is very large perhepes :sad: any suggestion please !!
 

did you simulate your code?
I'd investigate the possibility that your reset is active.
 

That synthesized? In your line where you check the counter vs. the constant value, the counter has 32 bits (31 downto 0), yet I keep counting 31 bits in the constant portion. I would have thought it would flag that as a length mis-match.

Why not use an integer counter to avoid that issue?
 
did you simulate your code?

Agreed. If you didn't simulate your code (and of course you didn't) then simulate it now. Saves you all sorts of trouble, especially when your projects get bigger. Simulating is cheap, debugging in hardware is far more costly in terms of time.
 

Agreed. If you didn't simulate your code (and of course you didn't) then simulate it now. Saves you all sorts of trouble, especially when your projects get bigger. Simulating is cheap, debugging in hardware is far more costly in terms of time.
thanks : so can i use modelsim to simulate my programme or using a test bench file for exemple, because i'm using only xilinx i check the code if it is ok i synthesise the code

- - - Updated - - -

That synthesized? In your line where you check the counter vs. the constant value, the counter has 32 bits (31 downto 0), yet I keep counting 31 bits in the constant portion. I would have thought it would flag that as a length mis-match.

Why not use an integer counter to avoid that issue?

when i synthesized that work but there are warnings for the lenth of the counter i don't know why it count 33 bits , so how i change it into intiger ( i use a integer vector ? )

- - - Updated - - -

yes hat synthesized but there are warnings about the lenght of counter it counts 33bits , so ifi change the type into integer ( i use an integer vector ? or how can i change it )
 

- You mention the clock is 'up to 250 MHz', so, to what is it set? If it's only, say, 10MHz you can wait an awful long time for it to blink ;)

- What about your pin assignments? Sure they are correct? Whap happens if you simply turn the LED on in your code? Does it on the board? If not, decent chance your assigments are off ;)
 

thanks : so can i use modelsim to simulate my programme or using a test bench file for exemple, because i'm using only xilinx i check the code if it is ok i synthesise the code

If you already have modelsim installed then you can use that for sim. But if not ... no worries. If you only have Xilinx ISE installed you can use ISim for your simulations. In fact, it will be the default simulation engine when you install a recent ISE version. Has been for years now.

You say you "check the code if it synthesizes okay". That is a good habit. :) But while it is a necessary requirement that it synthesizes it is not a sufficient requirement. Put another way: it's nice it synthesizes. after you have checked it synthesizes then you test it in a testbench to see if it actually does what you think it should be doing.
 

- You mention the clock is 'up to 250 MHz', so, to what is it set? If it's only, say, 10MHz you can wait an awful long time for it to blink ;)

- What about your pin assignments? Sure they are correct? Whap happens if you simply turn the LED on in your code? Does it on the board? If not, decent chance your assigments are off ;)


- What about your pin assignments? Sure they are correct? Whap happens if you simply turn the LED on in your code? Does it on the board? If not, decent chance your assigments are off ;)[/QUOTE]
i use the FPGA XC6SLX16 ? the clock is 250 MHZ , i would to toggling two leds every 500ms , i test that firstly without making a delay using a switch that is work but until i added the counter to make delay and adding the clock it does not work in card but synthesized :-( ; the assignment are correct
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top