Looks like a good starting point for FPGA's, that first book you mention FPGA 101 I think I have that as an E-Book, I have a few E-Book resources about FPGA's, just haven't had a chance to look at them yet, if you want any let me know!
Trying to create some blink code and get a crazy error:
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity BlinkLed is
Port (
led0 : out STD_LOGIC;
clk : in STD_LOGIC
);
end BlinkLed;
architecture Behavioral of BlinkLed is
begin
synchronous_description : process(clk) is begin
if rising_edge(clk) then
led0 <= '1';
else
led0 <= '0';
end if;
end process;
end Behavioral;
My UCF file:
Code:
NET "clk" LOC = "P89" | IOSTANDARD = LVCMOS25 ;
NET "led" LOC = "P86" | IOSTANDARD = LVCMOS25 ;
My Error:
Code:
ERROR:Xst:827 - "C:/XWD/BlinkLED/BlinkLed.vhd" line 34: Signal led cannot be synthesized, bad synchronous description. The description style you are using to describe a synchronous element (register, memory, etc.) is not supported in the current software release.
i even tried without the "rising_edge(clk)" the long way... (change the variable names also)
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity BlinkLed is
Port ( LED_01 : out STD_LOGIC;
OSC_IN : in STD_LOGIC);
end BlinkLed;
architecture Behavioral of BlinkLed is
begin
process (OSC_IN)
begin
if (OSC_IN'event and OSC_IN = '1') then
LED_01 <= '1';
else
LED_01 <= '0';
end if;
end process;
end Behavioral;
But why i cant use it is a mystery... really. What its used for is also a mystery heh. i assume its to tell me if the clocked changed states and the next item checks if the state is 1...
For your simple example, you can get away without it -- in synthesis. But your simulation tools won't be able to simulate it correctly. Any sequential design you do that is more complicated, always use reset for initialization.
Here is a clean way to do it:
process(clk, reset) then
if(reset = '0')
...
elsif(rising_edge(clk)) then
....
end if;
Ok cool thanks, but just to let you know i have seen tons of designs without the use of it. But ill be sure to use it. I think i better understand it now also
heh yeah thats true. Ok to be sure i understand...
This code synthesizes ok
Code:
process(OSC_IN, RESET) is begin --Handle the inputs
if(RESET = '1') then --if RESET is high then set the LED to low (off in my case)
LED_01 <= '0';
elsif(rising_edge(OSC_IN)) then //If RESET is LOW and the RISING EDGE of clock is hit then turn LED on
LED_01 <= '1';
end if;
How would i turn off the LED off when the Clock is LOW then ?
do i simply add after that ?
Code:
--AFTER IT ADD
if(OSC_IN = '0') then
LED_01 <= '0';
end if;
or
Code:
--AFTER IT ADD
if(falling_edge(OSC_IN)) then
LED_01 <= '0';
end if;
The below seems to synthesize ok and simulates fine
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity BlinkLed is
Port ( LED_01 : out STD_LOGIC;
OSC_IN : in STD_LOGIC;
RESET : in STD_LOGIC);
end BlinkLed;
architecture Behavioral of BlinkLed is
begin
process(OSC_IN, RESET) is begin
if(RESET = '1') then
LED_01 <= '0';
elsif(rising_edge(OSC_IN)) then
LED_01 <= '1';
end if;
if(OSC_IN = '0') then
LED_01 <= '0';
end if;
end process;
end Behavioral;
Take a look at the simulation image... As you can see when RESET is low it allows the LED to be controlled and when high even with a clock still coming in the LED is held low...