| 1 |
28 |
budinero |
-------------------------------------------------------------------------------------------------100
|
| 2 |
|
|
--| Modular Oscilloscope
|
| 3 |
|
|
--| UNSL - Argentine
|
| 4 |
|
|
--|
|
| 5 |
37 |
budinero |
--| File: ctrl_output_manager.vhd
|
| 6 |
35 |
budinero |
--| Version: 0.5
|
| 7 |
28 |
budinero |
--| Tested in: Actel A3PE1500
|
| 8 |
37 |
budinero |
--| Board: RVI Prototype Board + LP Data Conversion Daughter Board
|
| 9 |
28 |
budinero |
--|-------------------------------------------------------------------------------------------------
|
| 10 |
|
|
--| Description:
|
| 11 |
|
|
--| CONTROL - Output manager
|
| 12 |
35 |
budinero |
--| Reads a memory incrementaly under certain parameters.
|
| 13 |
28 |
budinero |
--|
|
| 14 |
|
|
--|-------------------------------------------------------------------------------------------------
|
| 15 |
|
|
--| File history:
|
| 16 |
|
|
--| 0.1 | jun-2009 | First testing
|
| 17 |
|
|
--| 0.2 | jul-2009 | Two levels internal buffer
|
| 18 |
|
|
--| 0.3 | jul-2009 | One level internal buffer and only one clock
|
| 19 |
33 |
budinero |
--| 0.31 | jul-2009 | Internal WE signals
|
| 20 |
35 |
budinero |
--| 0.5 | jul-2009 | Architecture completely renovated (reduced)
|
| 21 |
28 |
budinero |
----------------------------------------------------------------------------------------------------
|
| 22 |
33 |
budinero |
--| Copyright © 2009, Facundo Aguilera.
|
| 23 |
28 |
budinero |
--|
|
| 24 |
|
|
--| This VHDL design file is an open design; you can redistribute it and/or
|
| 25 |
|
|
--| modify it and/or implement it after contacting the author.
|
| 26 |
|
|
----------------------------------------------------------------------------------------------------
|
| 27 |
|
|
|
| 28 |
33 |
budinero |
|
| 29 |
|
|
--==================================================================================================
|
| 30 |
37 |
budinero |
-- TO DO
|
| 31 |
|
|
-- · Spped up address_counter
|
| 32 |
35 |
budinero |
-- · Test new architecture
|
| 33 |
33 |
budinero |
--==================================================================================================
|
| 34 |
28 |
budinero |
|
| 35 |
|
|
|
| 36 |
|
|
library ieee;
|
| 37 |
|
|
use ieee.std_logic_1164.all;
|
| 38 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
| 39 |
|
|
use IEEE.NUMERIC_STD.ALL;
|
| 40 |
|
|
|
| 41 |
|
|
|
| 42 |
|
|
|
| 43 |
|
|
----------------------------------------------------------------------------------------------------
|
| 44 |
|
|
----------------------------------------------------------------------------------------------------
|
| 45 |
37 |
budinero |
entity ctrl_output_manager is
|
| 46 |
28 |
budinero |
generic(
|
| 47 |
33 |
budinero |
MEM_ADD_WIDTH: integer := 14
|
| 48 |
28 |
budinero |
);
|
| 49 |
|
|
port(
|
| 50 |
|
|
------------------------------------------------------------------------------------------------
|
| 51 |
|
|
-- MASTER (to memory)
|
| 52 |
|
|
DAT_I_mem: in std_logic_vector (15 downto 0);
|
| 53 |
|
|
--DAT_O_mem: out std_logic_vector (15 downto 0);
|
| 54 |
|
|
ADR_O_mem: out std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
| 55 |
|
|
CYC_O_mem: out std_logic;
|
| 56 |
|
|
STB_O_mem: out std_logic;
|
| 57 |
|
|
ACK_I_mem: in std_logic ;
|
| 58 |
|
|
WE_O_mem: out std_logic;
|
| 59 |
|
|
|
| 60 |
|
|
------------------------------------------------------------------------------------------------
|
| 61 |
|
|
-- SLAVE (to I/O ports)
|
| 62 |
|
|
--DAT_I_port: in std_logic_vector (15 downto 0);
|
| 63 |
|
|
DAT_O_port: out std_logic_vector (15 downto 0);
|
| 64 |
|
|
--ADR_I_port: in std_logic_vector (7 downto 0);
|
| 65 |
|
|
CYC_I_port: in std_logic;
|
| 66 |
|
|
STB_I_port: in std_logic;
|
| 67 |
|
|
ACK_O_port: out std_logic ;
|
| 68 |
|
|
WE_I_port: in std_logic;
|
| 69 |
|
|
|
| 70 |
|
|
|
| 71 |
|
|
------------------------------------------------------------------------------------------------
|
| 72 |
|
|
-- Common signals
|
| 73 |
|
|
RST_I: in std_logic;
|
| 74 |
|
|
CLK_I: in std_logic;
|
| 75 |
|
|
|
| 76 |
|
|
------------------------------------------------------------------------------------------------
|
| 77 |
|
|
-- Internal
|
| 78 |
35 |
budinero |
|
| 79 |
|
|
load_I: in std_logic;
|
| 80 |
|
|
-- load initial address
|
| 81 |
|
|
|
| 82 |
|
|
enable_I: in std_logic;
|
| 83 |
|
|
-- continue reading from the actual address ('0' means pause, '1' means continue)
|
| 84 |
|
|
|
| 85 |
|
|
initial_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
| 86 |
28 |
budinero |
-- buffer starts and ends here
|
| 87 |
35 |
budinero |
|
| 88 |
37 |
budinero |
biggest_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
| 89 |
35 |
budinero |
-- when the buffer arrives here, address is changed to 0 (buffer size)
|
| 90 |
|
|
|
| 91 |
37 |
budinero |
pause_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
| 92 |
28 |
budinero |
-- address wich is being writed by control
|
| 93 |
35 |
budinero |
|
| 94 |
|
|
finish_O: out std_logic
|
| 95 |
|
|
-- it is set when communication ends and remains until next restart or actual address change
|
| 96 |
37 |
budinero |
|
| 97 |
28 |
budinero |
);
|
| 98 |
37 |
budinero |
end entity ctrl_output_manager;
|
| 99 |
28 |
budinero |
|
| 100 |
|
|
----------------------------------------------------------------------------------------------------
|
| 101 |
|
|
----------------------------------------------------------------------------------------------------
|
| 102 |
37 |
budinero |
architecture ARCH20 of ctrl_output_manager is
|
| 103 |
|
|
|
| 104 |
28 |
budinero |
signal address_counter: std_logic_vector(MEM_ADD_WIDTH - 1 downto 0);
|
| 105 |
|
|
signal enable_read: std_logic;
|
| 106 |
35 |
budinero |
signal enable_count: std_logic;
|
| 107 |
|
|
signal s_finish: std_logic; -- register previous (and equal) to output
|
| 108 |
37 |
budinero |
signal init: std_logic; -- register
|
| 109 |
28 |
budinero |
|
| 110 |
|
|
begin
|
| 111 |
35 |
budinero |
|
| 112 |
28 |
budinero |
--------------------------------------------------------------------------------------------------
|
| 113 |
35 |
budinero |
-- Wishbone signals
|
| 114 |
|
|
DAT_O_port <= DAT_I_mem;
|
| 115 |
|
|
CYC_O_mem <= CYC_I_port;
|
| 116 |
|
|
STB_O_mem <= STB_I_port and enable_read;
|
| 117 |
|
|
ACK_O_port <= ACK_I_mem;
|
| 118 |
|
|
ADR_O_mem <= address_counter;
|
| 119 |
|
|
WE_O_mem <= '0' ;
|
| 120 |
28 |
budinero |
|
| 121 |
35 |
budinero |
--------------------------------------------------------------------------------------------------
|
| 122 |
|
|
-- Status signals
|
| 123 |
37 |
budinero |
enable_read <= '1' when enable_I = '1' and WE_I_port = '0' and s_finish = '0' and
|
| 124 |
|
|
(address_counter /= pause_address_I or init = '1')
|
| 125 |
33 |
budinero |
else '0';
|
| 126 |
37 |
budinero |
|
| 127 |
35 |
budinero |
enable_count <= CYC_I_port and STB_I_port and ACK_I_mem and enable_read;
|
| 128 |
28 |
budinero |
|
| 129 |
35 |
budinero |
finish_O <= s_finish;
|
| 130 |
|
|
|
| 131 |
|
|
P_finish: process ( CLK_I, RST_I, address_counter, initial_address_I, load_I)
|
| 132 |
|
|
begin
|
| 133 |
37 |
budinero |
if CLK_I'event and CLK_I = '1' and CLK_I'LAST_VALUE = '0' then
|
| 134 |
35 |
budinero |
if RST_I = '1' then
|
| 135 |
|
|
s_finish <= '1';
|
| 136 |
37 |
budinero |
init <= '0';
|
| 137 |
35 |
budinero |
elsif load_I = '1' then
|
| 138 |
|
|
s_finish <= '0';
|
| 139 |
37 |
budinero |
init <= '1';
|
| 140 |
|
|
elsif address_counter + 1 = initial_address_I then
|
| 141 |
35 |
budinero |
s_finish <= '1';
|
| 142 |
37 |
budinero |
init <= '0';
|
| 143 |
|
|
else
|
| 144 |
|
|
init <= '0';
|
| 145 |
|
|
end if;
|
| 146 |
35 |
budinero |
end if;
|
| 147 |
|
|
end process;
|
| 148 |
33 |
budinero |
|
| 149 |
35 |
budinero |
--------------------------------------------------------------------------------------------------
|
| 150 |
|
|
-- Address counter
|
| 151 |
|
|
P_count: process(CLK_I, address_counter, enable_count, load_I)
|
| 152 |
28 |
budinero |
begin
|
| 153 |
35 |
budinero |
if CLK_I'event and CLK_I = '1' and CLK_I'LAST_VALUE = '0' then
|
| 154 |
|
|
if load_I = '1' then
|
| 155 |
|
|
address_counter <= initial_address_I;
|
| 156 |
37 |
budinero |
elsif enable_count = '1' and address_counter >= biggest_address_I then
|
| 157 |
|
|
address_counter <= (others => '0');
|
| 158 |
|
|
elsif enable_count = '1' then
|
| 159 |
|
|
address_counter <= address_counter + 1;
|
| 160 |
28 |
budinero |
end if;
|
| 161 |
35 |
budinero |
end if;
|
| 162 |
28 |
budinero |
end process;
|
| 163 |
|
|
|
| 164 |
|
|
end architecture;
|