This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > FPGA Technical Tutorials > Design Recipes for FPGAs Using Verilog and VHDL > Serial Communications > Implementing the Manchester Encoding Scheme using VHDL

TABLE OF CONTENTS

Xilinx FPGA FPGA Forum

Implementing the Manchester Encoding Scheme using VHDL

FONT SIZE : AAA

The VHDL code for the synchronous Manchester encoder is shown here:

1 library ieee;

2 use ieee.std_logic_1664.all; 34 entity manchester_encoder is

5 port ( 6 clk : in std_logic;

7 d : in std_logic;

8 q : out std_logic

9 );

10 end entity manchester_encoder;

11

12 architecture basic of manchester_encoder is

13 signal lastd : std_logic := 0 ;

14 begin

15 p1: process ( clk )

16 begin

17 if clk’event and clk=’1’ then

18 if (d=0 ) then

19 q <= 1 ;

20 lastd <= 0 ;

21 elsif (d=1) then

22 q <= 0 ;

23 lastd <= 1 ;

24 else

25 q <= x ;

26 lastd <= x ;

27 end if;

28 else

29 if ( lastd = 0 ) then

30 q <= 0 ;

31 elsif ( lastd = 1 ) then

32 q <= 1 ;

33 else

34 q <= x ;

35 end if

36 end if;

37 end process p1;

38 end architecture basic;

The XOR implementation of the Manchester encoder is much simpler and this listing is shown as follows: 

1 library ieee;

2 use ieee.std_logic_1664.all; 34 entity manchester_encoder is

5 port ( 6 clk : in std_logic;

7 d : in std_logic;

8 q : out std_logic

9 );

10 end entity manchester_encoder;

11

12 architecture basic of manchester_encoder is

13 begin

14 q <= d xor clk;

15 end architecture basic;

Decoding the Manchester data stream is also a choice between asynchronous and synchronous approaches. We can use a local clk and detect the values of the input to evaluate whether the values on the rising and falling edges are 0 or 1, respectively, and ascertain the values of the data as a result, but clearly this is dependent on the transmitter and receiver clocks being synchronized to a reasonable degree. Such a simple decoder could look like this:

1 entity manchester_decoder is

2 port ( 3 clk : in std_logic;

4 d : in std_logic;

5 q : out std_logic

6 );

7 end entity manchester_decoder;

89 architecture basic of manchester_decoder is

10 signal lastd : std_logic := 0 ;

11 begin

12 p1 : process (clk)

13 begin

14 if clk’event and clk=’1’ then

15 lastd <= d;

16 else

17 if (lastd = 0 ) and (d = 1 ) then

18 q <= 1 ;

19 elsif (lastd = 1 ) and (d= 0 ) then

20 q <= 0 ;

21 else

22 q <= x ;

23 end if;

24 end if;

25 end process p1;

26 end architecture basic;

In this VHDL model, the clock is at the same rate as the transmitter clock, and the data should be sent in packets to ensure that the data is not sent in blocks that are too large, such that the clock can get out of sync, and also that the data can be checked for integrity to correct for mistakes or the clock on the receiver being out of phase.





  • XC5VLX110T-2FF1738C

    Manufacturer:Xilinx

  • FPGA Virtex-5 LXT Family 110592 Cells 65nm Technology 1V 1738-Pin FCBGA
  • Product Categories: FPGAs (Field Programmable Gate Array)

    Lifecycle:Active Active

    RoHS: No RoHS

  • XCV300-4PQG240C

    Manufacturer:Xilinx

  • FPGA Virtex Family 322.97K Gates 6912 Cells 250MHz 0.22um Technology 2.5V 240-Pin HSPQFP EP
  • Product Categories:

    Lifecycle:Obsolete -

    RoHS:

  • XC2V2000-5FGG676C

    Manufacturer:Xilinx

  • FPGA Virtex-II Family 2M Gates 24192 Cells 750MHz 0.15um Technology 1.5V 676-Pin FBGA
  • Product Categories: FPGAs (Field Programmable Gate Array)

    Lifecycle:Obsolete -

    RoHS:

  • XC3090-70PQ160C

    Manufacturer:Xilinx

  • FPGA XC3000 Family 6K Gates 320 Cells 70MHz 5V 160-Pin PQFP
  • Product Categories:

    Lifecycle:Obsolete -

    RoHS: No RoHS

  • XCS30XL-4TQG144I

    Manufacturer:Xilinx

  • XCS30XL-4TQG144I - NOT RECOMMENDED for NEW DESIGN
  • Product Categories: CPLD/FPGA

    Lifecycle:Obsolete -

    RoHS: -

Need Help?

Support

If you have any questions about the product and related issues, Please contact us.