hanjingyu2008的个人空间 https://blog.eetop.cn/219089 [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

AHBAPB APB_Slave

已有 460 次阅读| 2019-2-28 19:21 |系统分类:芯片设计



module APB_Slave(
input wire PRESETn,
input wire PCLK,

input wire PSELx,
input wire PENABLE,

input wire PWRITE,
input wire [31:0] PADDR,
input wire [31:0] PWDATA,
output reg [31:0] PRDATA
);

reg [31:0] Slave_Data [31:0];

/*
S0:  0x0000_0000 ~ 0x0000_00ff;
S1:  0x0000_0100 ~ 0x0000_01ff;
S2:  0x0000_0200 ~ 0x0000_02ff;
S3:  0x0000_0300 ~ 0x0000_03ff;
*/

wire [5:0] num = PADDR[7:2];
always @(posedge PCLK or negedge PRESETn)
begin
  if(!PRESETn)  PRDATA <= 32'h00000000;
  else
  begin
    if(PSELx && PENABLE)
    begin
        if(PWRITE)  Slave_Data[num] <= PWDATA;
        else        PRDATA          <= Slave_Data[num];
          
        if(PWRITE)  $display("%m    Write Addr:%x, Reg:%d, Data:%x", PADDR, num, PWDATA);
        else        $display("%m    Read  Addr:%x, Reg:%d, Data:%x", PADDR, num, Slave_Data[num]);
    end
  end   
end // PCLK


endmodule

点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 0

    关注
  • 6

    粉丝
  • 0

    好友
  • 1

    获赞
  • 3

    评论
  • 3128

    访问数
关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-16 03:28 , Processed in 0.015049 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部