WXing 发表于 2010-4-20 20:46:58

双向端口的仿真

按照duoduo(在此表示由衷的感谢)的《CPLD/FPGA中双向总线的实现方法》中的程序,如下:
/*****************************************/
module BiBus(hwr_,hrd_,hd,swr_,srd_,sd);
input hwr_;
input hrd_;
inout hd;
output swr_;
output srd_;
inout sd;
/*****************************************/
wire hd_out_oe;
reg hd_out;
wire sd_out_oe;
reg sd_out;
/*****************************************/
always @(hwr_) begin
if(!hwr_) sd_out=hd;
end
/*****************************************/
always @(hrd_) begin
if (!hrd_) hd_out=sd;
end
/*****************************************/
assign swr_=hwr_;
assign srd_=hrd_;
assign sd_out_oe=!hwr_;
assign hd_out_oe=!hrd_;
assign hd=hd_out_oe?hd_out:8'hzz;
assign sd=sd_out_oe?sd_out:8'hzz;
/*****************************************/
endmodule
/*****************************************/
设计双向总线,为什么仿真总不对,波形如下:
http://cache.amobbs.com/bbs_upload782111/files_28/ourdev_547832.jpg
(原文件名:1.jpg)

http://cache.amobbs.com/bbs_upload782111/files_28/ourdev_547833.jpg
(原文件名:2.jpg)
仿真时设置为写信号为低,读信号为高,应该是sd=hd才对啊,仿真时已把hd值为11111111了,为什么输出的sd为高阻状态,而且swr_和srd_的状态也不对,高手指教。
页: [1]
查看完整版本: 双向端口的仿真