Line 11... |
Line 11... |
--| Read data and write it in a memory (it's a simple wishbone bridge)
|
--| Read data and write it in a memory (it's a simple wishbone bridge)
|
--|
|
--|
|
--|-------------------------------------------------------------------------------------------------
|
--|-------------------------------------------------------------------------------------------------
|
--| File history:
|
--| File history:
|
--| 0.1 | jul-2009 | First release
|
--| 0.1 | jul-2009 | First release
|
|
--| 0.12 | aug-2009 | Disable strobe output when enable = '0'
|
|
--| 0.13 | aug-2009 | End in 0 when continuous (better integration)
|
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
--| 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
|
-- · ...
|
-- · Test new enable function (for stb and cyc)
|
|
-- · Clean!
|
--==================================================================================================
|
--==================================================================================================
|
|
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
use IEEE.NUMERIC_STD.ALL;
|
use IEEE.NUMERIC_STD.ALL;
|
|
|
|
use work.ctrl_pkg.all;
|
|
|
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
entity ctrl_memory_writer is
|
entity ctrl_memory_writer is
|
generic(
|
generic(
|
Line 56... |
Line 59... |
-- Using an address generator, commented
|
-- Using an address generator, commented
|
-- ADR_O_adc: out std_logic_vector (ADC_ADD_WIDTH - 1 downto 0);
|
-- ADR_O_adc: out std_logic_vector (ADC_ADD_WIDTH - 1 downto 0);
|
CYC_O_adc: out std_logic;
|
CYC_O_adc: out std_logic;
|
STB_O_adc: out std_logic;
|
STB_O_adc: out std_logic;
|
ACK_I_adc: in std_logic ;
|
ACK_I_adc: in std_logic ;
|
WE_O_adc: out std_logic;
|
--WE_O_adc: out std_logic;
|
|
|
------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------
|
-- Common signals
|
-- Common signals
|
RST_I: in std_logic;
|
RST_I: in std_logic;
|
CLK_I: in std_logic;
|
CLK_I: in std_logic;
|
Line 73... |
Line 76... |
enable_I: in std_logic;
|
enable_I: in std_logic;
|
final_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
final_address_I: 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
|
-- it is set when communication ends and remains until next restart or actual address change
|
finished_O: out std_logic;
|
finished_O: out std_logic;
|
-- when counter finishes, restart
|
-- when counter finishes, restart
|
continuous_I: in std_logic;
|
continuous_I: in std_logic
|
);
|
);
|
end entity ctrl_memory_writer;
|
end entity ctrl_memory_writer;
|
|
|
|
|
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
architecture ARCH11 of ctrl_output_manager is
|
architecture ARCH12 of ctrl_memory_writer is
|
|
|
type DataStatusType is (
|
type DataStatusType is (
|
|
FINISHED,
|
INIT,
|
INIT,
|
WORKING
|
WORKING
|
);
|
);
|
|
|
signal data_status: DataStatusType; -- comunicates status between both ports
|
signal data_status: DataStatusType;
|
|
|
|
|
signal count: std_logic_vector(MEM_ADD_WIDTH-1 downto 0);
|
signal count: std_logic_vector(MEM_ADD_WIDTH-1 downto 0);
|
signal enable_count:std_logic;
|
signal enable_count:std_logic;
|
signal reset_count: std_logic;
|
signal reset_count: std_logic;
|
signal data: std_logic_vector(15 downto 0);
|
signal data: std_logic_vector(15 downto 0);
|
|
|
signal address_counter: std_logic_vector(MEM_ADD_WIDTH - 1 downto 0);
|
|
signal s_finished, s_STB_adc, s_STB_mem: std_logic; -- previous to outputs
|
signal s_finished, s_STB_adc, s_STB_mem: std_logic; -- previous to outputs
|
|
|
begin
|
begin
|
--------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------
|
-- Instances
|
-- Instances
|
Line 117... |
Line 119... |
|
|
--------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------
|
-- Combinational
|
-- Combinational
|
|
|
-- counter
|
-- counter
|
s_finished <= '1' when count >= final_address_I;
|
s_finished <= '1' when count >= final_address_I else '0';
|
enable_count <= '1' when enable_I = '1' and
|
enable_count <= '1' when enable_I = '1' and
|
data_status = WORKING and
|
data_status = WORKING and
|
s_STB_mem = '1' and
|
s_STB_mem = '1' and
|
ACK_I_mem = '1' and
|
ACK_I_mem = '1'
|
s_finished = '0'
|
|
else
|
else
|
'0';
|
'0';
|
reset_count <= '1' when reset_I = '1' or (s_finished = '1' and continuous_I = '1') else
|
reset_count <= '1' when reset_I = '1' or s_finished = '1' else
|
'0';
|
'0';
|
|
|
-- outputs
|
-- outputs
|
finished_O <= s_finished;
|
finished_O <= s_finished;
|
STB_O_adc <= s_STB_adc;
|
STB_O_adc <= s_STB_adc and enable_I; -- !
|
STB_O_mem <= s_STB_mem;
|
STB_O_mem <= s_STB_mem and enable_I; -- !
|
DAT_O_mem <= data;
|
DAT_O_mem <= data;
|
ADR_O_mem <= count;
|
ADR_O_mem <= count;
|
|
--WE_O_adc <= '0';
|
|
WE_O_mem <= '1';
|
|
|
--------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------
|
-- Clocked
|
-- Clocked
|
|
|
|
|
-- Lock interface when working
|
-- Lock interface when working
|
P_cyc_signals: process (clk_I, enable_count, ACK_I_adc, ACK_I_mem)
|
P_cyc_signals: process (CLK_I, enable_I, reset_I)
|
begin
|
begin
|
if CLK_I'event and CLK_I = '1' then
|
if CLK_I'event and CLK_I = '1' then
|
if enable_I = '0' or reset_I = '1' then
|
if enable_I = '0' or reset_I = '1' then
|
CYC_O_adc <= '0'; CYC_O_mem <= '0';
|
CYC_O_adc <= '0'; CYC_O_mem <= '0';
|
else
|
else
|
Line 152... |
Line 155... |
end if;
|
end if;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
|
|
|
|
|
|
P_stb_signals: process (CLK_I, reset_I, data_status, s_STB_adc, s_STB_mem, ACK_I_adc, ACK_I_mem)
|
P_stb_signals: process (CLK_I, reset_I, data_status, s_STB_adc, s_STB_mem, ACK_I_adc, ACK_I_mem)
|
begin
|
begin
|
|
|
if CLK_I'event and CLK_I = '1' then
|
if CLK_I'event and CLK_I = '1' then
|
if reset_I = '1' then
|
if reset_I = '1' or RST_I = '1' then
|
data_status <= INIT;
|
data_status <= INIT;
|
s_STB_adc <= '0';
|
s_STB_adc <= '0';
|
s_STB_mem <= '0';
|
s_STB_mem <= '0';
|
data <= (others => '0');
|
data <= (others => '0');
|
elsif enable_I = '1' then
|
elsif enable_I = '1' then
|
if data_status = INIT and s_STB_adc = '0' or s_STB_mem = '0' then
|
case data_status is
|
|
when INIT =>
|
-- this state is only necessary when there are adc convertions in every clock
|
-- this state is only necessary when there are adc convertions in every clock
|
-- (for the first convertion)
|
-- (for the first convertion)
|
s_STB_adc <= '1';
|
s_STB_adc <= '1';
|
s_STB_mem <= '1';
|
s_STB_mem <= '1';
|
else
|
|
data_status <= WORKING;
|
data_status <= WORKING;
|
|
|
|
when WORKING =>
|
if s_STB_adc = '1' and ACK_I_adc = '1' then
|
if s_STB_adc = '1' and ACK_I_adc = '1' then
|
s_STB_mem <= '1'; -- strobe when adc ack
|
s_STB_mem <= '1'; -- strobe when adc ack
|
data <= DAT_I_adc; -- save data
|
data <= DAT_I_adc; -- save data
|
elsif s_STB_mem = '1' and ACK_I_mem = '1' then
|
elsif s_STB_mem = '1' and ACK_I_mem = '1' then
|
s_STB_mem <= '0';
|
s_STB_mem <= '0';
|
Line 185... |
Line 187... |
s_STB_adc <= '1'; -- strobe when mem ack
|
s_STB_adc <= '1'; -- strobe when mem ack
|
elsif s_STB_adc = '1' and ACK_I_adc = '1' then
|
elsif s_STB_adc = '1' and ACK_I_adc = '1' then
|
s_STB_adc <= '0';
|
s_STB_adc <= '0';
|
end if;
|
end if;
|
|
|
|
if continuous_I = '0' and s_finished = '1' then
|
|
data_status <= FINISHED;
|
end if;
|
end if;
|
else
|
|
|
when others => -- FINISHED
|
s_STB_adc <= '0';
|
s_STB_adc <= '0';
|
s_STB_mem <= '0';
|
s_STB_mem <= '0';
|
|
|
|
end case;
|
end if;
|
end if;
|
end if;
|
end if;
|
|
|
end process;
|
end process;
|
|
|
|
|
|
|
|
|
|
|
end architecture;
|
end architecture;
|
No newline at end of file
|
No newline at end of file
|