Home Verilog Digital Design Digital Basics Python RF Basics

Legal Disclaimer

Chip Designing for ASIC/ FPGA Design engineers and Students
FULLCHIPDESIGN
Digital-logic Design...  Dream for many students… start learning front-end…
Topics @TYH :- 4G LTE Tutorial, GVIM editor, Smart-Phone, Cloud Computing
FCD
Custom Search

Feedback ? Send it to admin@fullchipdesign.com or join me at fullchip@gmail.com

Legal Disclaimer

Previous.
Next.
Introduction Operators Initial stms Block vs. Non Blk IF-ELSE, CASE FORLOOP File Operations Read .bin format Function Call Testbench Random Numbers Shift Micro-ops Sync RAM Mem Generate Assertions
Verilog Tutorial.
Digital Basics Tutorial.

Register transfer level (RTL) is used to create a high level description of a synchronous digital circuit.

1. Conditional If  - Else statements are used to generate priority logic in RTL. It can be used in both synchronous and combinational logic.

Synchronous priority logic generation:- In this scenario entire logic within always block is executed in parallel with respect to a reference clock. ‘<=‘ operator is called non-blocking operator.

 

Combinational logic generation :- In this scenario the logic is implemented independent to clock. All statements in this block are executed in sequence. ‘=‘ is called blocking operator.

reg r_packet_in;

reg packet_in;

 

always@(posedge clk_1fs or negedge rst_n)

begin

    if (!rst_n) begin

        r_packet_in <= 'b0;

    end

    else begin

        r_packet_in <= packet_in;

    end

End

Check the complete implementation of the above logic in verilog testbench example.

Conditional statements and Counter code

2. Conditional Case Statements and counter code

Case statements are used in RTL design to model states in Finite State Machine and for generating conditional statements based on value of a particular register. Case statement implementation is shown below.

case (r_count) 

    

    10 : begin 

           packet_in = 'haa;

           wr_en = 'b1;

         end 

    11 : begin 

           packet_in = 'hbb;

           wr_en = 'b1;

         end

    12 : begin 

          packet_in = 'hcc;

          wr_en = 'b1;

        end

    13 : begin                  

          packet_in = 'hdd;        

          wr_en = 'b1;            

        end                          

endcase 

 

 

Synchronous Counter Example

// Always block to Implement counters

always@(posedge clk_1fs or negedge rst_n)

begin

    if (!rst_n) begin

        r_packet_in <= 'b0;

        r_count <= 'b0;

        r_rd_count <= 'b0;

        r_wr_en <= 'b0;

        r_rd_en <= 'b0;

    end

    else begin

        r_packet_in <= packet_in;

        r_count <= count + 1 ;

        r_rd_count <= rd_count + 1 ;

        r_wr_en <= wr_en;

        r_rd_en <= rd_en;

 end end

 

Counters are extensively used in synchronous RTL. In current implementation, its used for keeping track of packets. Check the complete usage of the counter code in the test bench example.  
Check the counter code in the test bench example.  
Block vs. Non Blk.
FORLOOP.
Previous                      Next
Interview Questions. Main, FPGA, Digital Fundamentals