LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.ALL;
entity tb_reverseline is
end tb_reverseline;
architecture tb of tb_reverseline is
--component reverseline
-- port(ingresso, rst_n, clk, en : in std_logic;
-- uscita : out std_logic);
-- end component;
signal wordin : std_logic_vector(7 downto 0) := "10011010";
signal wordout: std_logic_vector(7 downto 0);
signal clk_0 : std_logic := '0';
signal start : std_logic;
signal rst_sys: std_logic;
signal Q : std_logic_vector(7 downto 0);
begin
--reverser: reverseline
-- port map(ingresso => wordin(7),
-- rst_n => rst_sys,
-- clk => clk_0,
-- en => start,
-- uscita => wordout(0));
clk_0 <= not clk_0 after 10 ns;
reset_wave: process
begin
rst_sys <= '0';
wait for 42 ns;
rst_sys <= '1';
wait for 1000 ns;
end process reset_wave;
enable_wave: process
begin
start <= '1';
wait for 10 ns;
start <= '0';
wait for 54 ns;
start <= '1';
wait for 500 ns;
start <= '0';
end process enable_wave;
-- questo process rappresenta nient'altro che 2 buffer
-- uno all'ingresso e uno all'uscita del registro invertitore
-- è proprio questo che mi dà il problema
trasmissione: process(clk_0,rst_sys,start)
variable c: integer := 0;
begin
if rising_edge(clk_0) and rst_sys = '1' then
if start = '1' then
if c = 8 then
c := 0;
wordout(0) <= '0';
else
c := c + 1;
wordin(0) <= wordin(1) xor wordin(6);
wordout(0) <= Q(Q'left);
for i in 0 to 6 loop
wordin(i+1) <= wordin(i);
wordout(i+1) <= wordout(i);
end loop;
end if;
end if;
end if;
end process trasmissione;
-- questo è il registro invertitore
rx : process(CLK_0, RST_sys, start)
--variabile che fa scattare l'operazione di conversione;
--potrebbe diventare un contatore
variable count: integer;
begin
--effetto del reset e dell'enable asincrono
if RST_SYS = '0' or start = '0' then
Q <= (others => '0');
count := 0;
elsif rising_edge(clk_0) then
count := count + 1;
if count = 9 then
for i in 0 to Q'left loop
Q(i) <= Q(Q'left - i);
end loop;
count := 0;
wordout(0) <= '1';
else
Q(0) <= wordin(7);
for i in 1 to Q'left loop
Q(i) <= Q(i-1);
end loop;
--wordout(0) <= Q(Q'left);
end if;
end if;
end process rx;
end architecture tb;