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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [rtl/] [bplib/] [bpgen/] [bp_rs232_2l4l_iob.vhd] - Blame information for rev 12

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

Line No. Rev Author Line
1 12 wfjm
-- $Id: bp_rs232_2l4l_iob.vhd 406 2011-08-14 21:06:44Z mueller $
2 2 wfjm
--
3 12 wfjm
-- Copyright 2010-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 2 wfjm
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, 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 MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
--
14
------------------------------------------------------------------------------
15 12 wfjm
-- Module Name:    bp_rs232_2l4l_iob - syn
16 2 wfjm
-- Description:    iob's for internal + external rs232, with select
17
--
18 12 wfjm
-- Dependencies:   bp_rs232_2line_iob
19
--                 bp_rs232_4line_iob
20 2 wfjm
--
21
-- Test bench:     -
22
--
23
-- Target Devices: generic
24 12 wfjm
-- Tool versions:  xst 12.1; ghdl 0.26-0.29
25 2 wfjm
--
26
-- Revision History: 
27
-- Date         Rev Version  Comment
28 12 wfjm
-- 2011-08-14   406   1.2.2  fix mistake in tx and rts relay
29
-- 2011-08-07   404   1.2.1  add RELAY generic and a relay stage towards IOB's
30
-- 2011-08-06   403   1.2    add pipeline flops; add RESET signal
31
-- 2011-07-09   391   1.1    moved and renamed to bpgen
32
-- 2011-07-02   387   1.0.1  use bp_rs232_[24]line_iob now
33 2 wfjm
-- 2010-04-17   278   1.0    Initial version
34
------------------------------------------------------------------------------
35
--    
36
 
37
library ieee;
38
use ieee.std_logic_1164.all;
39
use ieee.std_logic_arith.all;
40
 
41
use work.slvtypes.all;
42 12 wfjm
use work.bpgenlib.all;
43 2 wfjm
 
44
-- ----------------------------------------------------------------------------
45
 
46 12 wfjm
entity bp_rs232_2l4l_iob is             -- iob's for dual 2l+4l rs232, w/ select
47
  generic (
48
    RELAY : boolean := false);          -- add a relay stage towards IOB's
49 2 wfjm
  port (
50
    CLK : in slbit;                     -- clock
51 12 wfjm
    RESET : in slbit := '0';            -- reset
52 2 wfjm
    SEL : in slbit;                     -- select, '0' for port 0
53
    RXD : out slbit;                    -- receive data (board view)
54
    TXD : in slbit;                     -- transmit data (board view)
55
    CTS_N : out slbit;                  -- clear to send   (act. low)
56
    RTS_N : in slbit;                   -- request to send (act. low)
57
    I_RXD0 : in slbit;                  -- pad-i: p0: receive data (board view)
58
    O_TXD0 : out slbit;                 -- pad-o: p0: transmit data (board view)
59
    I_RXD1 : in slbit;                  -- pad-i: p1: receive data (board view)
60
    O_TXD1 : out slbit;                 -- pad-o: p1: transmit data (board view)
61
    I_CTS1_N : in slbit;                -- pad-i: p1: clear to send   (act. low)
62
    O_RTS1_N : out slbit                -- pad-o: p1: request to send (act. low)
63
  );
64 12 wfjm
end bp_rs232_2l4l_iob;
65 2 wfjm
 
66 12 wfjm
architecture syn of bp_rs232_2l4l_iob is
67
 
68 2 wfjm
  signal RXD0 : slbit := '0';
69
  signal RXD1 : slbit := '0';
70
  signal CTS1_N : slbit := '0';
71 12 wfjm
 
72
  signal R_RXD    : slbit := '1';
73
  signal R_CTS_N  : slbit := '0';
74
  signal R_TXD0   : slbit := '1';
75
  signal R_TXD1   : slbit := '1';
76
  signal R_RTS1_N : slbit := '0';
77
 
78
  signal RR_RXD0   : slbit := '1';
79
  signal RR_TXD0   : slbit := '1';
80
  signal RR_RXD1   : slbit := '1';
81
  signal RR_TXD1   : slbit := '1';
82
  signal RR_CTS1_N : slbit := '0';
83
  signal RR_RTS1_N : slbit := '0';
84
 
85 2 wfjm
begin
86
 
87 12 wfjm
  -- On Digilent Atlys bords the IOBs for P0 and P1 are on diagonally opposide
88
  -- corners of the die, which causes very long (7-8ns) routing delays to a LUT
