基于APB slave mux我们可以快速地将多个apb slave连接在APB上面。在实际的设计当中都是采用这样的方式连接多个APB slave的

  • DECODE4BIT - 可以理解为master接收到地址之后,进行译码,通过mux进行选择那个APB slave

module apb_slave_mux
#(
// 定义16个端口的使能信号,默认为1,保证每个slave端口信号能够输入
parameter PORT0_ENABLE = 1,
parameter PORT1_ENABLE = 1,
parameter PORT2_ENABLE = 1,
parameter PORT3_ENABLE = 1,
parameter PORT4_ENABLE = 1,
parameter PORT5_ENABLE = 1,
parameter PORT6_ENABLE = 1,
parameter PORT7_ENABLE = 1,
parameter PORT8_ENABLE = 1,
parameter PORT9_ENABLE = 1,
parameter PORT10_ENABLE = 1,
parameter PORT11_ENABLE = 1,
parameter PORT12_ENABLE = 1,
parameter PORT13_ENABLE = 1,
parameter PORT14_ENABLE = 1,
parameter PORT15_ENABLE = 1
)
(
// 选择信号
input wire [3:0] DECODE4BIT,
input wire PSEL, // 每个slave的输入输出信号
output wire PSEL0,
input wire PREADY0,
input wire [31:0] PRDATA0,
input wire PSLVERR0, output wire PSEL1,
input wire PREADY1,
input wire [31:0] PRDATA1,
input wire PSLVERR1, output wire PSEL2,
input wire PREADY2,
input wire [31:0] PRDATA2,
input wire PSLVERR2, output wire PSEL3,
input wire PREADY3,
input wire [31:0] PRDATA3,
input wire PSLVERR3, output wire PSEL4,
input wire PREADY4,
input wire [31:0] PRDATA4,
input wire PSLVERR4, output wire PSEL5,
input wire PREADY5,
input wire [31:0] PRDATA5,
input wire PSLVERR5, output wire PSEL6,
input wire PREADY6,
input wire [31:0] PRDATA6,
input wire PSLVERR6, output wire PSEL7,
input wire PREADY7,
input wire [31:0] PRDATA7,
input wire PSLVERR7, output wire PSEL8,
input wire PREADY8,
input wire [31:0] PRDATA8,
input wire PSLVERR8, output wire PSEL9,
input wire PREADY9,
input wire [31:0] PRDATA9,
input wire PSLVERR9, output wire PSEL10,
input wire PREADY10,
input wire [31:0] PRDATA10,
input wire PSLVERR10, output wire PSEL11,
input wire PREADY11,
input wire [31:0] PRDATA11,
input wire PSLVERR11, output wire PSEL12,
input wire PREADY12,
input wire [31:0] PRDATA12,
input wire PSLVERR12, output wire PSEL13,
input wire PREADY13,
input wire [31:0] PRDATA13,
input wire PSLVERR13, output wire PSEL14,
input wire PREADY14,
input wire [31:0] PRDATA14,
input wire PSLVERR14, output wire PSEL15,
input wire PREADY15,
input wire [31:0] PRDATA15,
input wire PSLVERR15 ); // 产生使能信号
wire [15:0] en = {
(PORT15_ENABLE ==1),
(PORT14_ENABLE ==1),
(PORT13_ENABLE ==1),
(PORT12_ENABLE ==1),
(PORT11_ENABLE ==1),
(PORT10_ENABLE ==1),
(PORT9_ENABLE ==1),
(PORT8_ENABLE ==1),
(PORT7_ENABLE ==1),
(PORT6_ENABLE ==1),
(PORT5_ENABLE==1),
(PORT4_ENABLE==1),
(PORT3_ENABLE==1),
(PORT2_ENABLE==1),
(PORT1_ENABLE==1),
(PORT0_ENABLE==1)
}; wire [15:0] dec = {
(DECODE4BIT == 4'd15),
(DECODE4BIT == 4'd14),
(DECODE4BIT == 4'd13),
(DECODE4BIT == 4'd12),
(DECODE4BIT == 4'd11),
(DECODE4BIT == 4'd10),
(DECODE4BIT == 4'd9),
(DECODE4BIT == 4'd8),
(DECODE4BIT == 4'd7),
(DECODE4BIT == 4'd6),
(DECODE4BIT == 4'd5),
(DECODE4BIT == 4'd4),
(DECODE4BIT == 4'd3),
(DECODE4BIT == 4'd2),
(DECODE4BIT == 4'd1),
(DECODE4BIT == 4'd0)
}; // PSEL0 - 表示输出的salve选择信号
// PSEL - 拉高表示master要选择一个slave
// en[0] - 对应端口使能,默认是为1
// dec[0] - 对应decode4bit编码值与相应的slave编码值一致
assign PSEL0 = PSEL & en[0] & dec[0];
assign PSEL1 = PSEL & en[1] & dec[2];
assign PSEL2 = PSEL & en[2] & dec[2];
//.......省略中间//省略3~15
assign PSEL15 = PSEL & en[15] & dec[15]; //省略3~15
assign PREADY = ~PSEL |
( dec[ 0] & (PREADY0 | ~en[ 0]) ) |
( dec[ 1] & (PREADY1 | ~en[ 1]) ) |
( dec[ 2] & (PREADY2 | ~en[ 2]) ) |
//....
(dec[15] & (PREADY15| ~en[15]));
//省略3~15
assign PSLVERR = ( PSEL0 & PSLVERR0 ) |
( PSEL1 & PSLVERR1 ) |
( PSEL2 & PSLVERR2 ) |
//...
( PSEL15 & PSLVERR15 ) ;
//省略3~15
assign PRDATA = ( {32{PSEL0 }} & PRDATA0 ) |
( {32{PSEL1 }} & PRDATA1 ) |
( {32{PSEL2 }} & PRDATA2 ) |
//...
( {32{PSEL15 }} & PRDATA15 ) ; endmodule
  • 根据PSEL是否有效以及DECODE4BIT的值,完成16选1,PSEL0~PSEL15有一个或者0个拉高。
  • PREADYm默认为1,当PSEL为1的时候,根据译码结果选择相应的PREADY信号(当端口没有使能的时候en[x] == 0, 对应的PREADYx信号不会被选择)。
  • PSLVERR和PRDATA,选中谁就取谁的

APB Slave Mux的更多相关文章

  1. APB总线

    APB(Advance Peripheral Bus)是AMBA总线的一部分,从1998年第一版至今共有3个版本. AMBA 2 APB Specfication:定义最基本的信号interface, ...

  2. AHB协议整理 AMBA

    本文对AHB协议作了简单整理,整理自两篇文章: AHB总线协议 AHB重点难点总结 1. 简介 AHB总线规范是AMBA总线规范的一部分,AMBA总线规范是ARM公司提出的总线规范,被大多数SoC设计 ...

  3. 接口与协议学习笔记-AMBA片上通信协议_APB_AHB_AXI_AXI4不同版本(二)

    随着深亚微米工艺技术日益成熟,集成电路芯片的规模越来越大.数字IC从基于时序驱动的设计方法,发展到基于IP复用的设计方法,并在SOC设计中得到了广泛应用.在基于IP复用的SoC设计中,片上总线设计是最 ...

  4. STM

    STM(System Trace macrocell) STM是coresight system中的一个trace source,可以提供high-bandwidth的trace data. STM优 ...

  5. DMA-330(一)

    DMA Controller的interface: DMA Controller提供这些feature: 1)instruction set,对DMA transfer进行program 2)AXI ...

  6. 痞子衡嵌入式:Ethos-U55,ARM首款面向Cortex-M的microNPU

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是ARM Ethos-U55. ARM 前几天刚发布了 Cortex-M 家族最新一款内核 - Cortex-M55 以及首款面向 Cor ...

  7. AHB总线和APB总线

    AHB主要用于高性能模块(如CPU.DMA和DSP等)之间的连接,作为SoC的片上系统总线,它包括以下一些特性:单个时钟边沿操作:非三态的实现方式:支持突发传输:支持分段传输:支持多个主控制器:可配置 ...

  8. AHB/APB简介

    AHB AHB总线互联结构图 随着深亚微米工艺技术日益成熟,集成电路芯片的规模越来越大.数字IC从基于时序驱动的设计方法,发展到基于IP复用的设计方法,并在SOC设计中得到了广泛应用.在基于IP复用的 ...

  9. AMBA总线协议AHB、APB、AXI对比分析【转】

    转自:https://blog.csdn.net/ivy_reny/article/details/56274412 一.AMBA概述    AMBA (Advanced Microcontrolle ...

  10. [转]AMBA、AHB、APB、ASB总线简介

    [转]http://www.cnblogs.com/zhaozhong1989/articles/3092140.html 1.前言 随着深亚微米工艺技术日益成熟,集成电路芯片的规模越来越大.数字IC ...

随机推荐

  1. 2021AI量化投资训练营重磅升级,自带编程的优势显而易见

    量化交易规模突破万亿大关 国内量化交易规模快速发展,今年量化基金已突破万亿大关,并且量化私募的整体业绩十分亮眼,过去5年一线量化私募的超额收益基本在20%~30%,量化交易的占比已达到20%-30%( ...

  2. 万界星空科技仓库管理wms系统

    ​ 企业在管理库存时,尤其是生产制造企业,使用传统方式比如纸笔.Excel 管理库存,由于工具和信息化存在局限,导致在管理库存时出现如下问题: 1.通过纸笔记录出入库申请,人为手动计算易出错,数据易丢 ...

  3. CentOS7 安装Python3.9以上版本时。编译报错,原因是openssl版本低

    openssl-1.1.1安装 1.前因 python 导入clickhouse_driver需要import ssl和_ssl,报错 File"/home/oracle/python3/l ...

  4. Config:Spring Cloud分布式配置组件

    Config:Spring Cloud分布式配置组件 问题总结 Config? Config工作原理? Config 的特点? Config+Bus 实现配置的动态刷新? 问题答案 Config Co ...

  5. 别再傻傻地用 ifconfig 查地址了!这条命令足以让你摘掉小白工程师的帽子

    大家好,我是民工哥. 众所周知,在 Linux 系统中,ip 和 ifconfig 这个两命令的功能十分相似,ifconfig 是 net-tools 中已被弃用的一个命令,很多年前就已经没有维护了. ...

  6. HDU 4893 线段树延迟标记

    原题链接 题意 初始有一长度为n,全为0的序列 每次我们可以对这个序列进行三种操作: 1.将某个位置的数加上d 2.输出某个区间的和 3.将某个区间内每个数字变为与其最接近的斐波那契数,如果有两个最相 ...

  7. 详解MRS HBase全局二级索引

    本文分享自华为云社区<MRS HBase全局二级索引原理与使用场景>,作者:学习一下大数据 . 一.HBase二级索引背景介绍 HBase是基于Key-Value的分布式存储数据库,对表中 ...

  8. 十分钟从入门到精通(下)——OBS权限配置

    上一篇我们介绍了OBS权限管理中统一身份认证和企业项目管理,本期我们继续介绍OBS权限管理中的高级桶策略和ACL应用.   您是否也遇到过类似的问题或者困扰? 1.隔壁的主账户给了子用户创建一个桶,但 ...

  9. MES/MOM国内市场现状趋势与新生态模式参考

    本文分享自华为云社区<工业互联网系列(七)MES/MOM国内市场现状趋势与新生态模式参考>,作者:云起MAE . 国内工业互联网平台服务整体围绕数字化及数据价值挖掘的底层逻辑没有变,变的是 ...

  10. 为AR&VR黑科技:以“自由视角”360度尽展舞台唯美

    摘要:看华为的黑科技,如何用"自由视角"让观众感受舞台"风暴"的魅力所在. "风暴"降临 2021年1月9日晚上,我坐在电视机前,等待湖南卫 ...