• 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    

     

  • 相关阅读:
    BZOJ.2916.[POI1997]Monochromatic Triangles(三元环)
    Codeforces.724G.Xor-matic Number of the Graph(线性基)
    BZOJ.3498.[PA2009]Cakes(三元环 枚举)
    BZOJ.3545.[ONTAK2010]Peaks(线段树合并)
    BZOJ.4919.[Lydsy1706月赛]大根堆(线段树合并/启发式合并)
    BZOJ.2212.[POI2011]Tree Rotations(线段树合并)
    BZOJ.4552.[HEOI2016/TJOI2016]排序(线段树合并/二分 线段树)
    Codeforces.547C.Mike and Foam(容斥/莫比乌斯反演)
    BZOJ.4516.[SCOI2016]幸运数字(线性基 点分治)
    页面置换算法
  • 原文地址:https://www.cnblogs.com/chensimin1990/p/7878283.html
Copyright © 2020-2023  润新知