在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 12425|回复: 5

[解决] quartusII曼彻斯特码解码,波形仿真怎么搞不出来呀,,

[复制链接]
发表于 2010-10-26 14:52:34 | 显示全部楼层 |阅读模式
50资产
下边是曼彻斯特解码的Vhdl编程,,,帮忙看看哈,
library ieee ;
use ieee.std_logic_1164.all ;
use ieee.std_logic_arith.all ;
entity md is
port (rst,clk16x,mdi,rdn : in std_logic ;--复位clk1x,no_bits_rcvd,nrz寄存器,,用于时钟,中心采样,,串行输入曼码数据,,控制信号表示可进行一个读操作
dout : out std_logic_vector (7 downto 0) ;
data_ready : out std_logic ) ;--状态信号,表示数据已准备好,保持在数据总线上等待输出
end md ;
architecture v1 of md is
signal clk1x_enable : std_logic ;--使能1x CLOCK接收一个字。高有效
signal mdi1 : std_logic ;
signal mdi2 : std_logic ;--内部寄存器,用于检测mdi的输入边沿,激活clk1x_enable
signal rsr : std_logic_vector (7 downto 0) ;
signal dout_i : std_logic_vector (7 downto 0) ;
signal no_bits_rcvd : unsigned (3 downto 0) ;--控制字大小(位数),及运行译码频率
signal clkdiv : unsigned (3 downto 0) ;
signal nrz : std_logic ;
signal clk1x : std_logic ;
signal sample : std_logic ;--决定接收器对数据进行译码的时刻
begin
-- 创建两个FF寄存器(mdi1,mdi2)接收曼彻斯特信号
process (rst,clk16x)
begin
  if rst = '1' then
   mdi1 <= '0' ;
   mdi2 <= '0' ;
  elsif clk16x'event and clk16x = '1' then
   mdi2 <= mdi1 ;
   mdi1 <= mdi ;
  end if ;
end process ;
-- Enable the clock when an edge on mdi is detected
process (rst,clk16x,mdi1,mdi2,no_bits_rcvd)
begin
if rst = '1' then
  clk1x_enable <= '0' ;
elsif clk16x'event and clk16x = '1' then
  if mdi1 = '0' and mdi2 = '1' then
   clk1x_enable <= '1' ;
  elsif std_logic_vector(no_bits_rcvd) = "1101" then
   clk1x_enable <= '0' ;
  end if ;
end if ;
end process ;
-- Center sample the data at 1/4 and 3/4 points in data cell
sample <= ((not clkdiv(3)) and (not clkdiv(2)) and clkdiv(1) and clkdiv(0)) or (clkdiv(3) and clkdiv(2) and (not clkdiv(1)) and (not clkdiv(0))) ;
-- Decode Manchester data into NRZ
process (rst,sample,mdi2,clk16x,no_bits_rcvd)
begin
  if rst = '1' then
  nrz <= '0' ;
  elsif clk16x'event and clk16x = '1' then
   if std_logic_vector(no_bits_rcvd) > "000" and sample = '1' then
    nrz <= mdi2 xor clk1x ;
   end if ;
  end if ;
end process ;
-- Increment the clock
process (rst,clk16x,clk1x_enable,clkdiv)
begin
  if rst = '1' then
   clkdiv <= "0000" ;
  elsif clk16x'event and clk16x = '1' then
   if clk1x_enable = '1' then
    clkdiv <= clkdiv + "0001" ;
   end if ;
  end if ;
end process ;
clk1x <= clkdiv(3) ;
-- Serial to parallel conversion
process (rst,clk1x,dout_i,nrz)
begin
  if rst = '1' then
   rsr <= "00000000" ;
  elsif clk1x'event and clk1x = '1' then
   rsr <= rsr(6 downto 0) & nrz ;
  end if ;
end process ;
-- Transfer from shift to data register
process (rst,clk1x,no_bits_rcvd)
begin
  if rst = '1' then
   dout_i <= "00000000" ;
  elsif clk1x'event and clk1x = '1' then
   if std_logic_vector(no_bits_rcvd) = "1001" then
    dout_i <= rsr ;
   end if ;
  end if ;
end process ;
-- Track no of bits rcvd for word size
process (rst,clk1x,clk1x_enable,no_bits_rcvd)
begin
  if rst = '1' then
   no_bits_rcvd <= "0000" ;
  elsif clk1x'event and clk1x = '1' then
   if (clk1x_enable = '0') then
    no_bits_rcvd <= "0000" ;
   else
    no_bits_rcvd <= no_bits_rcvd + "0001" ;
   end if ;
  end if ;
end process ;
-- Generate data_ready status signal
process (rst,clk1x,clk1x_enable,rdn)
begin
  if (rst = '1' or rdn = '0') then
   data_ready <= '0' ;
  elsif clk1x'event and clk1x = '1' then
   if (clk1x_enable = '0') then
    data_ready <= '1' ;
   else data_ready <= '0' ;
   end if ;
  end if ;
end process ;
dout <= dout_i ;
end ;
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
问下各位大虾,我感觉程序没啥问题呀,但波形仿真时为啥输出总是00000000呀,[img]file:///D:/我的文档/qq/Users/364366191/Image/MPUNQW@XS6[`FOL8AI}9NUL.jpg[/img]


那几个输入,设成什么样才能输出呢,我是新手,望各位大虾帮忙解决下哈,

 楼主| 发表于 2010-10-26 14:57:22 | 显示全部楼层
帮帮忙啊,各位大哥,要是能仿出来的话,帮忙把波形图发上来哈,
二进制码与曼彻斯特码波形的对比关系如下。
初始数据        发送的值
逻辑 0        0 到1  (比特中心向上跳变)
逻辑 1        1到0  (比特中心向下跳变
图2.4   曼彻斯特编码的规则
 楼主| 发表于 2010-10-26 16:42:53 | 显示全部楼层
替自己再顶下,哎,
 楼主| 发表于 2010-10-27 08:58:34 | 显示全部楼层
ddddddddddddddddddddddddddddddddddddddd
 楼主| 发表于 2010-10-28 13:35:33 | 显示全部楼层
:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(
发表于 2010-10-28 14:28:26 | 显示全部楼层
回复 5# 364366191


    既然你都可以看到你的输出是全零的,你也应该可以看到这个全零时怎么输出的,要有点耐性看看其他信号的输出关系,你可以找到答案的,新手上路除了要有design的能力,自己也应该培养debug的能力,何况是你自己的设计。

ps. 适当的时候还是应该看看关于coding style的东西,如果你现在在做一个同步设计的话不是特别理想。你的clk1x 和clk16x都是时钟,同是你的1x又在和别的信号做逻辑,其实你现在的设计只要一个clk16x做时钟,1x可以用时钟使能来做。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-3-29 15:19 , Processed in 0.033227 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表