1 |
2 |
skeptonomi |
--*************************************************************************
|
2 |
|
|
--* *
|
3 |
|
|
--* Copyright (C) 2014 William B Hunter - LGPL *
|
4 |
|
|
--* *
|
5 |
|
|
--* This source file may be used and distributed without *
|
6 |
|
|
--* restriction provided that this copyright statement is not *
|
7 |
|
|
--* removed from the file and that any derivative work contains *
|
8 |
|
|
--* the original copyright notice and the associated disclaimer. *
|
9 |
|
|
--* *
|
10 |
|
|
--* This source file is free software; you can redistribute it *
|
11 |
|
|
--* and/or modify it under the terms of the GNU Lesser General *
|
12 |
|
|
--* Public License as published by the Free Software Foundation; *
|
13 |
|
|
--* either version 2.1 of the License, or (at your option) any *
|
14 |
|
|
--* later version. *
|
15 |
|
|
--* *
|
16 |
|
|
--* This source is distributed in the hope that it will be *
|
17 |
|
|
--* useful, but WITHout ANY WARRANTY; without even the implied *
|
18 |
|
|
--* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR *
|
19 |
|
|
--* PURPOSE. See the GNU Lesser General Public License for more *
|
20 |
|
|
--* details. *
|
21 |
|
|
--* *
|
22 |
|
|
--* You should have received a copy of the GNU Lesser General *
|
23 |
|
|
--* Public License along with this source; if not, download it *
|
24 |
|
|
--* from http://www.opencores.org/lgpl.shtml *
|
25 |
|
|
--* *
|
26 |
|
|
--*************************************************************************
|
27 |
|
|
--
|
28 |
|
|
-- Engineer: William B Hunter
|
29 |
|
|
-- Create Date: 08/08/2014
|
30 |
|
|
-- Project: Manchester Uart
|
31 |
|
|
-- File: manchester.vhd - a Manchester encoded UART
|
32 |
|
|
-- Description: This is a wrapper for teh encoder and decoder.
|
33 |
|
|
--
|
34 |
|
|
-- Justification: The use of the Manchester UART has some advantages of a standard UART.
|
35 |
|
|
-- 1. The Manchester UART can tolerate about 18% difference in timing between the transmitter and reciever.
|
36 |
|
|
-- This is very useful if one or both of the systems don't have an accurate clock. RC oscillators can be used
|
37 |
|
|
-- instead of crystals. No PLL is required for recovery of the data signal.
|
38 |
|
|
-- 2. The Manchester UART is better when powering low power (devices off of the serial lines (parasitic power).
|
39 |
|
|
-- A typical UART can have a continuous low output for 9 bit times, whereas the Manchester UART has a max
|
40 |
|
|
-- low time of 1 bit time.
|
41 |
|
|
-- There is also a disadvantage of the Manchester UART. It can have twice the transitions per bit compared to
|
42 |
|
|
-- a normal UART.This requires twice the bandwidth in the UART dirvers for a given data rate.
|
43 |
|
|
--
|
44 |
|
|
-- Operational Description: This is a Manchester encoded UART - It encodes 16 bit data grams using Manchester encoding.
|
45 |
|
|
-- This unit is designed for short data bursts rather than stream encoding typical of Manchester systesm.
|
46 |
|
|
-- Since this is a burst encoder, it relys on start and stop bits for synchronization instead of sync patterns.
|
47 |
|
|
-- The Manchester UART goes to an idle state when no data is being transmitted. The idle state is a logic high.
|
48 |
|
|
-- Bits are encoded by a high to low (zero) or low to high(one) transition in the middle of the bit period. Start
|
49 |
|
|
-- and stop bits are always ones (low to high transitions).
|
50 |
|
|
----------------------------------------------------------------------------------
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
library IEEE;
|
54 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
55 |
|
|
|
56 |
|
|
-- Uncomment the following library declaration if using
|
57 |
|
|
-- arithmetic functions with Signed or Unsigned values
|
58 |
|
|
--use IEEE.NUMERIC_STD.ALL;
|
59 |
|
|
|
60 |
|
|
-- Uncomment the following library declaration if instantiating
|
61 |
|
|
-- any Xilinx leaf cells in this code.
|
62 |
|
|
--library UNISIM;
|
63 |
|
|
--use UNISIM.VComponents.all;
|
64 |
|
|
|
65 |
|
|
entity Manchester is
|
66 |
|
|
Port (
|
67 |
|
|
clk16x : in STD_LOGIC;
|
68 |
|
|
srst : in STD_LOGIC;
|
69 |
|
|
rxd : in STD_LOGIC;
|
70 |
|
|
rx_data : out STD_LOGIC_VECTOR (15 downto 0);
|
71 |
|
|
rx_stb : out STD_LOGIC;
|
72 |
|
|
rx_idle : out STD_LOGIC;
|
73 |
|
|
fm_err : out STD_LOGIC;
|
74 |
|
|
txd : out STD_LOGIC;
|
75 |
|
|
tx_data : in STD_LOGIC_VECTOR (15 downto 0);
|
76 |
|
|
tx_stb : in STD_LOGIC;
|
77 |
|
|
tx_idle : out STD_LOGIC;
|
78 |
|
|
or_err : out STD_LOGIC
|
79 |
|
|
);
|
80 |
|
|
end Manchester;
|
81 |
|
|
|
82 |
|
|
architecture rtl of Manchester is
|
83 |
|
|
|
84 |
|
|
begin
|
85 |
|
|
|
86 |
|
|
u_decode : entity work.decode(rtl)
|
87 |
|
|
port map(
|
88 |
|
|
clk16x => clk16x,
|
89 |
|
|
srst => srst,
|
90 |
|
|
rxd => rxd,
|
91 |
|
|
rx_data => rx_data,
|
92 |
|
|
rx_stb => rx_stb,
|
93 |
|
|
fm_err => fm_err,
|
94 |
|
|
rx_idle => rx_idle
|
95 |
|
|
);
|
96 |
|
|
|
97 |
|
|
u_encode : entity work.encode(rtl)
|
98 |
|
|
port map(
|
99 |
|
|
clk16x => clk16x,
|
100 |
|
|
srst => srst,
|
101 |
|
|
txd => txd,
|
102 |
|
|
tx_data => tx_data,
|
103 |
|
|
tx_stb => tx_stb,
|
104 |
|
|
or_err => or_err,
|
105 |
|
|
tx_idle => tx_idle
|
106 |
|
|
);
|
107 |
|
|
|
108 |
|
|
end rtl;
|