硬件设计及建模—第.pptx
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《硬件设计及建模—第.pptx》由会员分享,可在线阅读,更多相关《硬件设计及建模—第.pptx(42页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、10.1 接口的概念接口反映的是模块与模块之间的互连,对Verilog来说,主要通过模块的端口表现。第1页/共42页10.1 接口的概念module top(input wire clock,resetn,teset_mode);wire 15:0 data,address,program_addr,jump_addr;wire 7:0 instr,next_instr;wire 3:0 slave_instr;wire slave_req,slave_rdy;wire bus_req,bus_grant;wire mem_read,mem_write;write data_rdy;proce
2、ssor proc1(/main_bus ports .data(data),.address(address),.slave_instr(slave_instr),.slave_req(slave_req),.bus_grant(bus_grant),.mem_read(mem_read),.mem_write(mem_write),.bus_req(bus_req),.slave_rdy(slave_rdy),/other ports .jump_addr(jump_addr),.instr(instr),.clock(clock),.resetn(resetn),.test_mode(t
3、est_mode);第2页/共42页10.1 接口的概念 slave slave1(/main_bus ports .data(data),.address(address),.bus_req(bus_req),.slave_ready(slave_ready),.mem_read(mem_read),.mem_write(mem_write),.slave_instr(slave_instr),.slave_req(slave_req),.bus_grant(bus_grant),.data_rdy(data_rdy),/other ports .clock(clock),.resetn(r
4、esetn);dual_port_ram ram(/main_bus ports .data(data),.data_rdy(data_rdy),.address(address),.mem_read(mem_read),.mem_write(mem_write),/other ports .program_addr(program_addr),.data_b(next_instr);第3页/共42页10.1 接口的概念 test_generator test_gen(/main_bus ports .data(data),.address(address),.mem_read(mem_rea
5、d),.mem_write(mem_write),/other ports .clock(clock),.resetn(resetn),.test_mode(test_mode);instruction_reg ir(.program_addr(program_addr),.instr(instr),.jump_addr(jump_addr),.next_instr(next_instr),.clock(clock),.resetn(resetn);endmodule第4页/共42页10.1 接口的概念module processor(/main_bus ports inout wire 15
6、:0 data,output reg 15:0 address,output reg 3:0 slave_instr,output reg slave_req,output reg bus_grant,output wire mem_read,output wire mem_write,input wire bus_req,input wire slave_rdy,/other ports output reg 15:0 jump_addr,input wire 7:0 instr,input wire clock,input wire resetn,input wire test_mode)
7、;./module functionality codeendmodulemodule slave(/main_bus ports inout wire 15:0 data,inout wire 15:0 address,output reg bus_req,output reg slave_rdy,output wire mem_read,output wire mem_write,input wire 3:0 slave_instr,input wire slave_req,input wire bus_grant,input wire data_rdy,/other ports inpu
8、t wire clock,input wire resetn);./module functionality codeendmodule第5页/共42页10.1 接口的概念module dual_port_ram(/main_bus ports inout wire 15:0 data,output wire data_rdy,input wire 15:0 address,input tri0 mem_read,input tri0 mem_write,/other ports input wire 15:0 program_addr,output reg 7:0 data_b);./mod
9、ule functionality codeendmodulemodule test_generator(/main_bus ports output wire 15:0 data,output reg 15:0 address,output reg mem_read,output reg mem_write,/other ports input wire clock,input wire resetn,input wire test_mode);./module functionality codeendmodule第6页/共42页10.1 接口的概念module instruction_r
10、eg(output reg 15:0 program_addr,output reg 7:0 instr,input wire 15:0 jump_addr,input wire 7:0 next_instr,input wire clock,input wire resetn);./module functionality codeendmodule第7页/共42页10.1.1 Verilog模块端口的缺点Verilog模块的端口提供了一种描述设计中模块之间连接关系的方式,这种方式直观明了,但在大型复杂设计中,有很多缺点:在多个模块中必须重复声明端口在不同模块中有声明不匹配的风险设计规范中的
11、一个改动需要修改多个模块在多个模块中通信协议也必须重复 例如有三个模块对一个共享存储器进行读写操作,那么在这三个模块中,读写操作的控制逻辑必须重复描述限制了抽象的自顶向下的设计 用模块端口连接时,设计的具体互连必须在设计周期的早期确定,而不能在一个不需要考虑设计细节的抽象层面上描述。第8页/共42页10.1.2 SystemVerilog接口优势SystemVerilog增加了新的端口类型接口,接口允许许多信号合成一组由一个端口表示,只需在一个地方对组成接口的信号进行声明,使用这些信号的模块只需一个接口类型的端口。interface main_bus;wire 15:0 data;wire 1
12、5:0 address;logic 7:0 slave_instr;logic slave_req;logic bus_grant;logic bus_req;logic slave_rdy;logic data_rdy;logic mem_read;logic mem_write;endinterface第9页/共42页10.1.2 SystemVerilog接口优势module top(input logic clock,resetn,test_mode);logic 15:0 program_addr,jump_addr;logic 7:0 instr,next_instr;main_b
13、us bus();/instance of an interface/(instance name is bus)processor proc1(/main_bus ports .bus(bus),/interface connection/other ports .jump_addr(jump_addr),.instr(instr),.clock(clock),.resetn(resetn),.test_mode(test_mode);第10页/共42页10.1.2 SystemVerilog接口优势 slave slave1(/main_bus ports .bus(bus),/inter
14、face connection/other ports .clock(clock),.resetn(resetn);dual_port_ram ram(/main_bus ports .bus(bus),/interface connection/other ports .program_addr(program_addr),.data_b(next_instr);第11页/共42页10.1.2 SystemVerilog接口优势 test_generator test_gen(/main_bus ports .bus(bus),/interface connection/other port
15、s .clock(clock),.resetn(resetn),.test_mode(test_mode);instruction_reg ir(.program_addr(program_addr),.instr(instr),.jump_addr(jump_addr),.next_instr(next_instr),.clock(clock),.resetn(resetn);endmodule第12页/共42页10.1.2 SystemVerilog接口优势module processor(/main_bus interface port main_bus bus,/interface p
16、ort/other ports output logic 15:0 jump_addr,input logic 7:0 instr,input logic clock,input logic resetn,input logic test_mode);./module functionality codeendmodulemodule slave(/main_bus interface port main_bus bus,/interface port/other ports input logic clock,input logic resetn);./module functionalit
17、y codeendmodulemodule dual_port_ram(/main_bus interface port main_bus bus,/interface port/other ports input logic 15:0 program_addr,output logic 7:0 data_b);./module functionality codeendmodulemodule test_generator(/main_bus interface port main_bus bus,/interface port/other ports input logic clock,i
18、nput logic resetn,input logic test_mode);./module functionality codeendmodule第13页/共42页10.1.3 接口内容接口不仅仅是一组连接线,它也可以封装模块间通信的所有细节。使用接口可以:(1)在一个地方接口中定义通信所需的各个信号和端口;(2)在接口中定义通信协议;(3)在接口中直接建立协议校验和其它验证程序。接口可以包含类型声明、任务、函数、过程块、程序块和断言。接口与模块之间有三个不同点:(1)接口不可以包含设计层次,接口不可以包含模块或原语的实例;(2)接口可以用作模块端口,表示模块间的通信通道,而在端口中使
19、用模块则是非法的(3)接口可以包含“modport”,这使得每个连接到接口上的模块以不同的方式访问接口。第14页/共42页10.2 接口声明接口定义语法与模块相似,接口也可以拥有端口,这些端口将成为接口所描述一组信号的一部分,接口可以包含Verilog和SystemVerilog中任何类型的声明。interface main_bus(input logic clock,resetn,test_mode);wire 15:0 data;wire 15:0 address;logic 7:0 slave_instr;logic slave_req;logic bus_grant;logic bus
20、_req;logic slave_rdy;logic data_rdy;logic mem_read;logic mem_write;endinterface第15页/共42页10.2 接口声明module top(input logic clock,resetn,test_mode);logic 15:0 program_addr,jump_addr;logic 7:0 instr,next_instr;main_bus bus(/instance of an interface .clock(clock),.resetn(resetn),.test_mode(test_mode);proc
21、essor proc1(/main_bus ports .bus(bus),/interface connection/other ports .jump_addr(jump_addr),.instr(instr);./remainder of netlist and module definitions are not listed第16页/共42页10.2 接口声明module top(input logic clock,resetn,test_mode);logic 15:0 program_addr,jump_addr;logic 7:0 instr,next_instr;main_b
22、us bus(.*);processor proc1(.*);slave slave1(.*);instruction_reg ir(.*);test_generator test_gen(.*);dual_port_ram ram(.*,.data_b(next_instr);endmodule/remainder of module definitions are not listed接口实例也可以使用简化的端口连接.name和.*第17页/共42页10.2 接口声明接口名称引用:(1)在模块端口中;(2)在接口实例化中。当接口作为模块的端口时,接口就象模块一样,可以在其定义之前使用,因此
23、不需要考虑源代码的编译顺序。接口可以象模块一样单独定义,接口名称可以在设计的任何层次、任何模块中当作端口使用。接口也可以在嵌套的模块中定义,使用接口只能在这个模块的局部范围内使用。第18页/共42页10.3 将接口用作模块端口显式命名的接口端口:在模块端口可以显式的声明为特定接口类型,显式命名的接口端口只可以连接到同一名称的接口上。interface chip_bus;endinterfacemodule cache(chip_bus pins,input clock);endmodule通用接口端口:通用接口端口用关键字interface定义端口类型,而不是使用特定接口类型,模块实例化时,任
24、何接口都可以连接到通用接口端口上。module ram(interface pins,input clock);endmodule第19页/共42页10.4 接口实例化和连接接口实例化的方式与模块相同,如果接口定义有商品,那么信号可以像模块实例化一样通过端口次序连接方式或端口名称连接方式连接到接口实例上。接口类型的端口必须连接,不能悬空!在模块实例中,声明为接口类型的端口必须连接到一个接口实例或连接到上层的其它接口端口上。SystemVerilog的.name和.*连接方式也适用于接口实例。接口的端口也可以定义为一个接口,从而使接口可以连接到另一个接口上。如AMBA总线可以描述为一个总接口、一
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 硬件 设计 建模
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内