library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; use IEEE.std_logic_unsigned.all; -- Make sure to define the behaviour of each GPIO pin used -- as either input or output which operates under standard logic entity demo4 is port( clk: in std_logic; gpio0: out std_logic; -- seg a gpio1: out std_logic; -- seg b gpio2: out std_logic; -- seg c gpio3: out std_logic; -- seg d gpio4: out std_logic; -- seg e gpio5: out std_logic; -- seg f gpio6: out std_logic; -- seg g detect: in std_logic -- resolved signal from motion sensor ); end demo4; architecture implementation of demo4 is signal numbers: integer range 0 to 9:= 0; signal count: integer:= 1; signal clock: std_logic:= '0'; begin -- To define your own clock parameters, you can either write code for it yourself -- or you can refer back to the clock mega-function in 'my first fpga' -- in case you're using block models process(clk) begin if(clk'event and clk='1') then count <= count+1; if(count = 25000) then clock <= not clock; count <=1; end if; end if; end process; -- Always make sure to close all loops and also make sure your sensitivity lists -- work logically process (clock) begin if (clock'event and clock='1') then if (detect = '0') then numbers <= numbers+ 1; if(numbers = 9) then numbers <=0; end if; elsif (detect = '1')then numbers <= numbers; end if; end if; end process; -- Always be aware of what logic value triggers what response -- For this example, the leds' of the 7-seg have a common annode (same structure as the leds on the board) -- Hence to light the leds to produce the desired response, the signal that was passed -- to them was LOW or 0, thereby acting as the required GND. -- This logic dictates the led logic assignments given below process(numbers) -- displays numbers begin if numbers = 0 then gpio0 <= '0'; gpio1 <= '0'; gpio2 <= '0'; gpio3 <= '0'; gpio4 <= '0'; gpio5 <= '0'; gpio6 <= '1'; elsif numbers = 1 then gpio0 <= '1'; gpio1 <= '0'; gpio2 <= '0'; gpio3 <= '1'; gpio4 <= '1'; gpio5 <= '1'; gpio6 <= '1'; elsif numbers = 2 then gpio0 <= '0'; gpio1 <= '0'; gpio2 <= '1'; gpio3 <= '0'; gpio4 <= '0'; gpio5 <= '1'; gpio6 <= '0'; elsif numbers = 3 then gpio0 <= '0'; gpio1 <= '0'; gpio2 <= '0'; gpio3 <= '0'; gpio4 <= '1'; gpio5 <= '1'; gpio6 <= '0'; elsif numbers = 4 then gpio0 <= '1'; gpio1 <= '0'; gpio2 <= '0'; gpio3 <= '1'; gpio4 <= '1'; gpio5 <= '0'; gpio6 <= '0'; elsif numbers = 5 then gpio0 <= '0'; gpio1 <= '1'; gpio2 <= '0'; gpio3 <= '0'; gpio4 <= '1'; gpio5 <= '0'; gpio6 <= '0'; elsif numbers = 6 then gpio0 <= '0'; gpio1 <= '1'; gpio2 <= '0'; gpio3 <= '0'; gpio4 <= '0'; gpio5 <= '0'; gpio6 <= '0'; elsif numbers = 7 then gpio0 <= '0'; gpio1 <= '0'; gpio2 <= '0'; gpio3 <= '1'; gpio4 <= '1'; gpio5 <= '1'; gpio6 <= '1'; elsif numbers = 8 then gpio0 <= '0'; gpio1 <= '0'; gpio2 <= '0'; gpio3 <= '0'; gpio4 <= '0'; gpio5 <= '0'; gpio6 <= '0'; elsif numbers = 9 then gpio0 <= '0'; gpio1 <= '0'; gpio2 <= '0'; gpio3 <= '0'; gpio4 <= '1'; gpio5 <= '0'; gpio6 <= '0'; end if; end process; end implementation;