Prev Problem
Next Problem

24. Open-Source Line using tri0

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

  • tri0 line declares the output as a wired signal with an implicit pull-down, meaning the line will default to 0 whenever nothing is driving it.
  • When drive_high = 1, the assignment drives the line with 1'b1, actively forcing the line HIGH.
  • When drive_high = 0, the assignment drives 1'bz, releasing the line into high-impedance.
  • Because the line is declared as tri0, the undriven state (Z) automatically resolves to 0.
  • This exactly models an open-source line: it can only pull HIGH, and when released, it naturally returns to LOW.

 

Code

/*Write your code here*/
module open_source_line(
    input  drive_high, 
    output tri0 line       
);
    assign line = (drive_high) ? 1'b1 : 1'bz; 
endmodule

 

Was this helpful?
Upvote
Downvote