• 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    

     

  • 相关阅读:
    只要我跑的够快,内卷它就卷不到我,一名高中生是如何做到在疫情下涨薪70%的?
    一个@Transaction哪里来这么多坑?
    基于netty实现一个完整的TFTP服务器
    DBeaver安装和注意要点
    Logstash将ES服务器A数据迁移ES服务器B
    Logstash迁移ES5.6.1一个索引多type类型迁移到ES7.6.2无type类型
    windows下使用filezilla上传文件权限问题
    logstash7.6.2更新已存在的elasticsearch记录
    mysql磁盘空间不足报错
    Kibana中DevTools命令集锦
  • 原文地址:https://www.cnblogs.com/chensimin1990/p/7878283.html
Copyright © 2020-2023  润新知