Gate Level Modeling Part-II (of Verilog HDL)

 ../images/main/bullet_green_ball.gifDesigning Using Primitives //使用门级原语的设计
  

Designing using primitives is used only in library development, where the ASIC vendor provides the ASIC library Verilog description, using Verilog primitives and user defined primitives (UDP).

使用原语的设计只用在库的开发,如ASIC的供应商提供通过Verilog HDL 原语和用户自定义原语构建的Verilog HDL 描述的ASIC 库。

  

space.gif

 ../images/main/bulllet_4dots_orange.gifAND Gate from NAND Gate //与门 来自与非门。
  

space.gif

  ../images/verilog/and_from_nand.gif
  

space.gif

 ../images/main/bullet_star_pink.gifCode //代码
  

space.gif

  

  1 // Structural model of AND gate from two NANDS 
  2 module and_from_nand();
  3 
  4 reg X, Y;
  5 wire F, W;
  6 // Two instantiations of the module NAND
  7 nand U1(W,X, Y);
  8 nand U2(F, W, W);
  9 
 10 // Testbench Code
 11 initial begin
 12   $monitor ("X = %b Y = %b F = %b", X, Y, F);
 13   X = 0;
 14   Y = 0;
 15    #1  X = 1;
 16    #1  Y = 1;
 17    #1  X = 0; 
 18    #1  $finish;
 19 end
 20 
 21 endmodule
You could download file and_from_nand.v here
  

space.gif

  
 X = 0 Y = 0 F = 0
 X = 1 Y = 0 F = 0
 X = 1 Y = 1 F = 1
 X = 0 Y = 1 F = 0
  

space.gif

  
  

space.gif

 ../images/main/bulllet_4dots_orange.gifD-Flip flop from NAND Gate  //使用与非门构建的D触发器
  

space.gif

  ../images/verilog/d_from_nand.gif
  

space.gif

 ../images/main/bullet_star_pink.gifVerilog Code
  

space.gif

  

  1 module dff_from_nand();
  2 wire Q,Q_BAR;
  3 reg D,CLK;
  4 
  5 nand U1 (X,D,CLK) ;
  6 nand U2 (Y,X,CLK) ;
  7 nand U3 (Q,Q_BAR,X);
  8 nand U4 (Q_BAR,Q,Y);
  9 
 10 // Testbench of above code
 11 initial begin
 12   $monitor("CLK = %b D = %b Q = %b Q_BAR = %b",CLK, D, Q, Q_BAR);
 13   CLK = 0;
 14   D = 0;
 15    #3  D = 1;
 16    #3  D = 0;
 17    #3  $finish;
 18 end	
 19 
 20 always  #2  CLK = ~CLK;
 21 
 22 endmodule
You could download file dff_from_nand.v here
  

space.gif

  
 CLK = 0 D = 0 Q = x Q_BAR = x
 CLK = 1 D = 0 Q = 0 Q_BAR = 1
 CLK = 1 D = 1 Q = 1 Q_BAR = 0
 CLK = 0 D = 1 Q = 1 Q_BAR = 0
 CLK = 1 D = 0 Q = 0 Q_BAR = 1
 CLK = 0 D = 0 Q = 0 Q_BAR = 1
  

space.gif

 ../images/main/bulllet_4dots_orange.gifMultiplexer from primitives //使用基本原语构建的多路选择器
  

space.gif

  ../images/verilog/multiplexer.gif
  

space.gif

 ../images/main/bullet_star_pink.gifVerilog Code //verilog代码
  

space.gif

  

  1 module mux_from_gates ();
  2 reg c0,c1,c2,c3,A,B; 
  3 wire Y; 
  4 //Invert the sel signals 
  5 not (a_inv, A); 
  6 not (b_inv, B); 
  7 // 3-input AND gate 
  8 and (y0,c0,a_inv,b_inv); 
  9 and (y1,c1,a_inv,B); 
 10 and (y2,c2,A,b_inv); 
 11 and (y3,c3,A,B); 
 12 // 4-input OR gate 
 13 or (Y, y0,y1,y2,y3); 
 14 
 15 // Testbench Code goes here
 16 initial begin
 17   $monitor (
 18    "c0 = %b c1 = %b c2 = %b c3 = %b A = %b B = %b Y = %b",
 19    c0, c1, c2, c3, A, B, Y);
 20   c0 = 0;
 21   c1 = 0;
 22   c2 = 0;
 23   c3 = 0;
 24   A = 0;
 25   B = 0;
 26    #1  A  = 1;
 27    #2  B  = 1;
 28    #4  A  = 0;
 29    #8  $finish;
 30 end
 31 
 32 always  #1  c0 = ~c0;
 33 always  #2  c1 = ~c1;
 34 always  #3  c2 = ~c2;
 35 always  #4  c3 = ~c3;
 36    
 37 endmodule 
You could download file mux_from_gates.v here
  

space.gif

  
 c0 = 0 c1 = 0 c2 = 0 c3 = 0 A = 0 B = 0 Y = 0
 c0 = 1 c1 = 0 c2 = 0 c3 = 0 A = 1 B = 0 Y = 0
 c0 = 0 c1 = 1 c2 = 0 c3 = 0 A = 1 B = 0 Y = 0
 c0 = 1 c1 = 1 c2 = 1 c3 = 0 A = 1 B = 1 Y = 0
 c0 = 0 c1 = 0 c2 = 1 c3 = 1 A = 1 B = 1 Y = 1
 c0 = 1 c1 = 0 c2 = 1 c3 = 1 A = 1 B = 1 Y = 1
 c0 = 0 c1 = 1 c2 = 0 c3 = 1 A = 1 B = 1 Y = 1
 c0 = 1 c1 = 1 c2 = 0 c3 = 1 A = 0 B = 1 Y = 1
 c0 = 0 c1 = 0 c2 = 0 c3 = 0 A = 0 B = 1 Y = 0
 c0 = 1 c1 = 0 c2 = 1 c3 = 0 A = 0 B = 1 Y = 0
 c0 = 0 c1 = 1 c2 = 1 c3 = 0 A = 0 B = 1 Y = 1
 c0 = 1 c1 = 1 c2 = 1 c3 = 0 A = 0 B = 1 Y = 1
 c0 = 0 c1 = 0 c2 = 0 c3 = 1 A = 0 B = 1 Y = 0
 c0 = 1 c1 = 0 c2 = 0 c3 = 1 A = 0 B = 1 Y = 0
 c0 = 0 c1 = 1 c2 = 0 c3 = 1 A = 0 B = 1 Y = 1

the above original  link:http://www.asic-world.com/verilog/gate2.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值