mr1victor

在总线设计中,常常要使用到双向端口。在芯片中,与单向端口相比,双向端口能够节约管脚资源,声明为inout,使用三态门实现。

 

描述这个三态门的verilog代码为:

 1 module inout_test (
 2     input wire ctrl,
 3     input wire din,
 4     output wire dout,
 5     inout wire dinout
 6 );
 7     
 8 
 9     assign dinout = ctrl? din : 1\'bz;
10     assign dout = dinout;
11 
12 endmodule

 

inout信号具有以下特征:

1.inout信号不能声明为reg型,因此不能用在always语句中;

2.给inout赋值需要一个印象寄存器,;

3.高阻态不能用于芯片内部,要将逻辑引到引脚处。

 

 1 module inout_test (
 2     input wire clk,
 3     input wire ctrl,
 4     input wire din,
 5     output reg dout,
 6     inout wire dinout
 7 );
 8     
 9     reg din_reg;
10 
11     always @(posedge clk ) begin
12         if (ctrl) begin
13             din_reg <= din;
14         end
15         else
16             dout <= dinout;
17     end
18 
19     assign dinout = ctrl? din_reg : 1\'bz;
20 
21 endmodule

fpga中编译得到电路为

 

疑问:ctrlk到dout_reg的ce端口,编译出来是用mux实现功能,为何不是反相器?

 

分类:

技术点:

相关文章:

  • 2021-07-05
  • 2021-11-02
  • 2021-10-16
  • 2021-04-10
  • 2021-11-18
  • 2022-12-23
  • 2021-11-28
  • 2021-09-10
猜你喜欢
  • 2022-12-23
  • 2021-09-13
  • 2021-11-28
  • 2021-05-19
  • 2021-09-12
  • 2022-12-23
相关资源
相似解决方案