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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [VHDL/] [epp.vhd] - Blame information for rev 99

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 99 davidgb
--===========================================================================--
2
--                                                                           --
3
--                 Synthesizable Enhance Parallel Port                       --
4
--                                                                           --
5
--===========================================================================--
6
--
7
--  File name      : epp.vhd
8
--
9
--  Entity name    : epp
10
--
11
--  Purpose        : Implements an Enhanced Parallel Port Interface
12
--                  
13
--  Dependencies   : ieee.std_logic_1164
14
--                   ieee.std_logic_unsigned
15
--                   unisim.vcomponents
16
--
17
--  Author         : John E. Kent
18
--
19
--  Email          : dilbert57@opencores.org      
20
--
21
--  Web            : http://opencores.org/project,system09
22
--
23
--  Description    : Register Memory Map
24
--
25
--  Address                              MSB                         LSB
26
--                                   Bit:    7   6   5   4   3   2   1   0
27
--  Base+$00 (SPP Data port)    Write Pin:   9   8   7   6   5   4   3   2
28
--  Base+$01 (SPP Status port)  Read  Pin: ~11  10  12  13  15                          
29
--  Base+$02 (SPP Control port) Write Pin:                 ~17  16 ~14  ~1
30
--  Base+$03 (EPP Address port) R/W
31
--  Base+$04 (EPP Data port)    R/W
32
-- 
33
--  ~ indicates a hardware inversion of the bit.
34
--
35
--  Parallel printer port pin assignment
36
-- 
37
--  Pin No (DB25)  SPP Signal      EPP Signal    Direction Register  Bit Inverted
38
--  1              nStrobe           Write_n       Out       Control-0 Yes
39
--  2              Data0           Data0         In/Out    Data-0    No
40
--  3              Data1           Data1         In/Out    Data-1    No
41
--  4              Data2           Data2         In/Out    Data-2    No
42
--  5              Data3           Data3         In/Out    Data-3    No
43
--  6              Data4           Data4         In/Out    Data-4    No
44
--  7              Data5           Data5         In/Out    Data-5    No
45
--  8              Data6           Data6         In/Out    Data-6    No
46
--  9              Data7           Data7         In/Out    Data-7    No
47
--  10             nAck            Interrupt     In        Status-6  No
48
--  11             Busy            Wait          In        Status-7  Yes
49
--  12             Paper-Out       Spare         In        Status-5  No
50
--  13             Select          Spare         In        Status-4  No
51
--  14             Linefeed        Data_Strobe_n Out       Control-1 Yes
52
--  15             nError          Spare         In        Status-3  No
53
--  16             nInitialize     Reset         Out       Control-2 No
54
--  17             nSelect-Printer Addr_Strobe_n Out       Control-3 Yes
55
--  18-25          Ground          Ground        -         -         -
56
-- 
57
--  Copyright (C) 2008 - 2010 John Kent
58
--
59
--  This program is free software: you can redistribute it and/or modify
60
--  it under the terms of the GNU General Public License as published by
61
--  the Free Software Foundation, either version 3 of the License, or
62
--  (at your option) any later version.
63
--
64
--  This program is distributed in the hope that it will be useful,
65
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
66
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
67
--  GNU General Public License for more details.
68
--
69
--  You should have received a copy of the GNU General Public License
70
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
71
--
72
--
73
--===========================================================================--
74
--                                                                           --
75
--                              Revision  History                            --
76
--                                                                           --
77
--===========================================================================--
78
--
79
-- Revision Author        Date         Description
80
--
81
-- 0.1      John E. Kent  2008-09-06   initial version generated from ioport.vhd
82
-- 0.2      John E. Kent  2010-08-09   updated header and added GPL
83
--
84
 
85
library ieee;
86
  use ieee.std_logic_1164.all;
87
  use ieee.std_logic_unsigned.all;
88
library unisim;
89
  use unisim.vcomponents.all;
90
 
