AHB_SLAVE.V

module ahb_if(
    //ahb_signals
    hclk,
    hrst_n,
    hsel,
    hwrite,
    hready,
    htrans,
    hburst,
    hsize,
    haddr,
    hwdata,
    hrdata,

    //sram_signal
    bank0_csn,
    bank1_csn,
    write_en,
    sram_addr,
    sram_wdata,
    sram_q0,
    sram_q1,
    sram_q2,
    sram_q3,
    sram_q4,
    sram_q5,
    sram_q6,
    sram_q7
    
);
input    hclk;
input    hrst_n;
input    hsel;
input    hwrite;
input    hready;
input[1:0]    htrans;
input[2:0]    hburst;
input[2:0]    hsize;
input[31:0]   haddr;
input[31:0]   hwdata;
output[31;0] hrdata; 

output[3:0]    bank0_csn;
output[3:0]    bank1_csn;
output         write_en;
output[12:0]    sram_addr;
output[7:0]     sram_wdata;
input[7:0]      sram_q0;
input[7:0]      sram_q1;
input[7:0]      sram_q2;
input[7:0]      sram_q3;
input[7:0]      sram_q4;
input[7:0]      sram_q5;
input[7:0]      sram_q6;
input[7:0]      sram_q7;

parameter    IDLE = 2'b00;
parameter    BUSY = 2'b01;
parameter    NONSEQ = 2'b10;
parameter    SEQ = 2'b11;

wire    bank_sel;
reg         hwrite_r;
reg[1:0]    htrans_r;
reg[2:0]    hburst_r;
reg[2:0]    hsize_r;
reg[31:0]   haddr_r;
reg[3:0]    bank_csn;

assign write_en = ((htrans_r == NONSEQ) || (htrans_r == SEQ)) && hwrite_r && hsel_r;
assign cs_n = !write_en;

assign bank_sel = haddr_r[15];
assign sram_addr = haddr_r[14:2];
assign sram_wdata = hwdata;
assign hrdata = bank_sel ? {sram_q7, sram_q6, sram_q5, sram_q4} : 
                           {sram_q3, sram_q2, sram_q1, sram_q0} ;
assign bank0_csn = (!cs_n && (bank_sel == 0)) ? bank_csn : 4'b1111;
assign bank1_csn = (!cs_n && (bank_sel == 1)) ? bank_csn : 4'b1111;

always@(posedge hclk or negedge rst_n)begin
    if(!hrst_n)begin
        hwrite_r <= 1'b0;
        htrans_r <= 2'b0;
        hburst_r <= 3'b0;
        hsize_r <= 3'b0;
        haddr_r <= 32'b0;
    end
    else if(hsel && hready)begin
            hwrite_r <= hwrite;
            htrans_r <= htrans;
            hburst_r <= hburst;
            hsize_r <= hsize;
            haddr_r <= haddr;
         end
end

always@(*)begin
   if(hszie_r == 3'b10)
        bank_csn = 4'b0000;
   else if(hsize_r == 3'b01)
            begin
                if(haddr[1] == 0)
                    bank_csn = 4'b1100;
                else
                    bank_csn = 4'b0011;
            end
        else if(hsize_r == 3'b00)
                begin
                    case(haddr[1:0])
                        2'b00:bank_csn = 4'b1110;
                        2'b01:bank_csn = 4'b1101;
                        2'b10:bank_csn = 4'b1011;
                        2'b11:bank_csn = 4'b0111;
                        default:bank_csn = 4'b1111;
                    endcase
                end
              else
                bank_csn = 4'b1111;
end

endmodule

Calling tool in ralgen.py: /hpc/simulation/jzhou/awakening_soc/infra/flow/dv/tools/ralgen/../../../../util/regtool.py -s -t /tmp/mct_dv_bb_env-ral_0.1cvwdpui1 /hpc/simulation/jzhou/awakening_soc/design/bb/dv/env/../../data/bb.hjson RAL pkg for bb written to /tmp/mct_dv_bb_env-ral_0.1cvwdpui1. INFO: Wrote dependency graph to /hpc/simulation/jzhou/awakening_soc/scratch/default/gnss_top-sim-vcs/default/sim-vcs/mct_dv_bb_sim_0.1.deps-after-generators.dot WARNING: The file ../../include/yuu_ahb_interface.svi in /hpc/simulation/jzhou/awakening_soc/infra/verif/uvc/yuu_ahb/src/sv/ahb_env.core is not within the directory containing the core file. This is deprecated and will be an error in a future FuseSoC version. A typical solution is to move core file into the root directory of the IP block it describes WARNING: The file ../../include/yuu_ahb_pkg.sv in /hpc/simulation/jzhou/awakening_soc/infra/verif/uvc/yuu_ahb/src/sv/ahb_env.core is not within the directory containing the core file. This is deprecated and will be an error in a future FuseSoC version. A typical solution is to move core file into the root directory of the IP block it describes. WARNING: The file ../../test/ahb_base_seq.sv in /hpc/simulation/jzhou/awakening_soc/infra/verif/uvc/yuu_ahb/src/sv/ahb_env.core is not within the directory containing the core file. This is deprecated and will be an error in a future FuseSoC version. A typical solution is to move core file into the root directory of the IP block it describes. ERROR: Setup failed : Cannot find ../../test/ahb_base_seq.sv in : /hpc/simulation/jzhou/awakening_soc/infra/verif/uvc/yuu_ahb/src/sv
07-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jealky

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值