当前位置:文档之家› 曼彻斯特编解码器

曼彻斯特编解码器

工具软件实训报告项目名称:曼彻斯特编解码器指导老师:系科:专业:姓名:学号:目录:一:实训要求 (3)二:实训原理 (3)三:实训思路 (4)四:实训步骤 (4)五:原理图、仿真结果图以及结论分析 (5)1.曼彻斯特编解码器(实现16bit数据的编解码) (5)1.1曼彻斯特编解码器电路原理图: (5)1.2模块详解 (6)1.3仿真图以及分析 (10)六:个人总结 (11)一:实训要求(1)通过学习原理图输入设计的方法掌握使用工具软件Quartus Ⅱ设计小型数字电路;(2)查阅文献,了解曼彻斯特编解码器的基本原理,并提出在Quartus Ⅱ软件环境下用VHDL进行仿真的方案。

(3)完成设计对编码器的要求:能够对输入的16bit数据进行曼彻斯特编码,输入有时钟、使能、16bit并行数据、写信号等;输出有编码结束和曼彻斯特编码信号(都为1位信号)等。

(4)完成设计对解码器要求:能够把输入的串行曼彻斯特码解码成原先的并行数据,输入有时钟、曼彻斯特码输入(1bit)、使能信号等,输出有提取的同步时钟信号、解码完成(1bit),并行数据(16bit)等。

二:实训原理曼彻斯特编码,也叫做相位编码(PE),是一个同步时钟编码技术,在以太网媒介系统中,被物理层使用来编码一个同步位流的时钟和数据。

它的每一个数据比特都是由至少一次电压转换的形式所表示的。

在曼彻斯特编码中,每一位的中间有一跳变,位中间的跳变既作为时钟信号,又作为数据信号。

按照曼彻斯特码在IEEE 802.4(令牌总线)以及IEEE 802.3 (以太网)中的规定,本次实训将从高电平到低电平的跳变表示“0”,从低电平到高电平的跳变表示“1”。

三:实训思路以下为曼彻斯特编解码器的实现框图:基准时钟分频器电路时钟1时钟2时钟3曼彻斯特编码器曼彻斯特解码器曼彻斯特码输出源码输出数据产生有上图可知,此次的曼彻斯特编解码电路包括三个部分:信号产生部分、编码电路部分和解码电路部分。

其中,信号产生部分用来产生一个循环的16位二进制数据编码作为普通的信号输入;编码部分则将输入的信号编码为曼彻斯特码,然后输出显示;解码部分负责将获得的曼彻斯特码解码成普通的二进制数据编码。

三个相对独立的模块相互协同工作,共同完成曼彻斯特编解码的工作。

四:实训步骤(1)建立工程;(2)编写VHDL文件,建立目标器件;(3)绘制电路原理图并编译;(4)进行仿真以及分析仿真后的波形文件; (5)完成实训报告。

五:原理图、仿真结果图以及结论分析1.曼彻斯特编解码器(实现16bit 数据的编解码) 1.1曼彻斯特编解码器电路原理图:clkclk0clk1clk2clks inst clk1dataindataoutmcodeinst1clk0dedataindedataout count[2..0]mdecode inst3VCCCLKINPUT data_in OUTPUTdecode_dataOUTPUTcode_dataOUTPUTclk2datainrecycle inst71.2模块详解1.2.1分频器模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity clks isport(clk:in std_logic; --基准时钟clk0,clk1,clk2:buffer std_logic); --分频出的三个时钟,分别输入循环编--码模块、曼彻斯特编码模块、曼彻斯特解码模块end clks;architecture behav of clks issignal a:integer:=0;signal b:integer:=0;beginprocess(clk)beginclk0<=clk;end process;process(clk)beginif clk'event and clk='1' thenif a=2 thena<=0;clk1<='1';elsea<=a+1;clk1<='0';end if;end if;end process;process(clk)beginif clk'event and clk='1' thenif b=5 thenb<=0;clk2<='1';elseb<=b+1;clk2<='0';end if;end if;end process;end behav;1.2.2循环编码模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity recycle isport(clk2:in std_logic;datain:out std_logic);end recycle;architecture behav of recycle issignal i:integer:=0;beginprocess(clk2)beginif clk2'event and clk2='1' thenif i=15 theni<=0;elsei<=i+1;end if;end if;end process;process(clk2)beginif clk2'event and clk2='1' thencase i iswhen 0 => datain<='1';when 1 => datain<='0';when 2 => datain<='1';when 3 => datain<='1';when 4 => datain<='0';when 5 => datain<='1';when 6 => datain<='0';when 7 => datain<='0';when 8 => datain<='0';when 9 => datain<='0';when 10 => datain<='1';when 11 => datain<='1';when 12 => datain<='0';when 13 => datain<='1';when 14 => datain<='0';when 15 => datain<='0';when others => datain<=null;end case;end if;end process;end behav;1.2.3曼彻斯特编码模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity mcode isport(clk1: in std_logic;datain: in std_logic;dataout: out std_logic);end mcode;architecture behav of mcode issignal con:std_logic_vector(1 downto 0);signal s:std_logic;beginprocess(clk1)beginif clk1'event and clk1='1' thenif datain='1' thencon<="01"; --上升沿表示'1'elsecon<="10"; --下降沿表示'0'end if;end if;end process;process(clk1)Beginif clk1'event and clk1='1' thenif s='1' thendataout<=con(1);s<=not s;elsedataout<=con(0);s<=not s;end if;end if;end process;end behav;说明:曼彻斯特码是用“01”和“10”来表示普通二进制数据中的“1”和“0”的,因此在实际电路设计中,我们很容易产生一个和数据信号具有相同频率的检测时钟,用来对传入的数据信号进行检测。

当检测信号检测到输入信号是“1”时,选择器就输出“01”给寄存器,由寄存器完成并串转化功能,然后再将串行数据输出;当输入信号是“0”时,选择器就输出“10”给寄存器由寄存器完成并串转化功能,然后再将串行数据输出,这样,输出的串行数据就是曼彻斯特码。

1.2.4曼彻斯特解码模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity mdecode isport(clk0:in std_logic;dedatain: in std_logic;dedataout:out std_logic;count: buffer std_logic_vector(2 downto 0));end mdecode;architecture behav of mdecode issignal con:std_logic_vector(1 downto 0);beginprocess(clk0)beginif clk0'event and clk0='1' thenif count=5 thencount<="000";elsecount<=count+1;end if;end if;end process;process(clk0)beginif clk0'event and clk0='1' thencon(1)<=con(0);con(0)<=dedatain;end if;end process;process(clk0)beginif clk0'event and clk0='1' thenif count=4 thenif con="10" thendedataout<='0';elsif con="01" thendedataout<='1';end if;end if;end if;end process;end behav;说明:曼彻斯特解码电路设计的关键是如何准确地从曼彻斯特码的数据流中提取出“10”和“01”信号,并且把它们转换成普通二进制编码中的“0”和“1”。

相关主题