module CP0(
input clk,
input rst,
input teq_exc,
input mtc0, //CPU instruction is Mtc0
input [:] pc,
input [:] addr, //Specifies CP0 register
input [:] wdata, //Data from GP register to replace CP0 register
input eret, //instruction is ERET(Exception Return)
input [:] cause,
output [:] rdata, //Data from CP0 register for GP register,
output [:] exc_addr //Address for PC at the beginning of an exception
); parameter SYSCALL = 'b1000,
BREAK = 'b1001,
TEQ = 'b1101,
IE = ;
// status = 12,
// cause = 13,
// epc = 14, reg [:] cop0 [:];
wire [:] status = cop0[];
integer i; wire exception = status[]&& ((status[]&&cause==SYSCALL)||
(status[]&&cause==BREAK) ||
(status[]&&cause==TEQ&&teq_exc)); always@(posedge clk or posedge rst) begin
if(rst)begin
for(i=;i<;i=i+)
cop0[i]<=;
end
else begin
if(mtc0)
cop0[addr] <= wdata;
else if(exception)begin
cop0[] <= pc;
cop0[] <= status<<;
cop0[] <= {'b0,cause,2'b0};
end
else if(eret) begin
cop0[] <= status>>;
end
end
end
assign exc_addr = eret?cop0[]:'h4;
assign rdata = cop0[addr]; endmodule

Verilog MIPS32 CPU(五)-- CP0的更多相关文章

  1. Verilog MIPS32 CPU(八)-- 控制器

    Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...

  2. Verilog MIPS32 CPU(六)-- MDU

    Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...

  3. Verilog MIPS32 CPU(七)-- DIV、DIVU

    Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...

  4. Verilog MIPS32 CPU(四)-- RAM

    Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...

  5. Verilog MIPS32 CPU(三)-- ALU

    Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...

  6. Verilog MIPS32 CPU(二)-- Regfiles

    Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...

  7. Verilog MIPS32 CPU(一)-- PC寄存器

    Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...

  8. Verilog MIPS32 CPU(九)-- 顶层文件

    `timescale 1ns / 1ps /////////////////////////////////////////////////////////////////////////////// ...

  9. FPGA Prototyping By Verilog Examples第五章 状态机FSM设计

    上升沿检测电路之Moore型FSM // Listing 5.3module edge_detect_moore ( input wire clk, reset, input wire level, ...

随机推荐

  1. linux weather

  2. HTML5 File API解读

    1,概述 Web应用应该具备处理广泛用户输入问题的能力,例如在Web富应用中,用户希望上传文件到服务器.File API定义了访问文件的基本操作途径,包括文件.文件列表集.错误处理等,同时,File ...

  3. C# WinForm ProgressBar垂直显示进度和从右向左显示进度

    1. 尝试将ProgressBar的RightToLeft属性设置为System.Windows.Forms.RightToLeft.Yes,同时将RightToLeftLayout属性设置为true ...

  4. spring-boot-actuator健康监控

    #健康监控 management.security.enabled=false health.mail.enabled =false http://localhost:54001/autoconfig ...

  5. 解决git报ssh variant 'simple' does not support setting port

    解决办法 在git bash中输入命令 git config --global ssh.variant ssh

  6. C语言增量内存申请 realloc

    void* realloc (void* ptr, size_t size); Reallocate memory block Changes the size of the memory block ...

  7. Linux任务前后台的切换(转)

    Linux任务前后台的切换   Shell支持作用控制,有以下命令实现前后台切换: 1. command& 让进程在后台运行 2. jobs 查看后台运行的进程 3. fg %n 让后台运行的 ...

  8. c3p0、dbcp和proxool比较

    现在常用的开源数据连接池主要有c3p0.dbcp和proxool三种,其中: hibernate开发组推荐使用c3p0; spring开发组推荐使用dbcp(dbcp连接池有weblogic连接池同样 ...

  9. 微信小程序相关三、css写小黄人

    小程序上课第三天,因为今天院里有活动,所以没去上课,第四天上午又因为要召开入党转正大会,又耽误了一上午,下午去上课,要了资料.这两天讲了一些零零碎碎的东西,做的实例有上面这个小黄人 都是用的css,基 ...

  10. C#自省

    [C#自省] 1.根据string,获取type.Type.GetType 方法,获取具有指定名称的 Type,执行区分大小写的搜索. 2.根据obj,获取type.Object.GetType 方法 ...