Line 1... |
Line 1... |
-------------------------------------------------------------------------------------------------100
|
-------------------------------------------------------------------------------------------------100
|
--| Modular Oscilloscope
|
--| Modular Oscilloscope
|
--| UNSL - Argentine
|
--| UNSL - Argentine
|
--|
|
--|
|
--| File: output_manager.vhd
|
--| File: output_manager.vhd
|
--| Version: 0.31
|
--| Version: 0.5
|
--| Tested in: Actel A3PE1500
|
--| Tested in: Actel A3PE1500
|
--|-------------------------------------------------------------------------------------------------
|
--|-------------------------------------------------------------------------------------------------
|
--| Description:
|
--| Description:
|
--| CONTROL - Output manager
|
--| CONTROL - Output manager
|
--| This is a pseudo buffer, wich reads a memory incrementaly under certain parameters.
|
--| Reads a memory incrementaly under certain parameters.
|
--|
|
--|
|
--|-------------------------------------------------------------------------------------------------
|
--|-------------------------------------------------------------------------------------------------
|
--| File history:
|
--| File history:
|
--| 0.1 | jun-2009 | First testing
|
--| 0.1 | jun-2009 | First testing
|
--| 0.2 | jul-2009 | Two levels internal buffer
|
--| 0.2 | jul-2009 | Two levels internal buffer
|
--| 0.3 | jul-2009 | One level internal buffer and only one clock
|
--| 0.3 | jul-2009 | One level internal buffer and only one clock
|
--| 0.31 | jul-2009 | Internal WE signals
|
--| 0.31 | jul-2009 | Internal WE signals
|
|
--| 0.5 | jul-2009 | Architecture completely renovated (reduced)
|
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
--| Copyright © 2009, Facundo Aguilera.
|
--| Copyright © 2009, Facundo Aguilera.
|
--|
|
--|
|
--| This VHDL design file is an open design; you can redistribute it and/or
|
--| This VHDL design file is an open design; you can redistribute it and/or
|
--| modify it and/or implement it after contacting the author.
|
--| modify it and/or implement it after contacting the author.
|
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
|
|
|
|
--==================================================================================================
|
--==================================================================================================
|
-- TODO
|
-- TODO
|
-- · Spped up address_counter (with Actel SmartGen).
|
-- · Spped up address_counter.
|
|
-- · Test new architecture
|
--==================================================================================================
|
--==================================================================================================
|
|
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
Line 70... |
Line 72... |
RST_I: in std_logic;
|
RST_I: in std_logic;
|
CLK_I: in std_logic;
|
CLK_I: in std_logic;
|
|
|
------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------
|
-- Internal
|
-- Internal
|
-- reset counter to initial address, or load it
|
|
load: in std_logic;
|
load_I: in std_logic;
|
-- start count from the actual address ('0' means pause, '1' means continue)
|
-- load initial address
|
enable: in std_logic;
|
|
|
enable_I: in std_logic;
|
|
-- continue reading from the actual address ('0' means pause, '1' means continue)
|
|
|
|
initial_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
-- buffer starts and ends here
|
-- buffer starts and ends here
|
initial_address: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
|
|
biggest_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
-- when the buffer arrives here, address is changed to 0 (buffer size)
|
-- when the buffer arrives here, address is changed to 0 (buffer size)
|
final_address: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
|
|
pause_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
-- address wich is being writed by control
|
-- address wich is being writed by control
|
stop_address: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
|
-- it is set when communication ends and remains until next restart or actual address change
|
|
finish: out std_logic
|
|
|
|
|
finish_O: out std_logic
|
|
-- it is set when communication ends and remains until next restart or actual address change
|
|
|
);
|
);
|
end entity output_manager;
|
end entity output_manager;
|
|
|
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
architecture ARCH11 of output_manager is
|
architecture ARCH20 of output_manager is
|
|
|
|
|
|
|
|
|
type DataStatusType is (
|
|
RESET,
|
|
INIT, -- when restartet
|
|
READY, -- data available to be read
|
|
READ -- data was read from port, read next from memory
|
|
);
|
|
|
|
signal data_status: DataStatusType; -- comunicates status between both ports
|
|
|
|
signal address_counter: std_logic_vector(MEM_ADD_WIDTH - 1 downto 0);
|
signal address_counter: std_logic_vector(MEM_ADD_WIDTH - 1 downto 0);
|
signal data: std_logic_vector(15 downto 0);
|
|
signal enable_read: std_logic;
|
signal enable_read: std_logic;
|
signal s_finish: std_logic;
|
signal enable_count: std_logic;
|
|
signal s_finish: std_logic; -- register previous (and equal) to output
|
|
|
|
|
begin
|
begin
|
|
|
--------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------
|
-- Data status resolution
|
-- Wishbone signals
|
|
|
P_status: process(CLK_I, RST_I, load, WE_I_port)
|
|
begin
|
|
|
|
if (CLK_I'event and CLK_I = '1') then
|
|
if RST_I = '1' or load = '1' then
|
|
data_status <= RESET;
|
|
else
|
|
case data_status is
|
|
when RESET =>
|
|
|
|
data_status <= INIT;
|
|
|
|
when INIT =>
|
|
|
|
if ACK_I_mem = '1' and enable_read = '1' then
|
|
data_status <= READY;
|
|
end if;
|
|
|
|
|
DAT_O_port <= DAT_I_mem;
|
|
CYC_O_mem <= CYC_I_port;
|
|
STB_O_mem <= STB_I_port and enable_read;
|
|
ACK_O_port <= ACK_I_mem;
|
|
ADR_O_mem <= address_counter;
|
|
WE_O_mem <= '0' ;
|
|
|
when READ =>
|
--------------------------------------------------------------------------------------------------
|
|
-- Status signals
|
|
|
if ACK_I_mem = '1' and enable_read = '1' and (STB_I_port /= '1' or CYC_I_port /= '1' or
|
enable_read <= '1' when enable_I = '1' and s_finish = '0' and address_counter /= pause_address_I
|
WE_I_port /= '0')
|
and WE_I_port = '0'
|
then
|
else '0';
|
data_status <= READY;
|
|
end if;
|
|
-- STB_I_port /= '1' or CYC_I_port /= '1': forwarding
|
|
|
|
when others => -- (when READY)
|
enable_count <= CYC_I_port and STB_I_port and ACK_I_mem and enable_read;
|
|
|
if STB_I_port = '1' and CYC_I_port = '1' and WE_I_port = '0' then
|
finish_O <= s_finish;
|
data_status <= READ;
|
|
end if;
|
|
|
|
end case;
|
P_finish: process ( CLK_I, RST_I, address_counter, initial_address_I, load_I)
|
|
begin
|
|
if CLK_I'event and CLK_I = '1' and CLK_I'LAST_VALUE = '0' then
|
|
if RST_I = '1' then
|
|
s_finish <= '1';
|
|
elsif load_I = '1' then
|
|
s_finish <= '0';
|
|
elsif address_counter = initial_address_I then
|
|
s_finish <= '1';
|
end if;
|
end if;
|
end if;
|
end if;
|
|
|
end process;
|
end process;
|
|
|
|
|
--------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------
|
-- Data read
|
-- Address counter
|
ADR_O_mem <= address_counter;
|
|
s_finish <= '1' when address_counter = initial_address and data_status /= INIT else
|
|
'0';
|
|
enable_read <= '1' when enable = '1' and s_finish = '0' and address_counter /= stop_address
|
|
else '0';
|
|
|
|
finish <= s_finish;
|
P_count: process(CLK_I, address_counter, enable_count, load_I)
|
WE_O_mem <= '0' ;
|
|
|
|
|
|
|
|
P_read: process(CLK_I, data_status, initial_address, address_counter, data, enable_read,
|
|
ACK_I_mem, WE_I_port)
|
|
begin
|
begin
|
|
if CLK_I'event and CLK_I = '1' and CLK_I'LAST_VALUE = '0' then
|
|
if load_I = '1' then
|
-- Clocked signals
|
address_counter <= initial_address_I;
|
if (CLK_I'event and CLK_I = '1') then
|
elsif enable_count = '1' then
|
case data_status is
|
if address_counter >= biggest_address_I then
|
|
|
when RESET =>
|
|
|
|
data <= (others => '0');
|
|
address_counter <= initial_address;
|
|
|
|
when READY =>
|
|
|
|
if enable_read = '1' and ACK_I_mem = '1' and CYC_I_port = '1' and STB_I_port = '1' then
|
|
-- (forwarding)
|
|
data <= DAT_I_mem;
|
|
if address_counter < final_address then
|
|
address_counter <= address_counter + 1;
|
|
else
|
|
address_counter <= (others => '0');
|
address_counter <= (others => '0');
|
end if;
|
|
else
|
else
|
data <= data;
|
|
address_counter <= address_counter;
|
|
end if;
|
|
|
|
when others => -- (when INIT or READ)
|
|
|
|
if enable_read = '1' and ACK_I_mem = '1' then
|
|
data <= DAT_I_mem;
|
|
if address_counter < final_address then
|
|
address_counter <= address_counter + 1;
|
address_counter <= address_counter + 1;
|
else
|
|
address_counter <= (others => '0');
|
|
end if;
|
|
end if;
|
end if;
|
|
|
end case;
|
|
end if;
|
|
|
|
-- Cominational signals
|
|
|
|
case data_status is
|
|
when RESET =>
|
|
|
|
STB_O_mem <= '0';
|
|
CYC_O_mem <= '0';
|
|
|
|
when READY =>
|
|
|
|
if enable_read = '1' and CYC_I_port = '1' and STB_I_port = '1' and WE_I_port = '0' then
|
|
-- (forwarding)
|
|
STB_O_mem <= '1';
|
|
CYC_O_mem <= '1';
|
|
else
|
|
STB_O_mem <= '0';
|
|
CYC_O_mem <= '0';
|
|
end if;
|
end if;
|
|
|
when others => -- (when INIT or READ)
|
|
|
|
if enable_read = '1' then
|
|
STB_O_mem <= '1';
|
|
CYC_O_mem <= '1';
|
|
else
|
|
STB_O_mem <= '0';
|
|
CYC_O_mem <= '0';
|
|
end if;
|
end if;
|
|
|
end case;
|
|
|
|
|
|
end process;
|
end process;
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------
|
|
-- Read from port interface
|
|
ACK_O_port <= '1' when (CYC_I_port = '1' and STB_I_port = '1' and WE_I_port = '0') and
|
|
(data_status = READY or
|
|
(data_status = READ and ACK_I_mem = '1' and enable_read = '1' )) else
|
|
'0';
|
|
-- data_status = READ and ACK_I_mem = '1' and enable_read = '1': forwarding
|
|
|
|
DAT_O_port <= data;
|
|
|
|
|
|
|
|
|
|
end architecture;
|
end architecture;
|
No newline at end of file
|
No newline at end of file
|