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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [System09_Xess_XuLA/] [ptm6840.vhd] - Blame information for rev 139

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 122 dilbert57
--===========================================================================--
2
--                                                                           --
3
--      ptm6840.vhd - Synthesizable Programmable Timer Module                --
4
--                                                                           --
5
--===========================================================================--
6
--
7
--  File name      : ptm6840.vhd
8
--
9
--  Purpose        : Programmable Timer Module for SystemXX
10
-- 
11
--  Dependencies   : ieee.std_logic_1164
12
--                   ieee.std_logic_unsigned
13
--                   unisim.vcomponents
14
--
15
--  Author         : John E. Kent
16
--
17
--  Email          : dilbert57@opencores.org      
18
--
19
--  Web            : http://opencores.org/project,system09
20
--
21
--
22
--  RS2 RS1 RS0 RW=0                          RW=1
23
--  === === === ============================= ========================
24
--   0   0   0  CR20 = 0 Write Control Reg #3 No Operation
25
--              CR20 = 1 Write Control Reg #1
26
--   0   0   1  Write Control Reg 2           Read Status Register
27
--   0   1   0  Write MSB Buffer Register     Read Timer #1 Counter
28
--   0   1   1  Write Timer #1 Latches        Read LSB Buffer Register
29
--   1   0   0  Write MSB Buffer Register     Read Timer #2 Counter
30
--   1   0   1  Write Timer #2 Latches        Read LSB Buffer Register
31
--   1   1   0  Write MSB Buffer Register     Read Timer #3 Counter
32
--   1   1   1  Write Timer #3 Latches        Read LSB Buffer Register
33
--
34
--  Control Register CRXX
35
--  Bit  =0                             =1
36
--  ==== ============================== ===============================
37
--  CRX7 TX output masked on output Ox  TX Output enabled on output OX
38
--  CRX6 Interrupt Flag masked on IRQ*  Interrupt Flag enabled to IRQ*
39
--  CRX5
40
--  CRX4
41
--  CRX3
42
--  CRX2 TX normal (16 bit) counting    TX dual 8 bit counting mode
43
--  CRX1 TX uses external clock on CX   TX uses enable clock
44
--  CR10 All Timers allowed to operate  All timers held in preset state
45
--  CR20 CR3X May be written            CRX1 may be written
46
--  CR30 T3 Clock is not prescaled      T3 clock is prescaled by 8
47
--
48
--  CRX5 CRX4 CRX3 Operating Mode
49
--  ==== ==== ==== ====================================================
50
--   0    0    0   Continuous: Gate -\_ or Write Latches or Reset initializes
51
--   0    0    1   Freq Compare: Interrupt if Gate \_/-\ is < Counter Timeout
52
--   0    1    0   Continuous: Gate -\_ or Reset causes counter initialization
53
--   0    1    1   Pulse Width Compare: Interrupt if Gate \_/ is < Counter Timeout
54
--   1    0    0   Single Shot: Gate -\_ or Write latches or reset initializes counter
55
--   1    0    1   Freq Compare: Interrupt if Gate \_/-\ is > Counter Timeout
56
--   1    1    0   Single Shot: Gate -\_ or or reset initializes counter
57
--   1    1    1   Pulse Width Compare: Interrupt if Gate \_/ is > Counter Timeout
58
--
59
--   0    X    0   Continuous
60
--   1    X    0   Single Shot
61
--   X    0    0   Gate_n -\_   or Write latches
62
--   X    0    1   Gate_n \_/-\ Frequency Comparison
63
--   X    1    0   Gate_n  -\_  or Reset initializes counter
64
--   X    1    1   Gate_n \_/   Pulse Width Comparison
65
--
66
--  G_N-\_ negative transition of gate input
67
--  G_N_/- positive transition of gate input
68
--  W      write timer latch command
69
--  R      reset timer (CR10=1 or rst=1)
70
--  CE     Counter enable flip flop
71
--  CI     Counter Initialization
72
--  TO     time out (all zero condition)
73
--  I      interrupt for a given timer
74
--  assume G_N and C_N are synchonized to the cpu clock
75
--
76
--  Continuous mode
77
--  ===============
78
--  (CRX7=1, CRX5=0, CRX3=0)
79
--  IX=1 when (TO=1) when M = L = 0 or N = 0
80
--  CRX4=0 
81
--  CI=1 when G_N-\_ or (R=1) or (W=1)
82
--  CRX4=1 
83
--  CI=1 when G_N-\_ or (R=1)
84
--
85
--  16 bit mode (CRX2=0)
86
--  OX = low  for (N+1)*(T)
87
--  TO at (N+1)*(T)
88
--  OX = high for (N+1)*(T)
89
--  TO at (N+1)*(T)
90
--  
91
--  Dual 8 Bit Mode (CRX2=1)
92
--  OX = low  for ((L)*(M+1)+1)*(T)
93
--  OX = high for (L)*(T)
94
--  TO at (L+1)*(M+1)*(T) => OX = low
95
--  OX = low  for ((L)*(M+1)+1)*(T)
96
--  OX = high for (L)*(T)
97
--  TO at (L+1)*(M+1)*(T) => OX = low
98
-- 
99
--  eg. If M = 3 and L = 4 and T=enables
100
--  OX = low  for 3*(4+1)+1 = 16 enables
101
--  OX = high for 4 enables
102
--
103
--  Single shot mode
104
--  ================
105
--  (CRX7=1, CRX5=1, CRX3=0)
106
--  CRX4=0 
107
--  CI=1 when G_N-\_ or (R=1) or (W=1)
108
--  CRX4=1 
109
--  CI=1 when G_N-\_ or (R=1)
110
--
111
--  16 bit mode (CRX2=0)
112
--  OX = low  for     (T)
113
--  OX = high for (N)*(T)
114
--  TO at (N+1)*(T) => OX = low
115
--  TO at (N+1)*(T) => OX = low
116
--
117
--  Dual 8 bit mode (CRX2=1)
118
--  OX = low  for ((L)*(M+1)+1)*(T)
119
--  OX = high for  (L)         *(T)
120
--  TO at (L+1)*(M+1)*(T) => OX = low
121
--  TO at (L+1)*(M+1)*(T) => OX = low
122
--
123
--  Frequency Comparison mode
124
--  =========================
125
--  (CRX4=0, CRX3=1)
126
--  CE=1 when G_N-\_ and (I=0) and (W=0) and (R=0)
127
--  CE=0 when            (I=1) or  (W=1) or  (R=1)
128
--
129
--  CRX5=0 
130
--  CI=1 when G_N-\_ and (I=0) and ((CE=0) or (TO=1)) or (R=0)
131
--  IX=1 when G_N-\_ before TO
132
--
133
--  CRX5=1 
134
--  CI=1 when G_N-\_ and (I=0) or  (R=0)
135
--  IX=1 when G_N-\_ after  TO
136
--
137
--  Pulse Width Comparison Mode
138
--  ===========================
139
--  (CRX4=1, CRX3=1)
140
--  CI=1 when G_N-\_ and (I=0) or  (R=0)
141
--  CE=1 when G_N-\_ and (I=0) and (W=0) and (R=0)
142
--  CE=0 when (G_N=1)  or  (I=1) or  (W=1) or  (R=1)
143
--           
144
--  CRX5=0
145
--  IX=1 when G_N_/- before TO
146
--
147
--  CRX5=1   
148
--  IX=1 when G_N_/- after TO
149
--
150
--  Status Register
151
--  ===============
152
--  SR7 INT = (I1.CR16) + (I2.CR26) + (I3.CR36)
153
--  SR6 0
154
--  SR5 0
155
--  SR4 0
156
--  SR3 0
157
--  SR2 I3
158
--  SR1 I2
159
--  SR0 I1
160
--
161
--  Interrupts are reset by a reset condition (R) RST = 1, CR10 = 1 or
162
--  Read Status Register (RS) followed by a Read Timer (RTX) Command
163
--  provided the interrupt (IX) is set when the Status Register is read
164
--  and the timer (TX) corresponding to the particular interrupt is read
165
--  or a write timer register (W) or a counter initialization (CI).
166
--
167
--  Copyright (C) 2011 John Kent
168
--
169
--  This program is free software: you can redistribute it and/or modify
170
--  it under the terms of the GNU General Public License as published by
171
--  the Free Software Foundation, either version 3 of the License, or
172
--  (at your option) any later version.
173
--
174
--  This program is distributed in the hope that it will be useful,
175
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
176
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
177
--  GNU General Public License for more details.
178
--
179
--  You should have received a copy of the GNU General Public License
180
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
181
--
182
--===========================================================================--
183
--                                                                           --
184
--                              Revision  History                            --
185
--                                                                           --
186
--===========================================================================--
187
--
188
-- Version  Author        Date           Description
189
-- 0.1      John E. Kent  1 May 2011     Initial version
190
-- 
191
--===========================================================================
192
--
193
 
