Line 1... |
Line 1... |
-- $Id: serport.vhd 389 2011-07-07 21:59:00Z mueller $
|
-- $Id: serport.vhd 424 2011-11-13 16:38:23Z mueller $
|
--
|
--
|
-- Copyright 2007-2010 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
-- Copyright 2007-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
--
|
--
|
-- This program is free software; you may redistribute and/or modify it under
|
-- This program is free software; you may redistribute and/or modify it under
|
-- the terms of the GNU General Public License as published by the Free
|
-- the terms of the GNU General Public License as published by the Free
|
-- Software Foundation, either version 2, or at your option any later version.
|
-- Software Foundation, either version 2, or at your option any later version.
|
--
|
--
|
Line 14... |
Line 14... |
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
-- Package Name: serport
|
-- Package Name: serport
|
-- Description: serial port interface components
|
-- Description: serial port interface components
|
--
|
--
|
-- Dependencies: -
|
-- Dependencies: -
|
-- Tool versions: xst 8.1, 8.2, 9.1, 9.2, 11.4, 12.1; ghdl 0.18-0.29
|
-- Tool versions: xst 8.2, 9.1, 9.2, 11.4, 12.1; ghdl 0.18-0.29
|
--
|
--
|
-- Revision History:
|
-- Revision History:
|
-- Date Rev Version Comment
|
-- Date Rev Version Comment
|
|
-- 2011-10-23 419 1.2.4 remove serport_clkdiv_ consts;
|
|
-- 2011-10-22 417 1.2.3 add serport_xon(rx|tx) defs
|
|
-- 2011-10-14 416 1.2.2 add c_serport defs
|
-- 2010-12-26 348 1.2.1 add ABCLKDIV to serport_uart_rxtx_ab
|
-- 2010-12-26 348 1.2.1 add ABCLKDIV to serport_uart_rxtx_ab
|
-- 2010-04-10 276 1.2 add clock divider constant defs
|
-- 2010-04-10 276 1.2 add clock divider constant defs
|
-- 2007-10-22 88 1.1 renames (in prev revs); remove std_logic_unsigned
|
-- 2007-10-22 88 1.1 renames (in prev revs); remove std_logic_unsigned
|
-- 2007-06-03 45 1.0 Initial version
|
-- 2007-06-03 45 1.0 Initial version
|
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
Line 31... |
Line 34... |
|
|
use work.slvtypes.all;
|
use work.slvtypes.all;
|
|
|
package serport is
|
package serport is
|
|
|
-- clock divider constants assume 50 MHz clock
|
constant c_serport_xon : slv8 := "00010001"; -- char xon: ^Q = hex 11
|
|
constant c_serport_xoff : slv8 := "00010011"; -- char xoff ^S = hex 13
|
constant serport_clkdiv_009600 : integer := 5208-1; -- 50000000/ 9600=5208.33
|
constant c_serport_xesc : slv8 := "00011011"; -- char xesc ^[ = ESC = hex 1B
|
constant serport_clkdiv_019200 : integer := 2604-1; -- 50000000/ 19200=2604.16
|
|
constant serport_clkdiv_038400 : integer := 1302-1; -- 50000000/ 38400=1302.08
|
|
constant serport_clkdiv_057600 : integer := 868-1; -- 50000000/ 57600= 868.05
|
|
constant serport_clkdiv_115200 : integer := 434-1; -- 50000000/115200= 434.02
|
|
constant serport_clkdiv_230400 : integer := 217-1; -- 50000000/230400= 217.01
|
|
constant serport_clkdiv_460800 : integer := 109-1; -- 50000000/460800= 108.51
|
|
constant serport_clkdiv_500000 : integer := 100-1; -- 50000000/500000= 100
|
|
constant serport_clkdiv_576000 : integer := 87-1; -- 50000000/576000= 86.80
|
|
constant serport_clkdiv_921600 : integer := 54-1; -- 50000000/921600= 54.25
|
|
constant serport_clkdiv_1M : integer := 50-1; -- 50000000/1M = 50
|
|
constant serport_clkdiv_2M : integer := 24-1; -- 50000000/2M = 25
|
|
|
|
component serport_uart_rxtx is -- serial port uart: rx+tx combo
|
component serport_uart_rxtx is -- serial port uart: rx+tx combo
|
generic (
|
generic (
|
CDWIDTH : positive := 13); -- clk divider width
|
CDWIDTH : positive := 13); -- clk divider width
|
port (
|
port (
|
Line 132... |
Line 124... |
ACT : out slbit; -- active; if 1 clkdiv is invalid
|
ACT : out slbit; -- active; if 1 clkdiv is invalid
|
DONE : out slbit -- resync done
|
DONE : out slbit -- resync done
|
);
|
);
|
end component;
|
end component;
|
|
|
|
component serport_xonrx is -- serial port: xon/xoff logic rx path
|
|
port (
|
|
CLK : in slbit; -- clock
|
|
RESET : in slbit; -- reset
|
|
ENAXON : in slbit; -- enable xon/xoff handling
|
|
ENAESC : in slbit; -- enable xon/xoff escaping
|
|
UART_RXDATA : in slv8; -- uart data out
|
|
UART_RXVAL : in slbit; -- uart data valid
|
|
RXDATA : out slv8; -- user data out
|
|
RXVAL : out slbit; -- user data valid
|
|
RXHOLD : in slbit; -- user data hold
|
|
RXOVR : out slbit; -- user data overrun
|
|
TXOK : out slbit -- tx channel ok
|
|
);
|
|
end component;
|
|
|
|
component serport_xontx is -- serial port: xon/xoff logic tx path
|
|
port (
|
|
CLK : in slbit; -- clock
|
|
RESET : in slbit; -- reset
|
|
ENAXON : in slbit; -- enable xon/xoff handling
|
|
ENAESC : in slbit; -- enable xon/xoff escaping
|
|
UART_TXDATA : out slv8; -- uart data in
|
|
UART_TXENA : out slbit; -- uart data enable
|
|
UART_TXBUSY : in slbit; -- uart data busy
|
|
TXDATA : in slv8; -- user data in
|
|
TXENA : in slbit; -- user data enable
|
|
TXBUSY : out slbit; -- user data busy
|
|
RXOK : in slbit; -- rx channel ok
|
|
TXOK : in slbit -- tx channel ok
|
|
);
|
|
end component;
|
|
|
|
type serport_stat_type is record -- serial port module status
|
|
rxerr : slbit; -- receiver data error (frame error)
|
|
rxovr : slbit; -- receiver data overrun
|
|
rxact : slbit; -- receiver active
|
|
txact : slbit; -- transceiver active
|
|
abact : slbit; -- autobauder active;if 1 clkdiv invalid
|
|
abdone : slbit; -- autobauder resync done
|
|
abclkdiv : slv16; -- autobauder clock divider
|
|
rxok : slbit; -- rx channel ok
|
|
txok : slbit; -- tx channel ok
|
|
end record serport_stat_type;
|
|
|
|
constant serport_stat_init : serport_stat_type := (
|
|
'0','0', -- rxerr,rxovr
|
|
'0','0', -- rxact,txact
|
|
'0','0', -- abact,abdone
|
|
(others=>'0'), -- abclkdiv
|
|
'0','0' -- rxok,txok
|
|
);
|
|
|
|
component serport_1clock is -- serial port module, 1 clock domain
|
|
generic (
|
|
CDWIDTH : positive := 13; -- clk divider width
|
|
CDINIT : natural := 15; -- clk divider initial/reset setting
|
|
RXFAWIDTH : natural := 5; -- rx fifo address width
|
|
TXFAWIDTH : natural := 5); -- tx fifo address width
|
|
port (
|
|
CLK : in slbit; -- clock
|
|
CE_MSEC : in slbit; -- 1 msec clock enable
|
|
RESET : in slbit; -- reset
|
|
ENAXON : in slbit; -- enable xon/xoff handling
|
|
ENAESC : in slbit; -- enable xon/xoff escaping
|
|
RXDATA : out slv8; -- receiver data out
|
|
RXVAL : out slbit; -- receiver data valid
|
|
RXHOLD : in slbit; -- receiver data hold
|
|
TXDATA : in slv8; -- transmit data in
|
|
TXENA : in slbit; -- transmit data enable
|
|
TXBUSY : out slbit; -- transmit busy
|
|
STAT : out serport_stat_type; -- serport module status
|
|
RXSD : in slbit; -- receive serial data (uart view)
|
|
TXSD : out slbit; -- transmit serial data (uart view)
|
|
RXRTS_N : out slbit; -- receive rts (uart view, act.low)
|
|
TXCTS_N : in slbit -- transmit cts (uart view, act.low)
|
|
);
|
|
end component;
|
|
|
|
component serport_2clock is -- serial port module, 2 clock domain
|
|
generic (
|
|
CDWIDTH : positive := 13; -- clk divider width
|
|
CDINIT : natural := 15; -- clk divider initial/reset setting
|
|
RXFAWIDTH : natural := 5; -- rx fifo address width
|
|
TXFAWIDTH : natural := 5); -- tx fifo address width
|
|
port (
|
|
CLKU : in slbit; -- clock (backend:user)
|
|
RESET : in slbit; -- reset
|
|
CLKS : in slbit; -- clock (frontend:serial)
|
|
CES_MSEC : in slbit; -- S|1 msec clock enable
|
|
ENAXON : in slbit; -- U|enable xon/xoff handling
|
|
ENAESC : in slbit; -- U|enable xon/xoff escaping
|
|
RXDATA : out slv8; -- U|receiver data out
|
|
RXVAL : out slbit; -- U|receiver data valid
|
|
RXHOLD : in slbit; -- U|receiver data hold
|
|
TXDATA : in slv8; -- U|transmit data in
|
|
TXENA : in slbit; -- U|transmit data enable
|
|
TXBUSY : out slbit; -- U|transmit busy
|
|
STAT : out serport_stat_type; -- U|serport module status
|
|
RXSD : in slbit; -- S|receive serial data (uart view)
|
|
TXSD : out slbit; -- S|transmit serial data (uart view)
|
|
RXRTS_N : out slbit; -- S|receive rts (uart view, act.low)
|
|
TXCTS_N : in slbit -- S|transmit cts (uart view, act.low)
|
|
);
|
|
end component;
|
|
|
end package serport;
|
end package serport;
|
|
|
No newline at end of file
|
No newline at end of file
|