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

最新文章

  1. [python]set集合学习
  2. CSS3混合模式mix-blend-mode/background-blend-mode简介 ,PS中叠加效果
  3. spring 后置处理器BeanFactoryPostProcessor和BeanPostProcessor的用法和区别
  4. 浏览器查看cookie
  5. python 练习 28
  6. Java中HashMap,LinkedHashMap,TreeMap的区别[转]
  7. zendframework 事件管理(二)
  8. UITableView优化技巧
  9. Install Package and Software
  10. install Active Directory域控制器
  11. HTML5储存
  12. poj1459 Power Network --- 最大流 EK/dinic
  13. Inno Setup入门(十九)&mdash;&mdash;Inno Setup类参考(5)
  14. ubuntu文件目录详细介绍
  15. ThreadLocal 原理解析
  16. c++ 中lambda
  17. AtCoder Grand Contest 032-B - Balanced Neighbors (构造)
  18. Vue(小案例_vue+axios仿手机app)_go实现退回上一个路由
  19. Nginx安装echo模块
  20. win10安装MarkdownPad 2报错This view has crashed的处理及md简单语法

热门文章

  1. 黑暗之光 Day2
  2. React文档总结
  3. NSTimer类的使用
  4. Unity协程使用经验
  5. centos6.5 源码安装 mysql
  6. 109. Convert Sorted List to Binary Search Tree (List; Divide-and-Conquer, dfs)
  7. Github 使用的Markdown语言
  8. ICO流程,casestudy
  9. SQL Server横向扩展:设计,实现与维护(2)- 分布式分区视图
  10. 后台注册js代码的方法