194
library ieee;
195
  use ieee.std_logic_1164.all;
196
  use ieee.std_logic_unsigned.all;
197
--library unisim;
198
--  use unisim.vcomponents.all;
199
 
200
entity ptm6840 is
201
  port (
202
    clk       : in    std_logic;
203
    rst       : in    std_logic;
204
    cs        : in    std_logic;
205
    rw        : in    std_logic;
206
    addr      : in    std_logic_vector(1 downto 0);
207
    data_in   : in    std_logic_vector(7 downto 0);
208
    data_out  : out   std_logic_vector(7 downto 0);
209
    irq       : out   std_logic;
210
    tclk_n    : in    std_logic_vector(2 downto 0);  -- Timer Clock Inputs
211
    tgate_n   : in    std_logic_vector(2 downto 0);  -- Timer Gate inputs
212
    tout      : out   std_logic_vector(2 downto 0)   -- Timer Outputs
213
  );
214
end;
215
 
216
architecture rtl of ptm6840 is
217
 
218
signal porta_ddr : std_logic_vector(7 downto 0);
219
signal portb_ddr : std_logic_vector(7 downto 0);
220
signal porta_data : std_logic_vector(7 downto 0);
221
signal portb_data : std_logic_vector(7 downto 0);
222
 
223
begin
224
 
225
end rtl;

powered by: WebSVN 2.1.0

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