Beruflich Dokumente
Kultur Dokumente
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity DivFrec is
port (
clk : in std_logic;
clk1 : out std_logic
);
end DivFrec;
begin
divisor:process(clk)
variable temp: integer range 0 to 100000000 :=0; -- por el oscilador de 100 MHz
begin
end Behavioral;
RAM
entity ram is
Port (
data_in : in STD_LOGIC_VECTOR (3 downto 0);--conectado a A
data_out : out STD_LOGIC_VECTOR (3 downto 0);
addr : in STD_LOGIC_VECTOR (3 downto 0);--conectado a B
wr_ena : in STD_LOGIC;
clk : in STD_LOGIC
);
end ram;
ROM
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity rom is
Port (
addr : in std_logic_vector(3 downto 0);
data : out std_logic_vector(3 downto 0)
);
end rom;
begin
data <= memory(conv_integer(addr));
end Behavioral;
FSM
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity fsm is
Port (
x : in STD_LOGIC;
z_out : out STD_LOGIC_VECTOR (3 downto 0);
z : out std_logic_vector(1 downto 0);
rst : in std_logic;
clk_fsm : in std_logic
);
end fsm;
begin
process (rst,clk_fsm)
begin
if(rst='1') then
pr_estado<=std0;
elsif (clk_fsm'event and clk_fsm='1') then
pr_estado<=nx_estado;
end if;
end process;
process (x,pr_estado)
begin
case pr_estado is
when std0 =>
z_out<="0000";
z<="00";
if (x='0') then
nx_estado<=std0;
else
nx_estado<=std1;
end if;
when std1 =>
z_out<="0001";
z<="00";
if (x='0') then
nx_estado<=std1;
else
nx_estado<=std2;
end if;
when std2 =>
z_out<="0010";
z<="00";
if (x='0') then
nx_estado<=std2;
else
nx_estado<=std3;
end if;
when std3 =>
z_out<="0011";
z<="10";
if (x='0') then
nx_estado<=std3;
else
nx_estado<=std4;
end if;
when std4 =>
z_out<="0100";
z<="01";
if (x='0') then
nx_estado<=std0;
else
nx_estado<=std5;
end if;
when std5 =>
z_out<="0101";
z<="11";
if (x='0') then
nx_estado<=std5;
else
nx_estado<=std6;
end if;
when std6 =>
z_out<="0110";
z<="11";
if (x='0') then
nx_estado<=std6;
else
nx_estado<=std7;
end if;
when std7 =>
z_out<="0111";
z<="11";
if (x='0') then
nx_estado<=std7;
else
nx_estado<=std0;
end if;
end case;
end process;
end Behavioral;
CLK
# Clock signal
set_property PACKAGE_PIN W5 [get_ports clk]
set_property IOSTANDARD LVCMOS33 [get_ports clk]
create_clock -add -name sys_clk_pin -period 10.00 -waveform {0 5} [get_ports clk]
Switch
set_property PACKAGE_PIN V17 [get_ports {A[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {A[0]}]
LED
set_property PACKAGE_PIN U16 [get_ports {z[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {z[0]}]
Display
set_property PACKAGE_PIN W7 [get_ports {resultado_out[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {resultado_out[0]}]
Button