双向端口(inout)可以通过引脚复用来节省引脚。
在控制信号控制下,inout既可作为输入input也可作为输出output,因此对其仿真描述不当可能会引起仿真错误。当然,不只在testbench中,在程序中对inout口一般也是要做特殊处理的。
testbench:
`timescale 1ns / 1ps
// Company:
// Engineer:
//
// Create Date: 12:01:57 07/11/2017
// Design Name: work
// Module Name: C:/Users/gao/Desktop/isetest/work/testbench.v
// Project Name: work
// Target Device:
// Tool versions:
// Description:
//
// Verilog Test Fixture created by ISE for module: work
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
module testbench;
// Inputs
reg clk;
reg rst;
// Outputs
wire inout_vld;
// Bidirs
wire [3:0] inout_data;
reg [3:0] data_in;
initial begin
clk = 0;
forever #5 clk = ~clk;
end
initial begin
rst = 0;
#7 rst = 1;
#16 rst = 0;