zoukankan      html  css  js  c++  java
  • verilog编码规范

    verilog编码规范

    1.Register with Rising-Edge Coding Example (Verilog)

      Flip-Flops and Registers Control Signals
      Flip-Flops and Registers control signals include:
      • Clocks
      • Asynchronous and synchronous set and reset signals
      • Clock enable

    Filename: registers_1.v
    // 8-bit Register with
    // Rising-edge Clock
    // Active-high Synchronous Clear
    // Active-high Clock Enable
    // File: registers_1.v
    module registers_1(d_in,ce,clk,clr,dout);
    input [7:0] d_in;
    input ce;
    input clk;
    input clr;
    output [7:0] dout;
    reg [7:0] d_reg;
    always @ (posedge clk)
    begin
      if(clr)
        d_reg <= 8'b0;
      else if(ce)
        d_reg <= d_in;
    end
    assign dout = d_reg;
    endmodule

    2.Latch With Positive Gate and Asynchronous Reset Coding Example (Verilog)

    Filename: latches.v
    // Latch with Positive Gate and Asynchronous Reset
    // File: latches.v
    module latches (
      input G,
      input D,
      input CLR,
      output reg Q
    );
    always @ *
    begin
      if(CLR)
        Q = 0;
      else if(G)
        Q = D;
    end
    endmodule

     3.Tristate Description Using Concurrent Assignment Coding Example (Verilog)

    Filename: tristates_2.v
    // Tristate Description Using Concurrent Assignment
    // File: tristates_2.v
    //
    module tristates_2 (T, I, O);
    input T, I;
    output O;
    assign O = (~T) ? I: 1'bZ;
    endmodule

    4.Tristate Description Using Combinatorial Always Block Coding Example(Verilog)

    Filename: tristates_1.v
    // Tristate Description Using Combinatorial Always Block
    // File: tristates_1.v
    //
    module tristates_1 (T, I, O);
    input T, I;
    output O;
    reg O;
    always @(T or I)
    begin
      if (~T)
        O = I;
      else
        O = 1'bZ;
    end
    endmodule

    5.Shift Register Coding Example One (Verilog)

      Static Shift Register Elements
      A static Shift Register usually involves:
      • A clock
      • An optional clock enable
      • A serial data input
      • A serial data output

    Filename: shift_registers_0.v
    // 8-bit Shift Register
    // Rising edge clock
    // Active high clock enable
    // Concatenation-based template
    // File: shift_registers_0.v
    module shift_registers_0 (clk, clken, SI, SO);
    parameter WIDTH = 32;
    input clk, clken, SI;
    output SO;
    reg [WIDTH-1:0] shreg;
    always @(posedge clk)
    begin
        if (clken)
            shreg = {shreg[WIDTH-2:0], SI};
    end
    
    assign SO = shreg[WIDTH-1];
    
    endmodule    

     

  • 相关阅读:
    ASP.NET MVC下的四种验证编程方式
    tp框架下,数据库和编辑器都是utf-8, 输出中文却还是乱码
    按拼音首字母排序
    PHP 文件导出(Excel, CSV,txt)
    RedisDesktopManager 可视化工具提示:无法加载键:Scan..
    window下redis如何查看版本号
    jQuery 防止相同的事件快速重复触发
    input中加入搜索图标
    JS搜索商品(跟外卖app店内搜索商品一样) ,keyup函数和click函数调用
    JS正则对象 RegExp(有变量的时候使用),用来匹配搜索关键字(标红)
  • 原文地址:https://www.cnblogs.com/chensimin1990/p/7878283.html
Copyright © 2011-2022 走看看