Home.Verilog.Digital Design.Digital Basics.Python.RF Basics.
Custom Search

Legal Disclaimer

Chip Designing for ASIC/ FPGA Design engineers and Students
Digital-logic Design...  Dream for many students… start learning front-end…

Legal Disclaimer

@TYH :- 4G LTE Long Term Evolution Tutorial, CloudComputing
Verilog Tutorial.
Get Noticed:- Submit your own content to be published on fullchipdesign.com

Send it to fullchip@gmail.com

Digital Basics Tutorial.

Verilog Initial Statements.

Initial statements with examples are discussed in this section. Also discussed are clocks and resets generation logic using forever loop and not operator.

Statements within initial block are used in Verilog for generating test signals, example clocks, resets etc.

Initial statements can’t be synthesized because actual behavior of hardware is difficult to model using fixed delays. These statements are used only for testbench purposes and to initialize the values at zero simulation time.

Clock & Reset generation code: 

// Register declarations

reg clk_1fs;  

reg clk_1fs_d;  

reg rst_n;


// Use of initial statement to generate clocks 1fs and 1fs_d

initial begin 

     clk_1fs = 0; 

     clk_1fs_d = 0; 

     rst_n = 0;

     #100 rst_n = 1;

     forever begin

         #10 clk_1fs = 1;

         #11 clk_1fs_d = 1;

         #10 clk_1fs = 0;

         #11 clk_1fs_d = 0;






Another example of initial statement to generate clock and reset using not operator.

reg clk;
reg rstn;

/* Initial block to generate clock and reset */
   clk = 0;  rstn = 0;  #100 rstn = 1;
   forever begin
       #10 clk = !clk;  end
Clocks and reset generation in test-bench using Initial statements.  
Counter logic with enable disable logic generation using initial statements.  
Home Verilog Initial stmts IF-ELSE Case stms Readmemh Function Testbench Binary to Gray Clock Crossing Half-adder Full-adder Tristate buffer Adder tb Counter_enable Blocking Operators Shift LSR Random Nos Sync RAM Verilog Tutorial