In DUT:-
Code Verilog - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| module Dut
input a,b;
input [1:0] s1;
output out
always@(s1 or a or b)
begin
if(s1)
out = a;
else
out =b;
In TestBench:
module TB;
output reg a,b;
output reg[1:0] s1;
input out;
Dut d1(.a(a), .b(b), .s1(s1), .out(out));
initial
begin
#50 s1=2'b10, a=1,b=0;
#50 s1=2'b11, a=1,b=0;
#50 s1=2'b01, a=1,b=0;
#50 s1=2'b00, a=1,b=0; |
why the o/p = 1, When i drive s1=2'b10 and what is the reason? On what basis it will be executed?
why the o/p = 1, When i drive s1=2'b11 and what is the reason? On what basis it will be executed?
why the o/p = 1, When i drive s1=2'b01 and what is the reason? On what basis it will be executed?
why the o/p = 0, When i drive s1=2'b00 and what is the reason? On what basis it will be executed?
In another case width of s1 is a 3 bit vector in both DUT and Testbench and apply different stimulus like
#50 s1 =3'b0x1; a=1;b=0;
#50 s1 =3'b1zz; a=1;b=0;
#50 s1 =3'b01z; a=1;b=0;
#50 s1 =3'bzzz; a=1;b=0;
#50 s1 =3'b01x; a=1;b=0;
#50 s1 =3'b1zx; a=1;b=0;
on what basis if-else statement will be executed?