zoukankan      html  css  js  c++  java
  • 1组合逻辑电路基本门电路

    1.1基本门电路

    1.1.1结构化描述方式

    代码如下

    View Code
     1 module logics
    2 (
    3 input iA,
    4 input iB,
    5 output oAnd,
    6 output oOr,
    7 output oNot
    8 );
    9
    10 and and_inst(oAnd,iA,iB);
    11 or or_inst(oOr,iA,iB);
    12 not not_inst(oNot,iA);
    13
    14 endmodule

    最底层的是门级原语and or not

    RTL级视图

    testbench如下

    View Code
     1 `timescale 1 ns/ 1 ns
    2 module logics_tb();
    3
    4 reg ia;
    5 reg ib;
    6
    7 wire oAnd;
    8 wire oOr;
    9 wire oNot;
    10
    11 initial
    12 begin
    13 ia=0;
    14 #40 ia=1;
    15 #40 ia=0;
    16 #40 ia=1;
    17 #40 ia=0;
    18 end
    19
    20 initial
    21 begin
    22 ib=0;
    23 #40 ib=0;
    24 #40 ib=1;
    25 #40 ib=1;
    26 #40 ib=0;
    27 end
    28
    29 logics logics_inst
    30 (
    31 .iA(ia),
    32 .iB(ib),
    33 .oAnd(oAnd),
    34 .oOr(oOr),
    35 .oNot(oNot)
    36 );
    37
    38 endmodule

    RTL级仿真图形如下

    GATE级仿真图如下

    可见RTL级仿真是理想的,GATE级仿真考虑了延迟和信号开始的不确定。

    1.1.2采用流描述方法

    代码如下

    View Code
     1 module logics
    2 (
    3 input iA,
    4 input iB,
    5 output oAnd,
    6 output oOr,
    7 output oNot
    8 );
    9
    10 assign oAnd=iA&iB;
    11 assign oOr=iA|iB;
    12 assign oNot=~iA;
    13
    14 endmodule

    RTL级视图,仿真图形同上。

    1.1.3 采用行为描述方式

    代码如下

    View Code
     1 module logics
    2 (
    3 input iA,
    4 input iB,
    5 output reg oAnd,
    6 output reg oOr,
    7 output reg oNot
    8 );
    9
    10 always @(*)
    11 begin
    12 oAnd=iA&iB;
    13 oOr=iA|iB;
    14 oNot=~iA;
    15 end
    16
    17 endmodule

    always@()括号内的敏感信号填*,则综合器自动加上敏感信号。

    由于always语句中左边信号都要是寄存器型,故输出信号定义为寄存器型。描述组合逻辑时,always中使用阻塞赋值方式。

    RTL级视图及仿真图形同上。

  • 相关阅读:
    Mono 4.0 Mac上运行asp.net mvc 5.2.3
    ASP.NET SignalR 高可用设计
    .NET Fringe 定义未来
    微软“.Net社区虚拟大会”dotnetConf2015 第二天 无处不在的Xamarin
    微软“.Net社区虚拟大会”dotnetConf2015:关键词:.NET 创新、开源、跨平台
    Mono产品生命周期
    Paket 介绍
    谷歌发布的首款基于HTTP/2和protobuf的RPC框架:GRPC
    Visual Studio 2015 CTP6 发布
    皮裤原理和运营微信公众号dotNET跨平台
  • 原文地址:https://www.cnblogs.com/yuesheng/p/2123224.html
Copyright © 2011-2022 走看看