library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity delayed is Port ( clock : in STD_LOGIC; LED : out STD_LOGIC);end delayed;architecture Behavioral of delayed isbegin process(clock) variable clockDelay : integer range 0 to 10000 := 0; --tsamba lang yung range begin if clock'event and clock = '1' then clockDelay := clockDelay + 1; --increment the delay if clockDelay = 0 then LED <= '1'; elsif clockDelay = 5000 then LED <= '0'; end if; end if; end process; end Behavioral;
ano'ng advantage(s) ng CPLD over sa microcontroller(e.g. PIC) ? walang parallel port ang pc ko
nice ate marce!!!ipon muna ako para makabili,yung program po VHDL based?parang PASCAL language,anu anu po kaya pwedeng gawin sa kit na ito?
hmmmmmmm.. madami!!! hhehehcontrollers, kahit ano! namention ko nga earlier, pwede mong maemulate ang kahit anong interfacing protocols (UART, I2C, SpI, etc...)
-- DELAY CODES ---- set to 2Hz --library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity delay is Port ( clock_osc : in STD_LOGIC; clock_out : out STD_LOGIC);end delay;architecture Behavioral of delay isbegin process(clock_osc) variable counter: integer range 0 to 32768 :=0; --1sec = 32768 cycles --32768/4 = 8192 = 4Hz --32768/2 = 16384 = 2Hz begin if clock_osc ='1' and clock_osc'event then counter := counter + 1; if counter = 0 then clock_out <= '1'; elsif counter = 16384 then clock_out <= '0'; end if; end if; end process; end Behavioral;------------------------------------------------------------- COUNTER CODE ---- increments each tick of the clock ---- outputs a 4bit counter, that is from 0x00 - 0x0F --library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity counter is Port ( clock : in STD_LOGIC; count : out STD_LOGIC_VECTOR (3 downto 0));end counter;architecture Behavioral of counter issignal counter : std_logic_vector (3 downto 0);begin process (clock) begin if clock='1' and clock'event then if counter = "1111" then counter <= "0000"; else counter <= counter + 1; end if; end if; end process;count <= counter;end Behavioral;-------------------------------------------------------------- CONVERTER CODE ---- converts the output from counter [3:0] to LED output[6:0]library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity converter is Port ( count_in : in STD_LOGIC_VECTOR (3 downto 0); LED : out STD_LOGIC_VECTOR (6 downto 0));end converter;architecture Behavioral of converter isbegin with count_in select -- abcdefg LED <= "0110000" when "0001", --1 "1101101" when "0010", --2 "1111001" when "0011", --3 "0110011" when "0100", --4 "1011011" when "0101", --5 "1011111" when "0110", --6 "1110000" when "0111", --7 "1111111" when "1000", --8 "1111011" when "1001", --9 "1110111" when "1010", --A "0011111" when "1011", --b "1001110" when "1100", --C "0111101" when "1101", --d "1001111" when "1110", --E "1000111" when "1111", --F "1111110" when others; --0 end Behavioral;------------------------------------------------------------- TOP LEVEL VHDL DESGIN ---- uses port mapping to connect the 3 modules...library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity top is Port ( clock_32k : in STD_LOGIC; LED_out : out STD_LOGIC_VECTOR (6 downto 0));end top;architecture Behavioral of top iscomponent delay Port ( clock_osc : in STD_LOGIC; clock_out : out STD_LOGIC);end component;component counter Port ( clock : in STD_LOGIC; count : out STD_LOGIC_VECTOR (3 downto 0));end component;component converter Port ( count_in : in STD_LOGIC_VECTOR (3 downto 0); LED : out STD_LOGIC_VECTOR (6 downto 0));end component;signal clock_delay : std_logic;signal count_counter : std_logic_vector (3 downto 0);beginU1 : delay port map ( clock_osc => clock_32k, clock_out => clock_delay );U2 : counter port map ( clock => clock_delay, count => count_counter );U3 : converter port map ( count_in => count_counter, LED => LED_out ); end Behavioral;
^ logic design 1 and 2 and computer architecture subject lang pwede. Mas relevant ito lalo na sa Comp. engg students
btw, sis marce VHDL ba yung code or verilog?
agree. maganda 'to sa mga simple ALU design or directly implementing the SAP-1 and SAP-2 computer. mas may feel ka sa tinuturo.
dami niyo na pala experience dito sis marce.