OpenCores
URL https://opencores.org/ocsvn/ffr16/ffr16/trunk

Subversion Repositories ffr16

[/] [ffr16/] [branches/] [APERT/] [rtl/] [050803kn/] [cf_package.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 armando
--===========================================================================--
2
-- 
3
-- COMPACT FLASH MODULES PACKAGE
4
--
5
--  - DECEMBER 2002
6
--  - UPV / EHU.  
7
--
8
--  - APPLIED ELECTRONICS RESEARCH TEAM (APERT)-
9
--  DEPARTMENT OF ELECTRONICS AND TELECOMMUNICATIONS - BASQUE COUNTRY UNIVERSITY
10
--
11
-- THIS CODE IS DISTRIBUTED UNDER :
12
-- OpenIPCore Hardware General Public License "OHGPL" 
13
-- http://www.opencores.org/OIPC/OHGPL.shtml
14
--
15
-- Design units   : COMPACT FLASH TOOLS
16
--
17
-- File name      : cf_package.vhd
18
--
19
-- Purpose        : 
20
--                  
21
-- Library        : WORK
22
--
23
-- Dependencies   : IEEE.Std_Logic_1164
24
--
25
-- Simulator      : ModelSim SE version 5.5e on a WindowsXP PC
26
--===========================================================================--
27
-------------------------------------------------------------------------------
28
-- Revision list
29
-- Version   Author                 Date           Changes
30
--
31
-- 031202     Armando Astarloa     03 December                  First release
32
-- 070103         Armando Astarloa        07    January                 Added cf_emulator component
33
--                                                                                                                                                               procedure write_to_controller
34
--                                                                                                                                                               function read_from_controller                  
35
--                                                                                                                                                               Included address 0 for wb bus
36
-- 090103               Armando Astarloa          07    January                 Changes DAT_O to DAT_I_O in 
37
--                                                                                                                                              cf_sector_reader
38
-- 100103               Armando Astarloa          10    January                 Bug in fuction read from controller
39
-- 140103               Armando Astarloa          14    January                 Added read_from_the_fat32 procedure
40
-- 240603               Armando Astarloa          24    June                            Quit soft reset signals (with kcpsm 
41
--                                                                                                                                              v.1002)
42
--
43
-------------------------------------------------------------------------------
44
-- Description    : 
45
--                  
46
-------------------------------------------------------------------------------
47
-- Entity for cf_package Unit                                                     --
48
-------------------------------------------------------------------------------
49
library IEEE;
50
use IEEE.STD_LOGIC_1164.ALL;
51
use IEEE.STD_LOGIC_ARITH.ALL;
52
use IEEE.STD_LOGIC_UNSIGNED.ALL;
53
 
54
package cf_package is
55
 
56
component cf_fat32_reader is
57
    Port (
58
                                --
59
                                -- WISHBONE SIGNALS
60
                                --
61
                                RST_I:  in  std_logic;                                                                                                          -- WB : Global RESET signal
62
                        CLK_I:  in  std_logic;                                                                                                          -- WB : Global bus clock
63
 
64
                                --
65
                                -- MASTER INTERFACE
66
                                --
67
                                ACK_I_M:  in std_logic;                                                                                                         -- WB : Ack from the slave
68
            ADR_O_M:  out  std_logic;                                                                                                   -- WB : Register selection
69
            DAT_M:  inout  std_logic_vector(15 downto 0 );                                               -- WB : 16 bits data bus input
70
            STB_O_M:  out std_logic;                                                                                                    -- WB : Access request to the slave
71
            WE_O_M:   out  std_logic;                                                                                                   -- WB : Read/write request to the slave
72
                                TAG0_ERROR_I_M: in  std_logic;
73
                                --
74
                                -- SLAVE INTERFACE
75
                                --
76
 
77
                                ACK_O_S:  out std_logic;                                                                                                                -- WB : Ack to the master
78
--          ADR_I:  in  std_logic_vector(1 downto 0 );                                                  -- WB : Register selection
79
            DAT_O_S:  out  std_logic_vector(15 downto 0 );                                               -- WB : 16 bits data bus input
80
            STB_I_S:  in  std_logic;                                                                                                    -- WB : Access qualify from master
81
            WE_I_S:   in  std_logic;                                                                                                    -- WB : Read/write request from master
82
                                TAG0_WORD_AVAILABLE_O_S:  out  std_logic;
83
                                TAG1_ERROR_O_S:  out  std_logic                                                                                 -- Error on cf access
84
 
85
 
86
                                );
87
end component;
88
component cf_fat16_reader is
89
    Port (
90
                                --
91
                                -- WISHBONE SIGNALS
92
                                --
93
                                RST_I:  in  std_logic;                                                                                                          -- WB : Global RESET signal
94
                        CLK_I:  in  std_logic;                                                                                                          -- WB : Global bus clock
95
 
96
                                --
97
                                -- MASTER INTERFACE
98
                                --
99
                                ACK_I_M:  in std_logic;                                                                                                         -- WB : Ack from the slave
100
            ADR_O_M:  out  std_logic;                                                                                                   -- WB : Register selection
101
            DAT_M:  inout  std_logic_vector(15 downto 0 );                                               -- WB : 16 bits data bus input
102
            STB_O_M:  out std_logic;                                                                                                    -- WB : Access request to the slave
103
            WE_O_M:   out  std_logic;                                                                                                   -- WB : Read/write request to the slave
104
                                TAG0_ERROR_I_M: in  std_logic;
105
                                --
106
                                -- SLAVE INTERFACE
107
                                --
108
 
109
                                ACK_O_S:  out std_logic;                                                                                                                -- WB : Ack to the master
110
--          ADR_I:  in  std_logic_vector(1 downto 0 );                                                  -- WB : Register selection
111
            DAT_O_S:  out  std_logic_vector(15 downto 0 );                                               -- WB : 16 bits data bus input
112
            STB_I_S:  in  std_logic;                                                                                                    -- WB : Access qualify from master
113
            WE_I_S:   in  std_logic;                                                                                                    -- WB : Read/write request from master
114
                                TAG0_WORD_AVAILABLE_O_S:  out  std_logic;
115
                                TAG1_ERROR_O_S:  out  std_logic                                                                                 -- Error on cf access
116
 
117
                                );
118
end component;
119
 
120
--
121
-- RAW SECTORS READER
122
--
123
 
124
component cf_sector_reader is
125
    Port (
126
                                --
127
                                -- WISHBONE SIGNALS
128
                                --
129
                                RST_I:  in  std_logic;                                                                                                          -- WB : Global RESET signal
130
                                ACK_O:  out std_logic;                                                                                                          -- WB : Ack to the master
131
                ADR_I:  in  std_logic;                                                                                                  -- WB : Register selection
132
            CLK_I:  in  std_logic;                                                                                                              -- WB : Global bus clock
133
            DAT_I_O:  inout  std_logic_vector(15 downto 0 );                                             -- WB : 16 bits data bus input
134
            STB_I:  in  std_logic;                                                                                                              -- WB : Access qualify from master
135
            WE_I:   in  std_logic;                                                                                                              -- WB : Read/write request from master
136
                                TAG0_WORD_AVAILABLE:  out  std_logic;                                                                   -- 
137
                                TAG1_WORD_REQUEST:  in  std_logic;                                                                              -- IDE : Write Strobe
138
 
139
                                --
140
                                -- NON WISHBONE SIGNALS
141
                                --
142
                                IDE_BUS: inout  std_logic_vector(15 downto 0 );                                  -- IDE DATA bidirectional bus
143
 
144
                                NIOWR:  out  std_logic;                                                                                                         -- IDE : Write Strobe
145
                                NIORD:  out  std_logic;                                                                                                         -- IDE : Read Strobe
146
                           NCE1:  out  std_logic;                                                                                                               -- IDE : CE1
147
                                NCE0:  out  std_logic;                                                                                                          -- IDE : CE2
148
                                A2:  out  std_logic;                                                                                                                    -- IDE : Address bit 2
149
                                A1:  out  std_logic;                                                                                                                    -- IDE : Address bit 1
150
                                A0:  out  std_logic;                                                                                                                    -- IDE : Address bit 0
151
 
152
                                ERROR:  out  std_logic                                                                                                          -- Error on cf access
153
                                );
154
end component;
155
--
156
-- COMPACT FLASH EMULATOR
157
--
158
 
159
component cf_emulator
160
    Port (
161
                                --
162
                                -- GLOBAL INPUTS
163
                                --
164
                                CLK_I:  in  std_logic;                                                                                                          -- GLOBAL CLOCK
165
                                RST_I:  in  std_logic;                                                                                                          -- GLOBAL RESET
166
                                --
167
                                -- IDE BUS
168
                                --
169
                                IDE_BUS: inout  std_logic_vector(15 downto 0 );                                  -- IDE DATA bidirectional bus
170
 
171
                                NIOWR:  in  std_logic;                                                                                                          -- IDE : Write Strobe
172
                                NIORD:  in  std_logic;                                                                                                          -- IDE : Read Strobe
173
                           NCE1:  in  std_logic;                                                                                                         -- IDE : CE1
174
                                NCE0:  in  std_logic;                                                                                                            -- IDE : CE2
175
                                A2:  in  std_logic;                                                                                                                     -- IDE : Address bit 2
176
                                A1:  in  std_logic;                                                                                                                     -- IDE : Address bit 1
177
                                A0:  in  std_logic;                                                                                                                     -- IDE : Address bit 0
178
 
179
                                ERROR:  out  std_logic;                                                                                                         -- Error on cf access
180
                                RESET:  in  std_logic                                                                                                           -- Force reset
181
                                );
182
end component;
183
 
184
--
185
-- FUNCTIONS AND PROCEDURES
186
--
187
                --
188
                -- WRITE DATA TO THE CONTROLLER (SECTOR READER)
189
                --
190
                        procedure write_to_the_controller(signal CLK_I,ADR_I,ACK_O : in std_logic;
191
                                                                                                                                signal STB_I,WE_I : out std_logic;
192
                                                                                                                                signal DAT_O : out std_logic_vector (15 downto 0);
193
                                                                                                                                signal data_to_controller : in std_logic_vector (15 downto 0));
194
 
195
                --
196
                -- READ DATA FROM THE CONTROLLER (SECTOR READER)
197
                --
198
                procedure read_from_the_controller(signal CLK_I,ADR_I,ACK_O : in std_logic;
199
                                                                                                                                signal STB_I,WE_I: out std_logic;
200
                                                                                                                                signal DAT_O : in std_logic_vector (15 downto 0);
201
                                                                                                                                signal read_from_the_controller : out std_logic_vector (15 downto 0));
202
                --
203
                -- READ DATA FROM THE FAT32 PROCESSOR (FILE READER)
204
                --
205
                procedure read_from_the_fat32(signal CLK_I,ACK_O : in std_logic;
206
                                                                                                                                signal STB_I,WE_I: out std_logic;
207
                                                                                                                                signal DAT_O : in std_logic_vector (15 downto 0);
208
                                                                                                                                signal read_from_the_fat32 : out std_logic_vector (15 downto 0));
209
 
210
 
211
end package cf_package;
212
 
213
library IEEE;
214
use IEEE.std_logic_1164.all;
215
use IEEE.numeric_std.all;
216
 
217
 
218
package body cf_package is
219
 
220
                --
221
                -- WRITE DATA TO THE CONTROLLER
222
                --
223
                procedure write_to_the_controller(signal CLK_I,ADR_I,ACK_O : in std_logic;
224
                                                                                                                                signal STB_I,WE_I : out std_logic;
225
                                                                                                                                signal DAT_O : out std_logic_vector (15 downto 0);
226
                                                                                                                                signal data_to_controller : in std_logic_vector (15 downto 0)) is
227
                        begin
228
                                STB_I <= '1';
229
                                WE_I <= '1';
230
                                DAT_O <= data_to_controller;
231
                                -- wait till the ack
232
                                wait until rising_edge(ACK_O);
233
                                -- operate synchronously
234
                                -- wait until rising_edge(CLK_I);
235
                                STB_I <= '0';
236
                                WE_I <= '0';
237
                                --
238
                                -- thatīs not correct because
239
                                -- in Wishbone Specification
240
          -- WISHBONE MASTER MUST CHECK ACK SIGNAL
241
               --IN THE RISING EDGE OF THE CLOCK AND DEASSERT 
242
                     --  STROBE SIGNAL. SLAVE AUTOMATICALLY DEASSERT ACK
243
                                wait until falling_edge(ACK_O);
244
                                wait until rising_edge(CLK_I);
245
                                -- end write-cycle
246
                end write_to_the_controller;
247
 
248
                --
249
                -- READ DATA FROM THE CONTROLLER
250
                --
251
                procedure read_from_the_controller(signal CLK_I,ADR_I,ACK_O : in std_logic;
252
                                                                                                                                signal STB_I,WE_I: out std_logic;
253
                                                                                                                                signal DAT_O : in std_logic_vector (15 downto 0);
254
                                                                                                                                signal read_from_the_controller : out std_logic_vector (15 downto 0)) is
255
 
256
                        begin
257
                                STB_I <= '1';
258
                                WE_I <= '0';
259
                                -- wait till the ack
260
                                wait until rising_edge(ACK_O);
261
                                read_from_the_controller <= DAT_O;
262
                                -- operate synchronously
263
                                wait until rising_edge(CLK_I);
264
                                STB_I <= '0';
265
                                WE_I <= '0';
266
                                -- end read-cycle
267
                end;
268
                --
269
                -- READ DATA FROM THE FAT32 PROCESSOR
270
                --
271
                procedure read_from_the_fat32(signal CLK_I,ACK_O : in std_logic;
272
                                                                                                                                signal STB_I,WE_I: out std_logic;
273
                                                                                                                                signal DAT_O : in std_logic_vector (15 downto 0);
274
                                                                                                                                signal read_from_the_fat32 : out std_logic_vector (15 downto 0)) is
275
 
276
                        begin
277
                                STB_I <= '1';
278
                                WE_I <= '0';
279
                                -- wait till the ack
280
                                wait until rising_edge(ACK_O);
281
                                read_from_the_fat32 <= DAT_O;
282
                                -- operate synchronously
283
                                wait until rising_edge(CLK_I);
284
                                STB_I <= '0';
285
                                WE_I <= '0';
286
                                -- end read-cycle
287
                end;
288
 
289
end package body cf_package;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.