网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 61IC中国电子在线 >> EDA >> HDL >> 文章正文
  38译码器仿真           ★★★ 【字体:
38译码器仿真
作者:Free    文章来源:Free    点击数:    更新时间:2007-12-30    

 

//--------------------------------------------------------------------------------------------------

// File        : decoder3_8_TB.v

//-------------------------------------------------------------------------------------------------

`timescale 1ns / 1ps

module decoder3_8_tb;

 

//Internal signals declarations:

reg G1;

wire [7:0]Y;

reg G2;

reg [2:0]A;

reg G3;

 

// Unit Under Test port map

 decoder3_8 UUT (

  .G1(G1),

  .Y(Y),

  .G2(G2),

  .A(A),

  .G3(G3));

// -- edit by liwei  -- //

initial

 begin

  G1 = 1;

  G2 = 1;

  G3 = 0;

 

 #100 A <= 3'b010;

 #100 G2 = 0;

 #100 A <= 3'b110;

 #100 A <= 3'b000;

 #100 A <= 3'b001;

 #100 A <= 3'b010;

 #100 A <= 3'b011;

 #100 G1 <= 0;

 #100 G1 <= 1;

 #100 A <= 3'b100;

 #100 A <= 3'b101;

 #100 A <= 3'b110;

 #100 A <= 3'b111;

 end

 //$monitor($realtime,,"ps %h %h %h %h %h ",G1,Y,G2,A,G3);

endmodule

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//-------------------------------------------------------------------------------------------------

// File        : decoder3_8.v

//-------------------------------------------------------------------------------------------------

`timescale 1 ns / 1 ps

//{{ Section below this comment is automatically maintained

//   and may be overwritten

//{module {decoder3_8}}

module decoder3_8 ( G1 ,Y ,G2 ,A ,G3 );

input G1 ;

wire G1 ;

input G2 ;

wire G2 ;

input [2:0] A ;

wire [2:0] A ;

input G3 ;

wire G3 ;

output [7:0] Y ;

reg [7:0] Y ;

reg s;

//}} End of automatically maintained section

// -- edit by liwei  -- //

always @ ( A ,G1, G2, G3)

 begin

  s <= G2 | G3 ;

  if ( G1 == 0)

   Y <= 8'b1111_1111;

  else if ( s)

   Y <= 8'b1111_1111;

  else

   case ( A )

    3'b000 : Y<= 8'b1111_1110;

    3'b001 : Y<= 8'b1111_1101;

    3'b010 : Y<= 8'b1111_1011;

    3'b011 : Y<= 8'b1111_0111;

    3'b100 : Y<= 8'b1110_1111;

    3'b101 : Y<= 8'b1101_1111;

    3'b110 : Y<= 8'b1011_1111;

    3'b111 : Y<= 8'b0111_1111;

   endcase

  end

 

endmodule

注意以下语句中,12之间的并列关系,时钟来临时12是同时执行的。当G1=1G2=1,G3=0时,同时执行12的代码,执行1的结果是,s<=12只执行caseA)语句

 begin

1.  s <= G2 | G3 ;       

2.  if ( G1 == 0)

      Y <= 8'b1111_1111;

    else if ( s)

      Y <= 8'b1111_1111; 

    else

      case ( A )

               欢迎点击进入:TI德州中文网   (国内唯一针对TI应用的中文技术网站)    文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    没有相关文章
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    站长:61IC 湘ICP备05002478号