1 |
53 |
budinero |
-------------------------------------------------------------------------------------------------100
|
2 |
|
|
--| Modular Oscilloscope
|
3 |
|
|
--| UNSL - Argentine
|
4 |
|
|
--|
|
5 |
|
|
--| File: modullar_oscilloscope_tbench_text.vhd
|
6 |
|
|
--| Version: 0.1
|
7 |
|
|
--| Tested in: Actel A3PE1500
|
8 |
|
|
--| Board: RVI Prototype Board + LP Data Conversion Daughter Board
|
9 |
|
|
--|-------------------------------------------------------------------------------------------------
|
10 |
|
|
--| Description:
|
11 |
|
|
--| MODULAR OSCILLOSCOPE - Main
|
12 |
|
|
--| This is the top top module.
|
13 |
|
|
--|
|
14 |
|
|
--|-------------------------------------------------------------------------------------------------
|
15 |
|
|
--| File history:
|
16 |
|
|
--| 0.1 | aug-2009 | First testing
|
17 |
|
|
----------------------------------------------------------------------------------------------------
|
18 |
|
|
--| Copyright © 2009, Facundo Aguilera (budinero at gmail.com).
|
19 |
|
|
--|
|
20 |
|
|
--| This VHDL design file is an open design; you can redistribute it and/or
|
21 |
|
|
--| modify it and/or implement it after contacting the author.
|
22 |
|
|
----------------------------------------------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
-- NOTES:
|
26 |
|
|
-- · daq clock: 40 MHz
|
27 |
|
|
|
28 |
|
|
--==================================================================================================
|
29 |
|
|
-- TO DO
|
30 |
|
|
-- · Full full test
|
31 |
|
|
--==================================================================================================
|
32 |
|
|
library IEEE;
|
33 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
34 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
35 |
|
|
use ieee.math_real.all;
|
36 |
|
|
|
37 |
|
|
use work.ctrl_pkg.all;
|
38 |
|
|
use work.daq_pkg.all;
|
39 |
|
|
use work.memory_pkg.all;
|
40 |
|
|
use work.eppwbn_pkg.all;
|
41 |
|
|
|
42 |
|
|
entity modular_oscilloscope is
|
43 |
|
|
port(
|
44 |
|
|
-- ADC
|
45 |
|
|
adc_data_I: in std_logic_vector (9 downto 0);
|
46 |
|
|
adc_sel_O: out std_logic;
|
47 |
|
|
adc_clk_O: out std_logic;
|
48 |
|
|
adc_sleep_O: out std_logic;
|
49 |
|
|
adc_chip_sel_O: out std_logic;
|
50 |
|
|
|
51 |
|
|
-- EPP
|
52 |
|
|
nStrobe_I: in std_logic; -- HostClk/nWrite
|
53 |
|
|
Data_IO: inout std_logic_vector (7 downto 0);-- AD8..1 (Data1..Data8)
|
54 |
|
|
nAck_O: out std_logic; -- PtrClk/PeriphClk/Intr
|
55 |
|
|
busy_O: out std_logic; -- PtrBusy/PeriphAck/nWait
|
56 |
|
|
PError_O: out std_logic; -- AckData/nAckReverse
|
57 |
|
|
Sel_O: out std_logic; -- XFlag (Select)
|
58 |
|
|
nAutoFd_I: in std_logic; -- HostBusy/HostAck/nDStrb
|
59 |
|
|
PeriphLogicH_O: out std_logic; -- (Periph Logic High)
|
60 |
|
|
nInit_I: in std_logic; -- nReverseRequest
|
61 |
|
|
nFault_O: out std_logic; -- nDataAvail/nPeriphRequest
|
62 |
|
|
nSelectIn_I: in std_logic; -- 1284 Active/nAStrb
|
63 |
|
|
|
64 |
|
|
-- Peripherals
|
65 |
|
|
reset_I: in std_logic;
|
66 |
|
|
pll_clk_I: in std_logic -- clock signal go to pll, and is divided in two clocks
|
67 |
|
|
|
68 |
|
|
);
|
69 |
|
|
end entity modular_oscilloscope;
|
70 |
|
|
|
71 |
|
|
architecture structural1 of modular_oscilloscope is
|
72 |
|
|
|
73 |
|
|
------------------------------------------------------------------------------------------------
|
74 |
|
|
-- From port
|
75 |
|
|
signal ctrl_dat_i_port: std_logic_vector (15 downto 0);
|
76 |
|
|
signal ctrl_dat_o_port: std_logic_vector (15 downto 0);
|
77 |
|
|
signal ctrl_adr_i_port: std_logic_vector (7 downto 0);
|
78 |
|
|
signal ctrl_cyc_i_port: std_logic;
|
79 |
|
|
signal ctrl_stb_i_port: std_logic;
|
80 |
|
|
signal ctrl_ack_o_port: std_logic ;
|
81 |
|
|
signal ctrl_we_i_port: std_logic;
|
82 |
|
|
|
83 |
|
|
signal ctrl_dat_i_daq: std_logic_vector (15 downto 0);
|
84 |
|
|
signal ctrl_dat_o_daq: std_logic_vector (15 downto 0);
|
85 |
|
|
signal ctrl_adr_o_daq: std_logic_vector (1 downto 0);
|
86 |
|
|
signal ctrl_cyc_o_daq: std_logic;
|
87 |
|
|
signal ctrl_stb_o_daq: std_logic;
|
88 |
54 |
budinero |
signal ctrl_ack_i_daq: std_logic;
|
89 |
53 |
budinero |
signal ctrl_we_o_daq: std_logic;
|
90 |
|
|
|
91 |
|
|
signal ctrl_dat_o_memw: std_logic_vector (15 downto 0);
|
92 |
|
|
signal ctrl_adr_o_memw: std_logic_vector (13 downto 0);
|
93 |
|
|
signal ctrl_cyc_o_memw: std_logic;
|
94 |
|
|
signal ctrl_stb_o_memw: std_logic;
|
95 |
|
|
signal ctrl_ack_i_memw: std_logic ;
|
96 |
|
|
signal ctrl_we_o_memw: std_logic;
|
97 |
|
|
|
98 |
|
|
signal ctrl_dat_i_memr: std_logic_vector (15 downto 0);
|
99 |
|
|
signal ctrl_adr_o_memr: std_logic_vector (13 downto 0);
|
100 |
|
|
signal ctrl_cyc_o_memr: std_logic;
|
101 |
|
|
signal ctrl_stb_o_memr: std_logic;
|
102 |
|
|
signal ctrl_ack_i_memr: std_logic ;
|
103 |
|
|
signal ctrl_we_o_memr: std_logic;
|
104 |
|
|
|
105 |
|
|
signal clk_daq, clk_port: std_logic;
|
106 |
|
|
|
107 |
|
|
begin
|
108 |
|
|
|
109 |
|
|
U_DAQ: daq
|
110 |
|
|
generic map(
|
111 |
|
|
DEFALT_CONFIG => "0000101000000000"
|
112 |
|
|
-- 5432109876543210
|
113 |
|
|
--: std_logic_vector := "0000100000000000"
|
114 |
|
|
-- bits 8 a 0 clk_pre_scaler
|
115 |
|
|
-- bits 9 clk_pre_scaler_ena
|
116 |
|
|
-- bit 10 adc sleep
|
117 |
|
|
-- bit 11 adc_chip_sel
|
118 |
|
|
-- bits 12 a 15 sin usar
|
119 |
|
|
|
120 |
|
|
-- si clk_pre_scaler_ena = 1
|
121 |
|
|
-- frecuencia_adc = frecuencia_wbn / ((clk_pre_scaler+1)*2)
|
122 |
|
|
-- sino frecuencia_adc = frecuencia_wbn
|
123 |
|
|
)
|
124 |
|
|
port map(
|
125 |
|
|
-- Externo
|
126 |
|
|
adc_data_I => adc_data_I,
|
127 |
|
|
adc_sel_O => adc_sel_O,
|
128 |
|
|
adc_clk_O => adc_clk_O,
|
129 |
|
|
adc_sleep_O => adc_sleep_O,
|
130 |
|
|
adc_chip_sel_O => adc_chip_sel_O,
|
131 |
|
|
-- Interno
|
132 |
|
|
RST_I => reset_I,
|
133 |
|
|
CLK_I => clk_daq,
|
134 |
|
|
DAT_I => ctrl_dat_o_daq,
|
135 |
|
|
ADR_I => ctrl_adr_o_daq,
|
136 |
|
|
CYC_I => ctrl_cyc_o_daq,
|
137 |
|
|
STB_I => ctrl_stb_o_daq,
|
138 |
|
|
WE_I => ctrl_we_o_daq,
|
139 |
|
|
DAT_O => ctrl_dat_i_daq,
|
140 |
|
|
ACK_O => ctrl_ack_i_daq,
|
141 |
|
|
|
142 |
|
|
adc_clk_I => clk_daq
|
143 |
|
|
);
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
U_EPP16: eppwbn_16bit
|
147 |
|
|
port map (
|
148 |
|
|
-- TEMPORAL
|
149 |
|
|
--epp_mode_monitor: out std_logic_vector (1 downto 0);
|
150 |
|
|
-- Externo
|
151 |
|
|
nStrobe => nStrobe_I,
|
152 |
|
|
Data => Data_IO,
|
153 |
|
|
nAck => nAck_O,
|
154 |
|
|
busy => busy_O,
|
155 |
|
|
PError => PError_O,
|
156 |
|
|
Sel => Sel_O,
|
157 |
|
|
nAutoFd => nAutoFd_I,
|
158 |
|
|
PeriphLogicH => PeriphLogicH_O,
|
159 |
|
|
nInit => nInit_I,
|
160 |
|
|
nFault => nFault_O,
|
161 |
|
|
nSelectIn => nSelectIn_I,
|
162 |
|
|
-- Interno
|
163 |
|
|
RST_I => reset_I,
|
164 |
|
|
CLK_I => clk_port,
|
165 |
|
|
DAT_I => ctrl_dat_o_port,
|
166 |
|
|
DAT_O => ctrl_dat_i_port,
|
167 |
|
|
ADR_O => ctrl_adr_i_port,
|
168 |
|
|
CYC_O => ctrl_cyc_i_port,
|
169 |
|
|
STB_O => ctrl_stb_i_port,
|
170 |
|
|
ACK_I => ctrl_ack_o_port,
|
171 |
|
|
WE_O => ctrl_we_i_port
|
172 |
|
|
);
|
173 |
|
|
|
174 |
|
|
U_CTRL: ctrl
|
175 |
|
|
port map(
|
176 |
|
|
|
177 |
|
|
DAT_I_port => ctrl_dat_i_port,
|
178 |
|
|
DAT_O_port => ctrl_dat_o_port,
|
179 |
|
|
ADR_I_port => ctrl_adr_i_port(3 downto 0),
|
180 |
|
|
CYC_I_port => ctrl_cyc_i_port,
|
181 |
|
|
STB_I_port => ctrl_stb_i_port,
|
182 |
|
|
ACK_O_port => ctrl_ack_o_port,
|
183 |
|
|
WE_I_port => ctrl_we_i_port,
|
184 |
|
|
CLK_I_port => clk_port,
|
185 |
|
|
RST_I_port => reset_I,
|
186 |
|
|
|
187 |
|
|
DAT_I_daq => ctrl_dat_i_daq,
|
188 |
|
|
DAT_O_daq => ctrl_dat_o_daq,
|
189 |
|
|
ADR_O_daq => ctrl_adr_o_daq,
|
190 |
|
|
CYC_O_daq => ctrl_cyc_o_daq,
|
191 |
|
|
STB_O_daq => ctrl_stb_o_daq,
|
192 |
|
|
ACK_I_daq => ctrl_ack_i_daq,
|
193 |
|
|
WE_O_daq => ctrl_we_o_daq,
|
194 |
|
|
CLK_I_daq => clk_daq,
|
195 |
|
|
RST_I_daq => reset_I,
|
196 |
|
|
|
197 |
|
|
DAT_O_memw => ctrl_dat_o_memw,
|
198 |
|
|
ADR_O_memw => ctrl_adr_o_memw,
|
199 |
|
|
CYC_O_memw => ctrl_cyc_o_memw,
|
200 |
|
|
STB_O_memw => ctrl_stb_o_memw,
|
201 |
|
|
ACK_I_memw => ctrl_ack_i_memw,
|
202 |
|
|
WE_O_memw => ctrl_we_o_memw,
|
203 |
|
|
|
204 |
|
|
DAT_I_memr => ctrl_dat_i_memr,
|
205 |
|
|
ADR_O_memr => ctrl_adr_o_memr,
|
206 |
|
|
CYC_O_memr => ctrl_cyc_o_memr,
|
207 |
|
|
STB_O_memr => ctrl_stb_o_memr,
|
208 |
|
|
ACK_I_memr => ctrl_ack_i_memr,
|
209 |
|
|
WE_O_memr => ctrl_we_o_memr
|
210 |
|
|
);
|
211 |
|
|
|
212 |
|
|
U_DPORTMEM: dual_port_memory_wb
|
213 |
|
|
port map(
|
214 |
|
|
-- Puerto A (Higer prioriry)
|
215 |
|
|
RST_I_a => reset_I,
|
216 |
|
|
CLK_I_a => clk_daq,
|
217 |
|
|
DAT_I_a => ctrl_dat_o_memw,
|
218 |
|
|
DAT_O_a => open,
|
219 |
|
|
ADR_I_a => ctrl_adr_o_memw,
|
220 |
|
|
CYC_I_a => ctrl_cyc_o_memw,
|
221 |
|
|
STB_I_a => ctrl_stb_o_memw,
|
222 |
|
|
ACK_O_a => ctrl_ack_i_memw,
|
223 |
|
|
WE_I_a => ctrl_we_o_memw,
|
224 |
|
|
-- Puerto B (Lower prioriry)
|
225 |
|
|
RST_I_b => reset_I,
|
226 |
|
|
CLK_I_b => clk_port,
|
227 |
|
|
DAT_I_b => X"0000",
|
228 |
|
|
DAT_O_b => ctrl_dat_i_memr,
|
229 |
|
|
ADR_I_b => ctrl_adr_o_memr,
|
230 |
|
|
CYC_I_b => ctrl_cyc_o_memr,
|
231 |
|
|
STB_I_b => ctrl_stb_o_memr,
|
232 |
|
|
ACK_O_b => ctrl_ack_i_memr,
|
233 |
|
|
WE_I_b => ctrl_we_o_memr
|
234 |
|
|
);
|
235 |
|
|
|
236 |
|
|
U_PLL0: entity work.A3PE_pll_2clk
|
237 |
|
|
port map(
|
238 |
|
|
POWERDOWN => '0',
|
239 |
|
|
CLKA => pll_clk_I,
|
240 |
|
|
LOCK => open,
|
241 |
|
|
--SDIN => '0',
|
242 |
|
|
--SCLK => '0',
|
243 |
|
|
--SSHIFT => '0',
|
244 |
|
|
--SUPDATE => '0',
|
245 |
|
|
--MODE => '0',
|
246 |
|
|
GLA => clk_daq,
|
247 |
|
|
GLB => clk_port
|
248 |
|
|
--SDOUT => open
|
249 |
|
|
);
|
250 |
|
|
|
251 |
|
|
end architecture;
|
252 |
|
|
|