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

Subversion Repositories eus100lx

[/] [eus100lx/] [trunk/] [fpga/] [ios/] [ios.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 freza
-- Copyright (C) 2004 DSP&FPGA
2
-- Author: SaVa <s.valach@dspfpga.com>
3
--
4
-- This program is free software; you can redistribute it and/or
5
-- modify it under the terms of the OpenIPCore Hardware General Public
6
-- License as published by the OpenIPCore Organization; either version
7
-- 0.20-15092000 of the License, or (at your option) any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY; without even the implied warranty of
11
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-- OpenIPCore Hardware General Public License for more details.
13
--
14
-- You should have received a copy of the OpenIPCore Hardware Public
15
-- License along with this program; if not, download it from
16
-- OpenCores.org (http://www.opencores.org/OIPC/OHGPL.shtml).
17
 
18
 
19
library IEEE;
20
use IEEE.STD_LOGIC_1164.ALL;
21
use IEEE.STD_LOGIC_ARITH.ALL;
22
use IEEE.STD_LOGIC_UNSIGNED.ALL;
23
 
24
library unisim;
25
use unisim.vcomponents.all;
26
 
27
 
28
Entity eus_100lx is
29
Generic(
30
      E_DATA_WIDTH   : integer :=   32);
31
Port(
32
      SDRCLKF        : in     std_logic;                       -- Etrax clocks (50MHz)
33
      RESET          : in     std_logic;                       -- Global reset
34
-- ETRAX Bus
35
      DREQ0          : out    std_logic;                       -- DMA Request (Active high)
36
      DACK0          : in     std_logic;                       -- DMA ACK (Active high)
37
      IRQ            : out    std_logic;                       -- Active low
38
--- Bus signals
39
      D              : inout  std_logic_vector(E_DATA_WIDTH - 1 downto 0);
40
      A              : in     std_logic_vector(22 downto 2);
41
      CSR0           : in     std_logic;                       -- FPGA Programming
42
      CSR1           : in     std_logic;                       -- LCD Data channel
43
      CSP0           : in     std_logic;                       -- Internal Registers, control and status
44
      CSP4           : in     std_logic;                       -- Reserved
45
      RD             : in     std_logic;                       -- Etrax reads
46
      WR             : in     std_logic_vector(3 downto 0);    -- Etrax writes
47
-- USERIOs
48
      LEDX           : out    std_logic_vector(1 downto 0);    -- Leds
49
      X              : inout  std_logic_vector(87 downto 0);   -- Generic IOs
50
      ISAEN          : out    std_logic;                       -- 
51
-- LCD Outputs   / Generic In/Out 
52
      Y              : out    std_logic_vector(28 downto 0);
53
-- Dedicated SDRAM
54
      SD             : inout  std_logic_vector(15 downto 0);   -- Data Bus
55
      SA             : out    std_logic_vector(0 to 14);       -- Address and BA signals
56
      SRAS           : out    std_logic;                       -- SDRAM ras
57
      SCAS           : out    std_logic;                       -- SDRAM cas
58
      SCS            : out    std_logic;
59
      SCLK           : out    std_logic;
60
      SCKE           : out    std_logic;
61
      SDQMH          : out    std_logic;
62
      SDQML          : out    std_logic;
63
      SWE            : out    std_logic
64
      );
65
 
66
end eus_100lx;
67
 
68
architecture behav of eus_100lx is
69
 
70
-- Components Declarations
71
 
72
-- Clocks distribution
73
 
74
Component CLK_GEN
75
Generic (
76
      ACTIVE_RST     : std_logic := '1';
77
      CLK_M_RATIO    : integer := 2;
78
      CLK_D_RATIO    : integer := 2;
79
      CLK_DIV_RATIO  : real := 10.0;          -- LCD divider
80
      POWER_UP_T     : integer := 20           -- Clk numbers - should be 200ms, for sim is shorter 
81
      );
82
Port (
83
-- Clocks & Resets
84
      CLK_IN      : in     std_logic;
85
      CLK_FB      : in     std_logic;
86
      RESET_IN    : in     std_logic;
87
      RESET_OUT   : out    std_logic;
88
      CLK         : out    std_logic;        -- System Clock
89
      SD_CLK_I    : out    std_logic;        -- Internal SDRAM Clock
90
      SD_CLK      : out    std_logic;        -- SDRAM Clock     
91
      LCD_CLK_I   : out    std_logic;        -- Internal Clock for LCD controller, usually CLK divided by 16 - see M/D ratio 
92
      POWER_UP    : out    std_logic         -- SDRAM Initial time after stable CLK
93
);
94
End Component;
95
 
96
component pb_irc
97
  Port (
98
   BRAM_DATA    : in    std_logic_vector(17 downto 0);
99
   BRAM_ADDR    : in    std_logic_vector(9 downto 0);
100
   BRAM_EN      : in    std_logic;
101
   PB_RST       : in    std_logic;
102
   counter      : out   std_logic_vector(7 downto 0);
103
   waveforms    : out   std_logic_vector(7 downto 0);
104
   interrupt_event    : in    std_logic;
105
   clk          : in    std_logic);
106
end component;
107
 
108
--
109
 
110
constant zeros       : std_logic_vector(15 downto 0) := (Others => '0');
111
constant dist_ram_wd : integer := E_DATA_WIDTH;
112
 
113
-- LOW/HIGH definition
114
signal low           : std_logic := '0';
115
signal high          : std_logic := '1';
116
 
117
-- SDRCLKF_internal
118
signal sdrclkf_i     : std_logic;
119
signal lcd_clk_i     : std_logic;
120
signal rst           : std_logic;
121
signal dreq0_i       : std_logic;
122
 
123
-- Sampled signals by SDRCLKF
124
signal d_in          : std_logic_vector(E_DATA_WIDTH - 1 downto 0);
125
signal a_i           : std_logic_vector(22 downto 2);
126
signal csr0_i        : std_logic := '1';
127
signal csr1_i        : std_logic := '1';
128
signal csp0_i        : std_logic := '1';
129
signal csp4_i        : std_logic := '1';
130
signal rd_i          : std_logic := '1';
131
signal wr_i          : std_logic_vector(3 downto 0) := "1111";
132
signal dack0_i       : std_logic := '0';
133
 
134
signal wr_i_p        : std_logic_vector(3 downto 0) := "0000";
135
 
136
-- Access control - active high
137
signal sel_wr_0      : std_logic;
138
signal sel_wr_1      : std_logic;
139
signal sel_wr_2      : std_logic;
140
 
141
signal csp0_rd       : std_logic;
142
signal sel_rd_0      : std_logic;
143
signal sel_rd_1      : std_logic;
144
signal sel_rd_2      : std_logic;
145
 
146
-- Control Section
147
signal reg_0         : std_logic_vector(31 downto 0) := x"11111110";                -- Defaul values
148
signal reg_1         : std_logic_vector(31 downto 0) := x"22222222";
149
signal reg_2         : std_logic_vector(31 downto 0) := x"33333333";
150
 
151
signal sys_cnt       : std_logic_vector(31 downto 0) := (Others => '0');
152
 
153
signal d_out         : std_logic_vector(31 downto 0);
154
 
155
signal led_blink_cnt : std_logic_vector(22 downto 0);
156
 
157
signal sd_clk_i      : std_logic;
158
 
159
signal usr_inp       : std_logic_vector(7 downto 0);
160
signal usr_inp_i     : std_logic_vector(7 downto 0);
161
signal usr_inp_ii    : std_logic_vector(7 downto 0);
162
 
163
BEGIN
164
 
165
-- XX_OFUB workaround ISE7.1
166
DREQ0    <= 'Z';
167
IRQ      <= 'Z';
168
X        <= (Others => 'Z');
169
Y        <= (Others => 'Z');
170
SD       <= (Others => 'Z');
171
SA       <= (Others => 'Z');
172
SRAS     <= 'Z';
173
SCAS     <= 'Z';
174
SCS      <= 'Z';
175
SCLK     <= 'Z';
176
SCKE     <= 'Z';
177
SDQMH    <= 'Z';
178
SDQML    <= 'Z';
179
SWE      <= 'Z';
180
 
181
-- Windows size for write are 64kB
182
sel_wr_0 <= '1' When (csp0_i = '0') And (a_i(22 downto 16) = "0000000") Else '0';       -- Base Address = CSP0 + 0x00000   
183
sel_wr_1 <= '1' When (csp0_i = '0') And (a_i(22 downto 16) = "0000001") Else '0';      -- Base Address = CSP0 + 0x10000
184
sel_wr_2 <= '1' When (csp0_i = '0') And (a_i(22 downto 16) = "0000010") Else '0';      -- Base Address = CSP0 + 0x20000
185
 
186
-- Selectors without resample - used for dir control read/write
187
csp0_rd <= '1' When (CSP0 = '0') And (RD = '0') Else '0';                              -- Read selector for CSP0
188
--Windows size for read are 64kB
189
sel_rd_0 <= '1' When (csp0_rd = '1') And (A(22 downto 16) = "0000000") Else '0';        -- Base Address = CSP0 + 0x00000
190
sel_rd_1 <= '1' When (csp0_rd = '1') And (A(22 downto 16) = "0000001") Else '0';       -- Base Address = CSP0 + 0x10000
191
sel_rd_2 <= '1' When (csp0_rd = '1') And (A(22 downto 16) = "0000010") Else '0';       -- Base Address = CSP0 + 0x20000
192
 
193
-- Components mapping    
194
CLK_GENERATION : CLK_GEN
195
Port map(
196
   CLK_IN      => SDRCLKF,             -- Etrax's Clock (50MHz)
197
   CLK_FB      => low,                 -- SDRAM Feadback
198
   RESET_IN    => low,                 -- Global reset
199
   RESET_OUT   => rst,
200
   CLK         => sdrclkf_i,           -- Internal system Clock
201
   SD_CLK_I    => sd_clk_i,            -- Internal SDRAM Clock
202
   SD_CLK      => open,                -- SDRAM Clock     
203
   LCD_CLK_I   => lcd_clk_i,           -- Internal Clock for LCD controller, usually CLK divided by 8 see divide ratio 
204
   POWER_UP    => open                 -- SDRAM Initial time after stable CLK
205
);
206
 
207
-- write enable
208
wr_i_p <= Not wr_i;
209
--
210
 
211
RESAMPLE_IN : PROCESS(sdrclkf_i, D, A, CSR0, CSR1, CSP0, CSP4, RD, WR, DACK0)
212
BEGIN
213
   If sdrclkf_i'event And sdrclkf_i = '1' Then
214
      d_in <= D;
215
      a_i <= A;
216
      csr0_i <= CSR0;
217
      csr1_i <= CSR1;
218
      csp0_i <= CSP0;
219
      csp4_i <= CSP4;
220
      rd_i <= RD;
221
      wr_i <= WR;
222
      dack0_i <= DACK0;
223
   End If;
224
END PROCESS;
225
 
226
PROCESS(sdrclkf_i)
227
BEGIN
228
   If sdrclkf_i'event And sdrclkf_i = '1' Then
229
      If (sel_wr_0 = '1') And (wr_i(3) = '0') Then
230
         Case a_i(15 downto 2) is
231
            When "00000000000000" =>
232
               reg_0 <= d_in;
233
            When "00000000000001" =>
234
               reg_1 <= d_in;
235
            When "00000000000010" =>
236
               reg_2 <= d_in;
237
            When Others => NULL;
238
         End Case;
239
      End If;
240
   End If;
241
END PROCESS;
242
 
243
RESAMPLE_USER_IN : PROCESS(sdrclkf_i)
244
BEGIN
245
   If sdrclkf_i'event And sdrclkf_i = '1' Then
246
      usr_inp_i  <= usr_inp;
247
      usr_inp_ii <= usr_inp_i;
248
   End If;
249
END PROCESS;
250
 
251
d_out <= reg_0 When A(15 downto 2) = "00000000000000" Else
252
         reg_1 When A(15 downto 2) = "00000000000001" Else
253
         reg_2;
254
 
255
X(7 downto 0) <= reg_0(7 downto 0);             -- User outputs
256
usr_inp <= X(15 downto 8);                      -- User inputs
257
 
258
D <= d_out When sel_rd_0 = '1' Else
259
     sys_cnt When sel_rd_1 = '1' Else
260
     x"123456" & usr_inp_ii When sel_rd_2 = '1' Else
261
     (Others => 'Z');
262
 
263
ISAEN <= '1'; -- Enable "ISA ios"
264
 
265
LED_BLINK: PROCESS(sdrclkf_i, led_blink_cnt)
266
BEGIN
267
   If sdrclkf_i'event And sdrclkf_i = '1' Then
268
      led_blink_cnt <= led_blink_cnt + 1;
269
   End If;
270
END PROCESS;
271
 
272
PROCESS(sdrclkf_i)
273
BEGIN
274
   If sdrclkf_i'event And sdrclkf_i = '1' Then
275
      sys_cnt <= sys_cnt + 1;
276
   End If;
277
END PROCESS;
278
 
279
LEDX <= Not (led_blink_cnt(led_blink_cnt'high) & usr_inp(0));
280
 
281
end behav;

powered by: WebSVN 2.1.0

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