1 |
28 |
budinero |
-------------------------------------------------------------------------------------------------100
|
2 |
|
|
--| Modular Oscilloscope
|
3 |
|
|
--| UNSL - Argentine
|
4 |
|
|
--|
|
5 |
37 |
budinero |
--| File: ctrl_output_manager.vhd
|
6 |
54 |
budinero |
--| Version: 0.54
|
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 |
54 |
budinero |
--| 0.54 | aug-2009 | New finish_O and init flag behavior
|
22 |
28 |
budinero |
----------------------------------------------------------------------------------------------------
|
23 |
33 |
budinero |
--| Copyright © 2009, Facundo Aguilera.
|
24 |
28 |
budinero |
--|
|
25 |
|
|
--| This VHDL design file is an open design; you can redistribute it and/or
|
26 |
|
|
--| modify it and/or implement it after contacting the author.
|
27 |
|
|
----------------------------------------------------------------------------------------------------
|
28 |
|
|
|
29 |
33 |
budinero |
|
30 |
|
|
--==================================================================================================
|
31 |
37 |
budinero |
-- TO DO
|
32 |
55 |
budinero |
-- · (NO) Speed up address_counter
|
33 |
|
|
-- · (OK) Full test of new architecture
|
34 |
|
|
-- · (OK) Fix default value of s_finish signal
|
35 |
|
|
-- · General speed up
|
36 |
33 |
budinero |
--==================================================================================================
|
37 |
28 |
budinero |
|
38 |
|
|
|
39 |
|
|
library ieee;
|
40 |
|
|
use ieee.std_logic_1164.all;
|
41 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
42 |
|
|
use IEEE.NUMERIC_STD.ALL;
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
----------------------------------------------------------------------------------------------------
|
47 |
|
|
----------------------------------------------------------------------------------------------------
|
48 |
37 |
budinero |
entity ctrl_output_manager is
|
49 |
28 |
budinero |
generic(
|
50 |
33 |
budinero |
MEM_ADD_WIDTH: integer := 14
|
51 |
28 |
budinero |
);
|
52 |
|
|
port(
|
53 |
|
|
------------------------------------------------------------------------------------------------
|
54 |
|
|
-- MASTER (to memory)
|
55 |
|
|
DAT_I_mem: in std_logic_vector (15 downto 0);
|
56 |
|
|
--DAT_O_mem: out std_logic_vector (15 downto 0);
|
57 |
|
|
ADR_O_mem: out std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
58 |
|
|
CYC_O_mem: out std_logic;
|
59 |
|
|
STB_O_mem: out std_logic;
|
60 |
|
|
ACK_I_mem: in std_logic ;
|
61 |
|
|
WE_O_mem: out std_logic;
|
62 |
|
|
|
63 |
|
|
------------------------------------------------------------------------------------------------
|
64 |
|
|
-- SLAVE (to I/O ports)
|
65 |
|
|
--DAT_I_port: in std_logic_vector (15 downto 0);
|
66 |
|
|
DAT_O_port: out std_logic_vector (15 downto 0);
|
67 |
|
|
--ADR_I_port: in std_logic_vector (7 downto 0);
|
68 |
|
|
CYC_I_port: in std_logic;
|
69 |
|
|
STB_I_port: in std_logic;
|
70 |
|
|
ACK_O_port: out std_logic ;
|
71 |
|
|
WE_I_port: in std_logic;
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
------------------------------------------------------------------------------------------------
|
75 |
|
|
-- Common signals
|
76 |
|
|
RST_I: in std_logic;
|
77 |
|
|
CLK_I: in std_logic;
|
78 |
|
|
|
79 |
|
|
------------------------------------------------------------------------------------------------
|
80 |
|
|
-- Internal
|
81 |
35 |
budinero |
|
82 |
|
|
load_I: in std_logic;
|
83 |
|
|
-- load initial address
|
84 |
|
|
|
85 |
|
|
enable_I: in std_logic;
|
86 |
|
|
-- continue reading from the actual address ('0' means pause, '1' means continue)
|
87 |
|
|
|
88 |
|
|
initial_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
89 |
28 |
budinero |
-- buffer starts and ends here
|
90 |
35 |
budinero |
|
91 |
37 |
budinero |
biggest_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
92 |
35 |
budinero |
-- when the buffer arrives here, address is changed to 0 (buffer size)
|
93 |
|
|
|
94 |
37 |
budinero |
pause_address_I: in std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
|
95 |
28 |
budinero |
-- address wich is being writed by control
|
96 |
35 |
budinero |
|
97 |
|
|
finish_O: out std_logic
|
98 |
|
|
-- it is set when communication ends and remains until next restart or actual address change
|
99 |
37 |
budinero |
|
100 |
28 |
budinero |
);
|
101 |
37 |
budinero |
end entity ctrl_output_manager;
|
102 |
28 |
budinero |
|
103 |
|
|
----------------------------------------------------------------------------------------------------
|
104 |
|
|
----------------------------------------------------------------------------------------------------
|
105 |
54 |
budinero |
architecture ARCH22 of ctrl_output_manager is
|
106 |
37 |
budinero |
|
107 |
28 |
budinero |
signal address_counter: std_logic_vector(MEM_ADD_WIDTH - 1 downto 0);
|
108 |
|
|
signal enable_read: std_logic;
|
109 |
35 |
budinero |
signal enable_count: std_logic;
|
110 |
55 |
budinero |
signal enable_strobe: std_logic;
|
111 |
35 |
budinero |
signal s_finish: std_logic; -- register previous (and equal) to output
|
112 |
37 |
budinero |
signal init: std_logic; -- register
|
113 |
55 |
budinero |
signal same_address: std_logic;
|
114 |
28 |
budinero |
|
115 |
|
|
begin
|
116 |
35 |
budinero |
|
117 |
28 |
budinero |
--------------------------------------------------------------------------------------------------
|
118 |
35 |
budinero |
-- Wishbone signals
|
119 |
|
|
DAT_O_port <= DAT_I_mem;
|
120 |
|
|
CYC_O_mem <= CYC_I_port;
|
121 |
|
|
STB_O_mem <= STB_I_port and enable_read;
|
122 |
|
|
ACK_O_port <= ACK_I_mem;
|
123 |
|
|
ADR_O_mem <= address_counter;
|
124 |
|
|
WE_O_mem <= '0' ;
|
125 |
28 |
budinero |
|
126 |
35 |
budinero |
--------------------------------------------------------------------------------------------------
|
127 |
|
|
-- Status signals
|
128 |
54 |
budinero |
-- there is an init signal because in the first read, address_counter may be = to pause_address_I
|
129 |
55 |
budinero |
P_pause: process (CLK_I, RST_I, address_counter, pause_address_I)
|
130 |
|
|
begin
|
131 |
|
|
if CLK_I'event and CLK_I = '1' then
|
132 |
|
|
if RST_I = '1' then
|
133 |
|
|
same_address <= '0';
|
134 |
|
|
elsif address_counter = pause_address_I then
|
135 |
|
|
same_address <= '1';
|
136 |
|
|
else
|
137 |
|
|
same_address <= '0';
|
138 |
|
|
end if;
|
139 |
|
|
end if;
|
140 |
|
|
end process;
|
141 |
|
|
|
142 |
|
|
P_flags: process(CLK_I, RST_I, enable_I, enable_count, load_I)
|
143 |
|
|
begin
|
144 |
|
|
if CLK_I'event and CLK_I = '1' and CLK_I'LAST_VALUE = '0' then
|
145 |
|
|
-- when enable is '0', finish_O must be 0 again
|
146 |
|
|
if RST_I = '1' or enable_I = '0' then
|
147 |
|
|
init <= '1';
|
148 |
|
|
enable_strobe <= '0';
|
149 |
|
|
elsif (load_I = '1' and enable_I = '1') then
|
150 |
|
|
enable_strobe <= '1';
|
151 |
|
|
init <= '1';
|
152 |
|
|
elsif enable_count = '1' then
|
153 |
|
|
init <= '0';
|
154 |
|
|
end if;
|
155 |
|
|
end if;
|
156 |
|
|
end process;
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
enable_read <= '1' when WE_I_port = '0' and s_finish = '0' and
|
160 |
|
|
(same_address = '0' or init = '1') and enable_strobe = '1'
|
161 |
33 |
budinero |
else '0';
|
162 |
55 |
budinero |
|
163 |
35 |
budinero |
enable_count <= CYC_I_port and STB_I_port and ACK_I_mem and enable_read;
|
164 |
28 |
budinero |
|
165 |
55 |
budinero |
|
166 |
54 |
budinero |
s_finish <= '1' when address_counter = initial_address_I and init = '0' else
|
167 |
|
|
'0';
|
168 |
55 |
budinero |
finish_O <= s_finish;
|
169 |
33 |
budinero |
|
170 |
35 |
budinero |
--------------------------------------------------------------------------------------------------
|
171 |
|
|
-- Address counter
|
172 |
54 |
budinero |
P_count: process(CLK_I, RST_I, address_counter, enable_count, load_I)
|
173 |
28 |
budinero |
begin
|
174 |
35 |
budinero |
if CLK_I'event and CLK_I = '1' and CLK_I'LAST_VALUE = '0' then
|
175 |
54 |
budinero |
if RST_I = '1' then
|
176 |
|
|
address_counter <= (others => '0');
|
177 |
55 |
budinero |
elsif load_I = '1' and enable_I = '1' then
|
178 |
35 |
budinero |
address_counter <= initial_address_I;
|
179 |
37 |
budinero |
elsif enable_count = '1' and address_counter >= biggest_address_I then
|
180 |
|
|
address_counter <= (others => '0');
|
181 |
|
|
elsif enable_count = '1' then
|
182 |
|
|
address_counter <= address_counter + 1;
|
183 |
28 |
budinero |
end if;
|
184 |
35 |
budinero |
end if;
|
185 |
28 |
budinero |
end process;
|
186 |
|
|
|
187 |
|
|
end architecture;
|