I am trying to simulate a tri-state latch in Verilog. It appears that the Verilog compiler doesn’t support it.
This is my code:
module vloglatch ( LE, D, OE, Q ) ;
// You will probably want to flush out the nature of these port declarations:
input wire LE;
input wire D;
input wire OE;
output reg Q;
reg latch; // Internal latch to store the value when LE is active
// Latch operation: Latch the input D at the rising edge of LE
always @(posedge LE) begin
latch <= D;
end
// Output operation: Drive Q with the latched value if OE is low, else high-impedance
always @(*) begin
if (OE == 1’b0) begin
Q <= latch;
end else begin
Q <= 1’bz; // High-impedance state when OE is high
end
end
endmodule
And this is the error I received:
%Error-UNSUPPORTED: vloglatch.v:24:14: Unsupported tristate construct: ASSIGNDLY
** : … In instance vloglatch**
** 24 | Q <= 1’bz; **
** | ^~**
** … For error description see Errors and Warnings — Verilator Devel 5.017 documentation**
%Error: Exiting due to 1 error(s)
** … See the manual at Verilator User’s Guide — Verilator Devel 5.017 documentation for more assistance.**
Any ideas on how to go around this problem?