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

Subversion Repositories System09

[/] [System09/] [rev_86/] [rtl/] [VHDL/] [epp.vhd] - Blame information for rev 147

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

Line No. Rev Author Line
1 65 davidgb
--===========================================================================----
2
--
3
--  S Y N T H E Z I A B L E    epp - Enhanced Parallel Port
4
--
5
--  www.OpenCores.Org - September 2003
6
--  This core adheres to the GNU public license  
7
--
8
-- File name      : epp.vhd
9
--
10
-- Purpose        : Simple Parallel Port for System09
11
--
12
-- Dependencies   : ieee.Std_Logic_1164
13
--                  ieee.std_logic_unsigned
14
--
15
-- Uses           : None
16
--
17
-- Author         : John E. Kent      
18
--                  dilbert57@opencores.org      
19
--
20
--===========================================================================----
21
--
22
-- Revision History:
23
--===========================================================================--
24
--
25
-- Version 0.1 - 6th Sep 2008
26
--  Generated from ioport.vhd
27
--
28
--===========================================================================
29
--
30
--  Parallel printer port pin assignment
31
-- 
32
--  Pin No (DB25)  SPP Signal      EPP Signal    Direction Register  Bit Inverted
33
--  1             nStrobe            Write_n       Out       Control-0 Yes
34
--  2             Data0           Data0         In/Out    Data-0        No
35
--  3             Data1           Data1         In/Out    Data-1        No
36
--  4             Data2           Data2         In/Out    Data-2        No
37
--  5             Data3           Data3         In/Out    Data-3        No
38
--  6             Data4           Data4         In/Out    Data-4        No
39
--  7             Data5           Data5         In/Out    Data-5        No
40
--  8             Data6           Data6         In/Out    Data-6        No
41
--  9             Data7           Data7         In/Out    Data-7        No
42
--  10            nAck            Interrupt     In        Status-6  No
43
--  11            Busy            Wait          In        Status-7  Yes
44
--  12            Paper-Out       Spare         In        Status-5  No
45
--  13            Select          Spare         In        Status-4  No
46
-- 
47
--  14            Linefeed        Data_Strobe_n Out       Control-1 Yes
48
--  15            nError          Spare         In        Status-3  No
49
--  16             nInitialize     Reset         Out       Control-2 No
50
--  17             nSelect-Printer Addr_Strobe_n Out       Control-3 Yes
51
--  18-25          Ground          Ground        -         -         -
52
-- 
53
--  Address                              MSB                         LSB
54
--                                 Bit:    7   6   5   4   3   2   1   0
55
-- Base   (SPP Data port)    Write Pin:          9   8   7   6   5   4   3   2
56
-- Base+1 (SPP Status port)  Read  Pin:  ~11  10  12  13  15                            
57
-- Base+2 (SPP Control port) Write Pin:                  ~17  16 ~14  ~1
58
-- Base+3 (EPP Address port) R/W
59
-- Base+4 (EPP Data port)    R/W
60
-- 
61
--  ~ indicates a hardware inversion of the bit.
62
-- 
63
 
64
library ieee;
65
  use ieee.std_logic_1164.all;
66
  use ieee.std_logic_unsigned.all;
67
 
68
entity epp is
69
        port (
70
         clk       : in  std_logic;
71
    rst       : in  std_logic;
72
    cs        : in  std_logic;
73
    rw        : in  std_logic;
74
    addr      : in  std_logic_vector(2 downto 0);
75
    data_in   : in  std_logic_vector(7 downto 0);
76
         data_out  : out std_logic_vector(7 downto 0);
77
         epp_data  : out std_logic_vector(7 downto 0);
78
         epp_stat  : in  std_logic_vector(7 downto 3);
79
         epp_ctrl  : out std_logic_vector(3 downto 0);
80
         hold      : out std_logic;
81
         irq       : out std_logic
82
         );
83
end;
84
 
85
architecture rtl of epp is
86
 
87
constant CTRL_RW_BIT : integer := 0;
88
constant CTRL_DS_BIT : integer := 1;
89
constant CTRL_RS_BIT : integer := 2;
90
constant CTRL_AS_BIT : integer := 3;
91
 
92
constant STAT_IR_BIT : integer := 6;
93
constant STAT_WT_BIT : integer := 7;
94
 
95
signal epp_ctrl_reg : std_logic_vector(3 downto 0);
96
 
97
begin
98
 
99
--
100
-- Read / Write control
101
--
102
epp_control : process( rst, clk, cs, rw, addr, epp_stat, epp_crl_reg, data_in )
103
begin
104
  if rst = '1' then
105
    epp_ctrl_reg(CTRL_RW_BIT) <= '1';
106
    epp_ctrl_reg(CTRL_AS_BIT) <= '1';
107
    epp_ctrl_reg(CTRL_RS_BIT) <= '0';
108
    epp_ctrl_reg(CTRL_DS_BIT) <= '1';
109
    epp_data <= (others=>'Z');
110
  --
111
  -- clock controls on rising edge
112
  --
113
  elsif clk'event and clk = '1' then
114
    epp_ctrl_reg(CTRL_RS_BIT) <= '1';
115
 
116
    if cs = '1' then
117
      case addr is
118
                --
119
                -- address register
120
                --
121
      when "011" =>
122
        --
123
        -- set Data port direction
124
        --
125
             if rw = '1' then
126
          epp_ctrl_reg(CTRL_RW_BIT) <= '1';
127
          epp_data <= (others=>'Z');
128
        else
129
          epp_ctrl_reg(CTRL_RW_BIT) <= '0';
130
                         epp_data <= data_in;
131
        end if;
132
        --
133
                  -- initiale an address strobe
134
                  --
135
        if epp_stat(STAT_WT_BIT) = '0' then
136
          epp_ctrl_reg(CTRL_AS_BIT) <= '0';
137
        elsif epp_stat(STAT_WT_BIT) = '1' then
138
          epp_ctrl_reg(CTRL_AS_BIT) <= '1';
139
        end if;
140
 
141
                --
142
                -- data register
143
                --
144
      when "100" =>
145
                  --
146
                  -- set data port direction
147
                  --
148
             if rw = '1' then
149
          epp_ctrl_reg(CTRL_RW_BIT) <= '1';
150
          epp_data <= (others=>'Z');
151
        else
152
          epp_ctrl_reg(CTRL_RW_BIT) <= '0';
153
                         epp_data <= data_in;
154
        end if;
155
                  --
156
                  -- initiate a data strobe
157
                  --
158
        if epp_stat(STAT_WT_BIT) = '0' then
159
          epp_ctrl_reg(CTRL_DS_BIT) <= '0';
160
        elsif epp_stat(STAT_WT_BIT) = '1' then
161
          epp_ctrl_reg(CTRL_DS_BIT) <= '1';
162
        end if;
163
 
164
      when others =>
165
        epp_ctrl_reg(CTRL_RW_BIT) <= '1';
166
        epp_ctrl_reg(CTRL_AS_BIT) <= '1';
167
        epp_ctrl_reg(CTRL_DS_BIT) <= '1';
168
        epp_data <= (others=>'Z');
169
                  null;
170
 
171
      end case; -- addr
172
    end if; -- cs
173
  end if; -- clk / reset
174
  irq      <= epp_stat(STAT_IR_BIT);
175
  hold     <= not( epp_ctrl_reg(CTRL_DS_BIT) ) or not( epp_ctrl_reg(CTRL_AS_BIT) );
176
  epp_ctrl <= epp_ctrl_reg;
177
  data_out <= epp_data;
178
 
179
end process;
180
 
181
end rtl;
182
 

powered by: WebSVN 2.1.0

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