inout口浅析--1

     首先让我们回顾一下tri-state logic gates,引自维基百科中的解释。

     Three-state, or 3-state, logic gates are a type of logic gates that have three states of the output: high (H), low (L) and high-impedance (Z).The high-impedance state plays no role in the logic, which remains strictly binary. These devices are used on buses also known as the Data Buses of the CPU to allow multiple chips to send data. A group of three-states driving a line with a suitable control circuit is basically equivalent to a multiplexer, which may be physically distributed over separate devices 。

     In electronics, High impedance would mean that the output is effectively disconnected from the circuit

     Synthesis of z (关于高阻状态综合后的结果) 

The z value implies high impedance or  an open circuit.  It is not a normal logic value and 

can only be synthesized by a tri-state bufer.The operation of  the buffer is controlled by an enable signal, oe (for "output enable").  

When  it is  1,  the input is passed to output.  On the other hand, when it is 0, the y output appears  to be an open circuit.

The code of  the tri-state buffer is assign  y  =  (oe)  ?  a-in  :  l'bz; 

   tri-state buffer  最常见的应用就是用来描述,bidirectional ports。

  双向是分时复用,并不可以同时输入输出,因此它是单工的:也就是输

  入的时候,必须禁止输出使能;输出的时候,必须打开输出使能。

  注意:一般情况下,在子模块中,将双向口的拆分为输入和输出两个信号;最终只在顶层模块例化双向口。


     第一种描述 Inout口的方式

    

  即采用两个 tri-state buffer 来描述双向口

      将该模块看成一个介于 system和外设之间的模块,。

      信号说明:  

                data_to_bus是从sys来的想要输出到 data_bus上的数据。

                sdlink 是 tri-state buffer的控制信号.

                data_to_sys是从inout口data_inout接收到的外部数据总线的数据再传给sys的信号.

         当sdlink = 1时,可以认为此时CPU占据总线使用权,将要输出的数据通过 inout口 送到 数据总线上。而此时外设处于 输出高阻状态不占据总线使用权,所以

外设并没有输出数据到data_bus上,因此data_to_sys呈现高阻状态。

          综合后的RTL视图如下所示

           

      testbench文件如下(先做输出data到数据总线的验证)

  仿真结果如下所示:

     (再做从数据总线读回数据送sys).

  testbench部分文件如下所示,适当增加信号,例如用 io_data_reg模拟外部输入sys的总线数据.

   仿真结果如下所示:

       第二种描述 inout口的方式

    

     即 单tri-state buffer描述bid--pors

   

    这两种方式都可用于 描述 现实中的 双向端口,尤其是在描述 双向数据端口的时候。

先说到这,以后再做补充.  如果有 论述 不对 的地方,还请大家帮忙指出。

QQ:117242951

  维基百科网址 http://en.wikipedia.org/wiki/Main_Page

posted on 2011-05-07 10:43  o my god  阅读(671)  评论(1编辑  收藏  举报

导航