91
entity epp is
92
        port (
93
   --
94
   -- CPU Interface Signals
95
   --   
96
         clk       : in  std_logic;
97
    rst       : in  std_logic;
98
    cs        : in  std_logic;
99
    rw        : in  std_logic;
100
    addr      : in  std_logic_vector(2 downto 0);
101
    data_in   : in  std_logic_vector(7 downto 0);
102
         data_out  : out std_logic_vector(7 downto 0);
103
         irq       : out std_logic;
104
         hold      : out std_logic;
105
    --
106
    -- Parallel Port Interface Signals
107
    --
108
         epp_stat  : in  std_logic_vector(7 downto 3);
109
         epp_ctrl  : out std_logic_vector(3 downto 0);
110
         epp_data  : out std_logic_vector(7 downto 0)
111
         );
112
end;
113
 
114
architecture rtl of epp is
115
 
116
constant CTRL_RW_BIT : integer := 0;
117
constant CTRL_DS_BIT : integer := 1;
118
constant CTRL_RS_BIT : integer := 2;
119
constant CTRL_AS_BIT : integer := 3;
120
 
121
constant STAT_IR_BIT : integer := 6;
122
constant STAT_WT_BIT : integer := 7;
123
 
124
signal epp_ctrl_reg : std_logic_vector(3 downto 0);
125
 
126
begin
127
 
128
--
129
-- Read / Write control
130
--
131
epp_control : process( rst, clk, cs, rw, addr, epp_stat, epp_crl_reg, data_in )
132
begin
133
  if rst = '1' then
134
    epp_ctrl_reg(CTRL_RW_BIT) <= '1';
135
    epp_ctrl_reg(CTRL_AS_BIT) <= '1';
136
    epp_ctrl_reg(CTRL_RS_BIT) <= '0';
137
    epp_ctrl_reg(CTRL_DS_BIT) <= '1';
138
    epp_data <= (others=>'Z');
139
  --
140
  -- clock controls on rising edge
141
  --
142
  elsif clk'event and clk = '1' then
143
    epp_ctrl_reg(CTRL_RS_BIT) <= '1';
144
 
145
    if cs = '1' then
146
      case addr is
147
                --
148
                -- address register
149
                --
150
      when "011" =>
151
        --
152
        -- set Data port direction
153
        --
154
             if rw = '1' then
155
          epp_ctrl_reg(CTRL_RW_BIT) <= '1';
156
          epp_data <= (others=>'Z');
157
        else
158
          epp_ctrl_reg(CTRL_RW_BIT) <= '0';
159
                         epp_data <= data_in;
160
        end if;
161
        --
162
                  -- initiale an address strobe
163
                  --
164
        if epp_stat(STAT_WT_BIT) = '0' then
165
          epp_ctrl_reg(CTRL_AS_BIT) <= '0';
166
        elsif epp_stat(STAT_WT_BIT) = '1' then
167
          epp_ctrl_reg(CTRL_AS_BIT) <= '1';
168
        end if;
169
 
170
                --
171
                -- data register
172
                --
173
      when "100" =>
174
                  --
175
                  -- set data port direction
176
                  --
177
             if rw = '1' then
178
          epp_ctrl_reg(CTRL_RW_BIT) <= '1';
179
          epp_data <= (others=>'Z');
180
        else
181
          epp_ctrl_reg(CTRL_RW_BIT) <= '0';
182
                         epp_data <= data_in;
183
        end if;
184
                  --
185
                  -- initiate a data strobe
186
                  --
187
        if epp_stat(STAT_WT_BIT) = '0' then
188
          epp_ctrl_reg(CTRL_DS_BIT) <= '0';
189
        elsif epp_stat(STAT_WT_BIT) = '1' then
190
          epp_ctrl_reg(CTRL_DS_BIT) <= '1';
191
        end if;
192
 
193
      when others =>
194
        epp_ctrl_reg(CTRL_RW_BIT) <= '1';
195
        epp_ctrl_reg(CTRL_AS_BIT) <= '1';
196
        epp_ctrl_reg(CTRL_DS_BIT) <= '1';
197
        epp_data <= (others=>'Z');
198
                  null;
199
 
200
      end case; -- addr
201
    end if; -- cs
202
  end if; -- clk / reset
203
  irq      <= epp_stat(STAT_IR_BIT);
204
  hold     <= not( epp_ctrl_reg(CTRL_DS_BIT) ) or not( epp_ctrl_reg(CTRL_AS_BIT) );
205
  epp_ctrl <= epp_ctrl_reg;
206
  data_out <= epp_data;
207
 
208
end process;
209
 
210
end rtl;
211
 

powered by: WebSVN 2.1.0

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