Foundation Express infers a three-state driver when you assign the value of z to a variable. The z value represents the high-impedance state. Foundation Express infers one three-state driver per block. You can assign high-impedance values to single-bit or bused variables.
Foundation Express generates an inference report that shows information about inferred devices.
The following example shows a three-state inference report.
Three-State Device Name | Type | MB |
OUT1_tri | Three-State Buffer | N |
The first column of the report indicates the name of the inferred three-state device. The second column of the report indicates the type of three-state device that Foundation Express inferred.
Foundation Express always infers a three-state driver when you assign the value of z to a variable. Foundation Express does not provide any means of controlling the inference.
This section contains Verilog examples that infer the following types of three-state drivers.
This section shows a template for a simple three-state driver. In addition, this section supplies examples of how allocating high-impedance assignments to different blocks affects three-state inference.
The following example provides the Verilog template for a simple three-state driver. Foundation Express generates the inference report shown in the inference report example for a simple three-state driver. The figure Three-State Driver shows the inferred three-state driver.
module three_state (ENABLE, IN1, OUT1);
input IN1, ENABLE;
output OUT1;
reg OUT1;
always @(ENABLE or IN1) begin
if (ENABLE)
OUT1 = IN1;
else
OUT1 = 1'bz; //assigns high-impedance state
end
endmodule
The following example shows an inference report for a simple three-state driver.
Three-State Device Name | Type | MB |
OUT1_tri | Three-State Buffer | N |
The following example shows how to place all high-impedance assignments in a single block. In this case, the data is gated and Foundation Express infers a single three-state driver. An inference report for a single process follows the example. The figure Inferring One Three-State Driver shows the schematic the code generates.
module three_state (A, B, SELA, SELB, T);
input A, B, SELA, SELB;
output T;
reg T;
always @(SELA or SELB or A or B) begin
T = 1'bz;
if (SELA)
T = A;
if (SELB)
T = B;
end
endmodule
The following example shows a single block inference report.
Three-State Device Name | Type | MB |
T_tri | Three-State Buffer | N |
The following example shows how to place each high-impedance assignment in a separate block. In this case, Foundation Express infers multiple three-state drivers. The inference report for two three-state drivers follows the example. The figure Inferring Two Three-State Drivers shows the schematic the code generates.
module three_state (A, B, SELA, SELB, T);
input A, B, SELA, SELB;
output T;
reg T;
always @(SELA or A)
if (SELA)
T = A;
else
T = 1'bz;
always @(SELB or B)
if (SELB)
T = B;
else
endmodule
The following example shows an inference report for two three-state drivers..
Three-State Device Name | Type | MB |
T_tri | Three-State Buffer | N |
Three-State Device Name | Type | MB |
T_tri2 | Three-State Buffer | N |
The following example shows an inference report for two three-state drivers.
When a variable is registered in the same block in which it is three-stated, Foundation Express also registers the enable pin of the three-state gate.
The following example shows this type of code, and the inference report for a three-state driver with registered enable follows the example. The figure Three-State Driver with Registered Enable shows the schematic the code generates.
module ff_3state (DATA, CLK, THREE_STATE, OUT1);
input DATA, CLK, THREE_STATE;
output OUT1;
reg OUT1;
always @ (posedge CLK) begin
if (THREE_STATE)
OUT1 = 1'bz;
else
OUT1 = DATA;
end
endmodule
The following example shows an inference report for a three-state driver with registered enable.
Three-state Device Name | Type | MB |
OUT1_tri OUT1_tr_enable_reg | Three-State Buffer Flip-flop (width 1) | N N |
In the above figure, the three-state gate has a register on its enable pin. The following example uses two blocks to instantiate a three-state gate with a flip-flop only on the input. The inference report for a three-state driver without registered enable follows the example. The figure Three-State Driver without Registered Enable shows the schematic the code generates.
module ff_3state (DATA, CLK, THREE_STATE, OUT1);
input DATA, CLK, THREE_STATE;
output OUT1;
reg OUT1;
reg TEMP;
always @(posedge CLK)
TEMP = DATA;
always @(THREE_STATE or TEMP)
if (THREE_STATE)
OUT1 = TEMP;
else
OUT1 = 1'bz;
endmodule
The following example shows an inference report for a three-state driver without registered enable.
Three-State Device Name | Type | MB |
OUT1_tri | Three-State Buffer | N |
You can use the Z value in the following ways.
You cannot use the z value in an expression, except for comparison to z. Be careful when using expressions that compare to the z value. Foundation Express always evaluates these expressions to FALSE, and the pre- and post-synthesis simulation results might differ. For this reason, Foundation Express issues a warning when it synthesizes such comparisons.
The following example shows the incorrect use of the z value in an expression.
OUT_VAL = (1'bz && IN_VAL);
The following example shows the correct use of the z value in an expression.
if (IN_VAL == 1'bz) then