89
  -- in the middle. The RELAY generic allows to add 'relay flops' between IOB
90
  -- flops and the mux implented in proc_regs_mux.
91
  --
92
  -- The data flow is
93
  --   iob-flop     relay-flop    if-flop     port
94
  --   RXD0      -> RR_RXD0    -> R_RXD    -> RXD
95
  --   TXD0      <- RR_TXD0    <- R_TXD0   <- TXD
96
  --   RXD1      -> RR_RXD1    -> R_RXD    -> RXD
97
  --   TXD1      <- RR_TXD1    <- R_TXD1   <- TXD
98
  --   CTS1_N    -> RR_CTS1_N  -> R_CTS_N  -> CTS
99
  --   RTS1_N    <- RR_RTS1_N  <- R_RTS1_N <- RTS
100
 
101
  P0 : bp_rs232_2line_iob
102 2 wfjm
    port map (
103
      CLK   => CLK,
104
      RXD   => RXD0,
105 12 wfjm
      TXD   => RR_TXD0,
106 2 wfjm
      I_RXD => I_RXD0,
107
      O_TXD => O_TXD0
108
    );
109
 
110 12 wfjm
  P1 : bp_rs232_4line_iob
111 2 wfjm
    port map (
112
      CLK     => CLK,
113
      RXD     => RXD1,
114 12 wfjm
      TXD     => RR_TXD1,
115 2 wfjm
      CTS_N   => CTS1_N,
116 12 wfjm
      RTS_N   => RR_RTS1_N,
117 2 wfjm
      I_RXD   => I_RXD1,
118
      O_TXD   => O_TXD1,
119
      I_CTS_N => I_CTS1_N,
120
      O_RTS_N => O_RTS1_N
121
    );
122
 
123 12 wfjm
  DORELAY : if RELAY generate
124
    proc_regs_pipe: process (CLK)
125
    begin
126
      if CLK'event and CLK='1' then
127
        if RESET = '1' then
128
          RR_RXD0   <= '1';
129
          RR_TXD0   <= '1';
130
          RR_RXD1   <= '1';
131
          RR_TXD1   <= '1';
132
          RR_CTS1_N <= '0';
133
          RR_RTS1_N <= '0';
134
        else
135
          RR_RXD0   <= RXD0;
136
          RR_TXD0   <= R_TXD0;
137
          RR_RXD1   <= RXD1;
138
          RR_TXD1   <= R_TXD1;
139
          RR_CTS1_N <= CTS1_N;
140
          RR_RTS1_N <= R_RTS1_N;
141
        end if;
142
      end if;
143
    end process proc_regs_pipe;
144
  end generate DORELAY;
145
 
146
  NORELAY : if not RELAY generate
147
    RR_RXD0   <= RXD0;
148
    RR_TXD0   <= R_TXD0;
149
    RR_RXD1   <= RXD1;
150
    RR_TXD1   <= R_TXD1;
151
    RR_CTS1_N <= CTS1_N;
152
    RR_RTS1_N <= R_RTS1_N;
153
  end generate NORELAY;
154
 
155
  proc_regs_mux: process (CLK)
156 2 wfjm
  begin
157 12 wfjm
 
158
    if CLK'event and CLK='1' then
159
      if RESET = '1' then
160
        R_RXD    <= '1';
161
        R_CTS_N  <= '0';
162
        R_TXD0   <= '1';
163
        R_TXD1   <= '1';
164
        R_RTS1_N <= '0';
165
      else
166
        if SEL = '0' then               -- use 2-line rs232, no flow cntl
167
          R_RXD    <= RR_RXD0;            -- get port 0 inputs
168
          R_CTS_N  <= '0';
169
          R_TXD0   <= TXD;                -- set port 0 output 
170
          R_TXD1   <= '1';                -- port 1 outputs to idle state
171
          R_RTS1_N <= '0';
172
        else                            -- otherwise use 4-line rs232
173
          R_RXD    <= RR_RXD1;             -- get port 1 inputs
174
          R_CTS_N  <= RR_CTS1_N;
175
          R_TXD0   <= '1';                 -- port 0 output to idle state
176
          R_TXD1   <= TXD;                 -- set port 1 outputs
177
          R_RTS1_N <= RTS_N;
178
        end if;
179
      end if;
180 2 wfjm
    end if;
181
 
182 12 wfjm
  end process proc_regs_mux;
183
 
184
  RXD   <= R_RXD;
185
  CTS_N <= R_CTS_N;
186
 
187 2 wfjm
end syn;

powered by: WebSVN 2.1.0

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