- Verilog模块的端口提供了一种描述设计中模块之间连接关系的方式,但是在大型复杂的设计中,Verilog模块的端口有许多缺点。这些缺点包括:
- 在多个模块中必须重复声明端口
- 在多个模块中通信协议中也必须重复
- 在不同模块中有声明不匹配的风险
- 设计规范中的一个改动需要修改多个模块
- SystemVerilog相比Verilog增加了一种新的功能强大的端口类型:接口。
interface main_bus;
wire [15:0] data;
wire [15:0] address;
logic [7:0] slave_instruction;
...
endinterface
module tpo(input logic clock,resetN,test_mode);
logic [15:0] program_address,jump_address;
logic [7:0] instruction,next_instruction;
main_bus bus();
processor procl(
.bus(bus),
.jump_address(jump_address),
.instruction(instruction)
);
endmodule
module processo(
main_bus bus,
output logic [15:0] jump_address,
input logic [7:0] instruction
);
endmodule
- 模块端口可以声明为两种类型,显示命名的接口端口和通用接口端口。显示命名的接口端口只可以连接到同一名称的接口上,其他不同定义的接口连接到这个端口就会报错。如果端口声明是通用接口类型,那么这个端口可以连接到任何类型的接口实例上。接口的端口也可以定义为一个接口,这使得接口可以连接到另一个接口上。
interface chip_bus;
...
endinterface
module CACHE(
chip_bus pins,
input clock
)