library IEEE;
|
library IEEE;
|
use IEEE.STD_LOGIC_1164.ALL;
|
use IEEE.STD_LOGIC_1164.ALL;
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
|
|
-- Uncomment the following lines to use the declarations that are
|
-- Uncomment the following lines to use the declarations that are
|
-- provided for instantiating Xilinx primitive components.
|
-- provided for instantiating Xilinx primitive components.
|
--library UNISIM;
|
--library UNISIM;
|
--use UNISIM.VComponents.all;
|
--use UNISIM.VComponents.all;
|
|
|
entity input is
|
entity input is
|
Port ( clk : in std_logic;
|
Port ( clk : in std_logic;
|
rst : in std_logic;
|
rst : in std_logic;
|
serial : in std_logic;
|
serial : in std_logic;
|
mem_block : in std_logic;
|
mem_block : in std_logic;
|
mem_ready : out std_logic;
|
mem_ready : out std_logic;
|
wen : out std_logic;
|
wen : out std_logic;
|
address : out std_logic_vector (5 downto 0);
|
address : out std_logic_vector (5 downto 0);
|
i : out std_logic_vector(11 downto 0);
|
i : out std_logic_vector(11 downto 0);
|
q : out std_logic_vector(11 downto 0);
|
q : out std_logic_vector(11 downto 0)
|
);
|
);
|
end input;
|
end input;
|
|
|
architecture input of input is
|
architecture input of input is
|
|
|
type state is (s0, s1, s2, s3, s4, s5, s6, s7);
|
type state is (s0, s1, s2, s3, s4, s5, s6, s7);
|
signal st: state;
|
signal st: state;
|
signal meta, sync : std_logic;
|
signal meta, sync : std_logic;
|
signal addr : std_logic_vector(5 downto 0);
|
signal addr : std_logic_vector(5 downto 0);
|
begin
|
begin
|
|
|
process(clk,rst)
|
process(clk,rst)
|
--constant mais1 : std_logic_vector(11 downto 0) := "001100000000";
|
--constant mais1 : std_logic_vector(11 downto 0) := "001100000000";
|
constant mais1 : std_logic_vector(11 downto 0) := x"080";
|
constant mais1 : std_logic_vector(11 downto 0) := x"080";
|
constant menos1 : std_logic_vector(11 downto 0) := "110100000000";
|
constant menos1 : std_logic_vector(11 downto 0) := "110100000000";
|
begin
|
begin
|
-- 0123.45678901 bits
|
-- 0123.45678901 bits
|
-- 0011.00000000 = +1
|
-- 0011.00000000 = +1
|
-- 1101.00000000 = -1
|
-- 1101.00000000 = -1
|
|
|
-- Q
|
-- Q
|
-- o | o
|
-- o | o
|
-- 01 | 00
|
-- 01 | 00
|
-- |
|
-- |
|
-- ----------------- I
|
-- ----------------- I
|
-- |
|
-- |
|
-- 11 | 10
|
-- 11 | 10
|
-- o | o
|
-- o | o
|
|
|
if rst = '1' then
|
if rst = '1' then
|
st <= s0;
|
st <= s0;
|
mem_ready <= '0';
|
mem_ready <= '0';
|
wen <= '0';
|
wen <= '0';
|
addr <= (others => '0');
|
addr <= (others => '0');
|
address <= (others => '0');
|
address <= (others => '0');
|
i <= mais1;
|
i <= mais1;
|
q <= mais1;
|
q <= mais1;
|
elsif clk'event and clk='1' then
|
elsif clk'event and clk='1' then
|
case st is
|
case st is
|
when s0 =>
|
when s0 =>
|
st <= s1;
|
st <= s1;
|
meta <= serial;
|
meta <= serial;
|
wen <= '0';
|
wen <= '0';
|
when s1 =>
|
when s1 =>
|
st <= s2;
|
st <= s2;
|
sync <= meta;
|
sync <= meta;
|
when s2 =>
|
when s2 =>
|
st <= s3;
|
st <= s3;
|
if sync='0' then
|
if sync='0' then
|
i <= mais1;
|
i <= mais1;
|
else
|
else
|
i <= menos1;
|
i <= menos1;
|
end if;
|
end if;
|
when s3 =>
|
when s3 =>
|
st <= s4;
|
st <= s4;
|
when s4 =>
|
when s4 =>
|
st <= s5;
|
st <= s5;
|
meta <= serial;
|
meta <= serial;
|
addr <= addr +1;
|
addr <= addr +1;
|
when s5 =>
|
when s5 =>
|
st <= s6;
|
st <= s6;
|
sync <= meta;
|
sync <= meta;
|
if unsigned(addr) = 32 then
|
if unsigned(addr) = 32 then
|
addr <= conv_std_logic_vector(1,6);
|
addr <= conv_std_logic_vector(1,6);
|
mem_ready <= '1';
|
mem_ready <= '1';
|
end if;
|
end if;
|
when s6 =>
|
when s6 =>
|
st <= s7;
|
st <= s7;
|
mem_ready <= '0';
|
mem_ready <= '0';
|
if sync='0' then
|
if sync='0' then
|
q <= mais1;
|
q <= mais1;
|
else
|
else
|
q <= menos1;
|
q <= menos1;
|
end if;
|
end if;
|
when s7 =>
|
when s7 =>
|
st <= s0;
|
st <= s0;
|
if mem_block = '0' then
|
if mem_block = '0' then
|
address <= addr+32;
|
address <= addr+32;
|
else
|
else
|
address <= addr;
|
address <= addr;
|
end if;
|
end if;
|
wen <= '1';
|
wen <= '1';
|
end case;
|
end case;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
|
|