---
# System prepended metadata

title: SoC Laboratory Assignment W4
tags: [Assignment, SoC Laboratory]

---

# SoC Laboratory Assignment W4

## 1. Testbench

#### a) Do the two always block behave the same?

No. Nonblocking statements (with dependency) in different sequences will cause different simulation results.

---

#### b) Which of the following code snippets is race free

A is race free.
B initializes `clk` with `0` and `1` at the same time.
C passes the values `2` and `9` to `x` in different `always` blocks simultaneously.
D cannot determine the sequence of two processes.

---

## 2. Delay

#### c) Draw the Timing Waveform for the 3 cases

* A
![delay_A](https://hackmd.io/_uploads/rJYaP9rpke.png)
* B & C
![delay_BC](https://hackmd.io/_uploads/By9NF5B6Je.png)


---

## 3. Blocking/nonblocking

#### d) Asynchronous and synchronous reset at time zero

1. Asynchronous reset
    * clock_1_nonblocking
    * reset_blocking
2. Synchronous reset
    * clock_1
    * reset_nonblocking

---

#### e) Rewrite the Testbench code to generate the desired rdata sequence

```
// Test bench
task tx;
    input value;
    begin
        data <= value;
        @(posedge clk);
    end
endtask

tx(8'h05);
tx(8'h06);
tx(8'h07);
```

