go!! galawin mo... ilipat mo na lalagyan! itabi mo sa mga panties mo! hehehe
yung CPLD ko din di ko pa nagagalaw, medyo marami pang ginagawa pero for sure gagamitin ko din yun btw, ano mas magandang pag-aralan muna? VHDL o Verilog?
//circuit that counts 0 to 7 with clear in verilogmodule cnt8(clk, clr, q);input clk, clr;output [2:0] q;reg [3:0] q;always @ (posedge clk) if (clr) q <= 0; else q <= q + 1; endmodule//end of cnt8 design//test bench for cnt8module tb();reg clk, clr;wire [2:0] q;cnt8 uut(clk, clr, q);initialbegin clk = 0; clr = 1; #30 clr = 0; #1000 $finish;end//40 ns clock generationalways #20 clk = !clk;endmodule
--circuit that counts 0 to 7 with clear in VHDLLIBRARY IEEE;USE IEEE.std_logic_1164.all;USE IEEE.std_logic_unsigned.all;ENTITY cnt8 IS PORT( clr, clk : IN std_logic; q : OUT std_logic_vector (2 downto 0)); END;ARCHITECTURE logic OF cnt8 ISSIGNAL tmp : std_logic_vector (2 downto 0);BEGIN count: PROCESS (clr, clk) BEGIN IF (clr = '1') THEN tmp <= "000"; ELSIF (clk'EVENT and clk = '1') THEN tmp <= tmp + 1; END IF; END PROCESS; q <= tmp;END logic;--end of cnt8 design--test bench for cnt8LIBRARY IEEE;USE IEEE.std_logic_1164.all;USE IEEE.std_logic_unsigned.all; ENTITY cnt8test ISEND;ARCHITECTURE testxxxx OF cnt8test ISSIGNAL clk : std_logic := '0';SIGNAL clr : std_logic := '1';SIGNAL q : std_logic_vector (2 downto 0) ;COMPONENT cnt8 PORT( clr, clk : IN std_logic; q : OUT std_logic_vector (2 downto 0));END COMPONENT; BEGINUUT: cnt8 PORT MAP (clr, clk, q);--40 ns clock generationPROCESS BEGIN clk <= '0'; wait for 20 ns; clk <= '1'; wait for 20 ns;END PROCESS;--clear generationPROCESS BEGIN wait for 30 ns; clr <= '0';END PROCESS;END;
ako din vhdl din ang ginamit ko sa last project ko sa fpga. Question, magkano ang cpld board sa e-gizmo tsaka pahingi ng link di ko kasi makita eh. thanks
http://www.e-gizmo.com/KIT/CPLD.htm
Below are examples of verilog and VHDL codes. These are equivalent codes for a circuit that counts 0 to 7 with synchronous clear.VerilogCode: [Select]//circuit that counts 0 to 7 with clear in verilogmodule cnt8(clk, clr, q);input clk, clr;output [2:0] q;reg [3:0] q;always @ (posedge clk) if (clr) q <= 0; else q <= q + 1; endmodule//end of cnt8 design//test bench for cnt8module tb();reg clk, clr;wire [2:0] q;cnt8 uut(clk, clr, q);initialbegin clk = 0; clr = 1; #30 clr = 0; #1000 $finish;end//40 ns clock generationalways #20 clk = !clk;endmoduleVHDL Code: [Select]--circuit that counts 0 to 7 with clear in VHDLLIBRARY IEEE;USE IEEE.std_logic_1164.all;USE IEEE.std_logic_unsigned.all;ENTITY cnt8 IS PORT( clr, clk : IN std_logic; q : OUT std_logic_vector (2 downto 0)); END;ARCHITECTURE logic OF cnt8 ISSIGNAL tmp : std_logic_vector (2 downto 0);BEGIN count: PROCESS (clr, clk) BEGIN IF (clr = '1') THEN tmp <= "000"; ELSIF (clk'EVENT and clk = '1') THEN tmp <= tmp + 1; END IF; END PROCESS; q <= tmp;END logic;--end of cnt8 design--test bench for cnt8LIBRARY IEEE;USE IEEE.std_logic_1164.all;USE IEEE.std_logic_unsigned.all; ENTITY cnt8test ISEND;ARCHITECTURE testxxxx OF cnt8test ISSIGNAL clk : std_logic := '0';SIGNAL clr : std_logic := '1';SIGNAL q : std_logic_vector (2 downto 0) ;COMPONENT cnt8 PORT( clr, clk : IN std_logic; q : OUT std_logic_vector (2 downto 0));END COMPONENT; BEGINUUT: cnt8 PORT MAP (clr, clk, q);--40 ns clock generationPROCESS BEGIN clk <= '0'; wait for 20 ns; clk <= '1'; wait for 20 ns;END PROCESS;--clear generationPROCESS BEGIN wait for 30 ns; clr <= '0';END PROCESS;END;
^^sis glutnix basic na basic pa lang ang mga nalalaman ko nakakahiya pa magshare antayin natin si marcelina at ckiana02 para sa mga bagay bagay na yan madami din akong gustong malaman tungkol sa test bench na yan
ENTITY cnt8 IS PORT( clr, clk : IN std_logic; q : OUT std_logic_vector (2 downto 0)); END;
BEGINUUT: cnt8 PORT MAP (clr, clk, q);--40 ns clock generationPROCESS BEGIN clk <= '0'; wait for 20 ns; clk <= '1'; wait for 20 ns;END PROCESS;--clear generationPROCESS BEGIN wait for 30 ns; clr <= '0';END PROCESS;END;
wow thanks... at isa pang tanong, STD_LOGIC ba kalimitang ginagamit? kasi may natesting ko, BIT yata yun iirc, ayaw magcompile ng Test Bench, pinalitan ko ng STD_LOGIC gumana na...
USE IEEE.std_logic_1164.all;USE IEEE.std_logic_unsigned.all;
------------------------------------------------------------------- -- logic state system (unresolved) ------------------------------------------------------------------- TYPE std_ulogic IS ( 'U', -- Uninitialized 'X', -- Forcing Unknown '0', -- Forcing 0 '1', -- Forcing 1 'Z', -- High Impedance 'W', -- Weak Unknown 'L', -- Weak 0 'H', -- Weak 1 '-' -- Don't care ); ------------------------------------------------------------------- -- unconstrained array of std_ulogic for use with the resolution function ------------------------------------------------------------------- TYPE std_ulogic_vector IS ARRAY ( NATURAL RANGE <> ) OF std_ulogic; ------------------------------------------------------------------- -- resolution function ------------------------------------------------------------------- FUNCTION resolved ( s : std_ulogic_vector ) RETURN std_ulogic; ------------------------------------------------------------------- -- *** industry standard logic type *** ------------------------------------------------------------------- SUBTYPE std_logic IS resolved std_ulogic;
--this is a comment :-)---------My_Andlibrary ieee;use ieee.std_logic_1164.all;entity My_And is port(A, B : in std_logic; ANDED : out std_logic);end;architecture BEHAVIOR of My_And is ANDED <= A and B; end;----------end of the circuit My_And------------start of testbenchlibrary ieee;use ieee.std_logic_1164.all;Entity testMy_And Isend;Architecture test Of testMy_And IsSignal Ax : std_logic := '0'; --initial value of AxSignal Bx : std_logic := '0'; --initial value of BxSignal ANDout : std_logic;Component My_And --template of My_And described above Port(A, B : in std_logic; ANDED : OUT std_logic); end component;beginUUT: My_And Port Map (Ax, Bx, ANDout); --Ax maps to A, Bx maps to Bx and ANDout maps to ANDEDProcess begin wait for 30 ns; -- so Ax = 0, Bx = 0 for 30 ns Ax <= '0'; Bx <= '1'; wait for 30 ns; -- so Ax = 0, Bx = 1 for 30 ns Ax <= '1'; Bx <= '0'; wait for 30 ns; -- so Ax = 1, Bx = 0 for 30 ns Ax <= '1'; Bx <= '1'; wait for 30 ns; -- so Ax = 1, Bx = 1 for 30 ns Ax <= '0'; Bx <= '0'; --will go back to the start of the processend process;end;