Icarus_Verilog

This repo contains code snippets written in verilog as part of course Computer Architecture of my university curriculum

View on GitHub

Lab Sheet 3

LearningObjectives

Non blocking vs Blocking - Race Conditions

    //Illustration 1: Two concurrent always blocks with blocking
    //statements
    always @(posedge clock)
        a = b;
    always @(posedge clock)
        b = a;
    //Illustration 2: Two concurrent always blocks with nonblocking
    //statements
    always @(posedge clock)
        a <= b;
    always @(posedge clock)
        b <= a;
//Process nonblocking assignments by using temporary variables
    always @(posedge clock) begin
        //read operation
        //store values of right-hand-side expressions in temporary variable:
        temp_a = a ; temp_b = b;
        //Write operation
        //Assign values of temporary variables to left-hand-side variables
        a = temp-b; b = temp-a ;
    end

Block Types

Sequential

Parallel

    //Parallel blocks with deliberate race condition
    reg x, y; reg [1:0] z, w;
    initial
        fork
            x = 1'bO; y = 1'b1;
            z = {x,y};
            w = {y,x};
        join