Verilog: bidirectional switches - EDA Playground
Warning! This exercise has been opened in another tab; autosave has been disabled. Close this tab or refresh to reactivate.

 Languages & Libraries

 Tools & Simulators

 Examples

203


19
 
1
// Code your testbench here
2
// or browse Examples
3
4
module tb;
5
  reg in_out1, ctrl;
6
  wire in_out2, in_out2_if0, in_out2_if1;
7
  
8
  bidirectional_modeling bi_direct(in_out1, ctrl, in_out2, in_out2_if0, in_out2_if1);
9
  
10
  initial begin
11
    $monitor("At time = %0d: ctrl = %b, in_out1 = %b, in_out2 = %b, in_out2_if0 = %b, in_out2_if1 = %b", $time, ctrl, in_out1, in_out2, in_out2_if0, in_out2_if1);
12
    
13
    in_out1 = 0; ctrl = 0;
14
    
15
    #5 in_out1 = 1;
16
    #5 ctrl = 1;
17
    #5 in_out1 = 0;
18
  end
19
endmodule
xxxxxxxxxx
1
 
1
// Code your design here
2
module bidirectional_modeling (
3
  input in_out1, ctrl,
4
  output in_out2, in_out2_if0, in_out2_if1);
5
  
6
  tran t1(in_out1, in_out2);
7
  tranif0 t2(in_out1, in_out2_if0, ctrl);
8
  tranif1 t3(in_out1, in_out2_if1, ctrl);
9
endmodule
912 views and 0 likes     
 
Example for bidirectional switches modeling

Example for bidirectional switches modeling

150:0