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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 wfjm
-- $Id: bp_rs232_2l4l_iob.vhd 649 2015-02-21 21:10:16Z 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 22 wfjm
-- Description:    iob's for internal(2line) + external(4line) rs232, with select
17 2 wfjm
--
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 29 wfjm
-- Tool versions:  xst 12.1-14,7; ghdl 0.26-0.31
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
 
40
use work.slvtypes.all;
41 12 wfjm
use work.bpgenlib.all;
42 2 wfjm
 
43
-- ----------------------------------------------------------------------------
44
 
45 12 wfjm
entity bp_rs232_2l4l_iob is             -- iob's for dual 2l+4l rs232, w/ select
46
  generic (
47
    RELAY : boolean := false);          -- add a relay stage towards IOB's
48 2 wfjm
  port (
49
    CLK : in slbit;                     -- clock
50 12 wfjm
    RESET : in slbit := '0';            -- reset
51 2 wfjm
    SEL : in slbit;                     -- select, '0' for port 0
52
    RXD : out slbit;                    -- receive data (board view)
53
    TXD : in slbit;                     -- transmit data (board view)
54
    CTS_N : out slbit;                  -- clear to send   (act. low)
55
    RTS_N : in slbit;                   -- request to send (act. low)
56
    I_RXD0 : in slbit;                  -- pad-i: p0: receive data (board view)
57
    O_TXD0 : out slbit;                 -- pad-o: p0: transmit data (board view)
58
    I_RXD1 : in slbit;                  -- pad-i: p1: receive data (board view)
59
    O_TXD1 : out slbit;                 -- pad-o: p1: transmit data (board view)
60
    I_CTS1_N : in slbit;                -- pad-i: p1: clear to send   (act. low)
61
    O_RTS1_N : out slbit                -- pad-o: p1: request to send (act. low)
62
  );
63 12 wfjm
end bp_rs232_2l4l_iob;
64 2 wfjm
 
65 12 wfjm
architecture syn of bp_rs232_2l4l_iob is
66
 
67 2 wfjm
  signal RXD0 : slbit := '0';
68
  signal RXD1 : slbit := '0';
69
  signal CTS1_N : slbit := '0';
70 12 wfjm
 
71
  signal R_RXD    : slbit := '1';
72
  signal R_CTS_N  : slbit := '0';
73
  signal R_TXD0   : slbit := '1';
74
  signal R_TXD1   : slbit := '1';
75
  signal R_RTS1_N : slbit := '0';
76
 
77
  signal RR_RXD0   : slbit := '1';
78
  signal RR_TXD0   : slbit := '1';
79
  signal RR_RXD1   : slbit := '1';
80
  signal RR_TXD1   : slbit := '1';
81
  signal RR_CTS1_N : slbit := '0';
82
  signal RR_RTS1_N : slbit := '0';
83
 
84 2 wfjm
begin
85
 
86 12 wfjm
  -- On Digilent Atlys bords the IOBs for P0 and P1 are on diagonally opposide
87
  -- corners of the die, which causes very long (7-8ns) routing delays to a LUT
88
  -- in the middle. The RELAY generic allows to add 'relay flops' between IOB
89
  -- flops and the mux implented in proc_regs_mux.
90
  --
91
  -- The data flow is
92
  --   iob-flop     relay-flop    if-flop     port
93
  --   RXD0      -> RR_RXD0    -> R_RXD    -> RXD
94
  --   TXD0      <- RR_TXD0    <- R_TXD0   <- TXD
95
  --   RXD1      -> RR_RXD1    -> R_RXD    -> RXD
96
  --   TXD1      <- RR_TXD1    <- R_TXD1   <- TXD
97
  --   CTS1_N    -> RR_CTS1_N  -> R_CTS_N  -> CTS
98
  --   RTS1_N    <- RR_RTS1_N  <- R_RTS1_N <- RTS
99
 
100
  P0 : bp_rs232_2line_iob
101 2 wfjm
    port map (
102
      CLK   => CLK,
103
      RXD   => RXD0,
104 12 wfjm
      TXD   => RR_TXD0,
105 2 wfjm
      I_RXD => I_RXD0,
106
      O_TXD => O_TXD0
107
    );
108
 
109 12 wfjm
  P1 : bp_rs232_4line_iob
110 2 wfjm
    port map (
111
      CLK     => CLK,
112
      RXD     => RXD1,
113 12 wfjm
      TXD     => RR_TXD1,
114 2 wfjm
      CTS_N   => CTS1_N,
115 12 wfjm
      RTS_N   => RR_RTS1_N,
116 2 wfjm
      I_RXD   => I_RXD1,
117
      O_TXD   => O_TXD1,
118
      I_CTS_N => I_CTS1_N,
119
      O_RTS_N => O_RTS1_N
120
    );
121
 
122 12 wfjm
  DORELAY : if RELAY generate
123
    proc_regs_pipe: process (CLK)
124
    begin
125 13 wfjm
      if rising_edge(CLK) then
126 12 wfjm
        if RESET = '1' then
127
          RR_RXD0   <= '1';
128
          RR_TXD0   <= '1';
129
          RR_RXD1   <= '1';
130
          RR_TXD1   <= '1';
131
          RR_CTS1_N <= '0';
132
          RR_RTS1_N <= '0';
133
        else
134
          RR_RXD0   <= RXD0;
135
          RR_TXD0   <= R_TXD0;
136
          RR_RXD1   <= RXD1;
137
          RR_TXD1   <= R_TXD1;
138
          RR_CTS1_N <= CTS1_N;
139
          RR_RTS1_N <= R_RTS1_N;
140
        end if;
141
      end if;
142
    end process proc_regs_pipe;
143
  end generate DORELAY;
144
 
145
  NORELAY : if not RELAY generate
146
    RR_RXD0   <= RXD0;
147
    RR_TXD0   <= R_TXD0;
148
    RR_RXD1   <= RXD1;
149
    RR_TXD1   <= R_TXD1;
150
    RR_CTS1_N <= CTS1_N;
151
    RR_RTS1_N <= R_RTS1_N;
152
  end generate NORELAY;
153
 
154
  proc_regs_mux: process (CLK)
155 2 wfjm
  begin
156 12 wfjm
 
157 13 wfjm
    if rising_edge(CLK) then
158 12 wfjm
      if RESET = '1' then
159
        R_RXD    <= '1';
160
        R_CTS_N  <= '0';
161
        R_TXD0   <= '1';
162
        R_TXD1   <= '1';
163
        R_RTS1_N <= '0';
164
      else
165
        if SEL = '0' then               -- use 2-line rs232, no flow cntl
166
          R_RXD    <= RR_RXD0;            -- get port 0 inputs
167
          R_CTS_N  <= '0';
168
          R_TXD0   <= TXD;                -- set port 0 output 
169
          R_TXD1   <= '1';                -- port 1 outputs to idle state
170
          R_RTS1_N <= '0';
171
        else                            -- otherwise use 4-line rs232
172
          R_RXD    <= RR_RXD1;             -- get port 1 inputs
173
          R_CTS_N  <= RR_CTS1_N;
174
          R_TXD0   <= '1';                 -- port 0 output to idle state
175
          R_TXD1   <= TXD;                 -- set port 1 outputs
176
          R_RTS1_N <= RTS_N;
177
        end if;
178
      end if;
179 2 wfjm
    end if;
180
 
181 12 wfjm
  end process proc_regs_mux;
182
 
183
  RXD   <= R_RXD;
184
  CTS_N <= R_CTS_N;
185
 
186 2 wfjm
end syn;

powered by: WebSVN 2.1.0

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