Verilog MIPS32 CPU(七)-- DIV、DIVU
- Verilog MIPS32 CPU(一)-- PC寄存器
- Verilog MIPS32 CPU(二)-- Regfiles
- Verilog MIPS32 CPU(三)-- ALU
- Verilog MIPS32 CPU(四)-- RAM
- Verilog MIPS32 CPU(五)-- CP0
- Verilog MIPS32 CPU(六)-- MDU
- Verilog MIPS32 CPU(七)-- DIV、DIVU
- Verilog MIPS32 CPU(八)-- 控制器
module DIVU(
input [:] dividend,
input [:] divisor,
input start,
input clock,
input reset,
output reg over,
output reg busy,
output [:] q,
output [:] r); reg [:] count;
reg [:] reg_q;
reg [:] reg_r;
reg [:] reg_b;
reg r_sign; wire [:] sub_add = r_sign?({reg_r,q[]} + {'b0,reg_b}):({reg_r,q[31]} - {1'b0,reg_b});
assign r = r_sign? reg_r + reg_b : reg_r;
assign q = reg_q; always @ (posedge clock or posedge reset) begin
if (reset) begin
count <= ;
busy <= ;
over <= ;
end
else if (start)begin
reg_r <= ;
r_sign <= ;
reg_q <= dividend;
reg_b <= divisor;
count <= ;
busy <= ;
end
else if (busy) begin
reg_r <= sub_add[:];
r_sign <= sub_add[];
reg_q <= {reg_q[:],~sub_add[]};
count <= count +;
if(count == ) begin
busy <= ;
over <= ;
end
end
end endmodule module DIV(
input signed [:] dividend,
input signed [:] divisor,
input start,
input clock,
input reset,
output reg over,
output reg busy,
output [:] q,
output reg [:] r); reg [:] count;
reg [:] reg_q;
reg [:] reg_r;
reg [:] reg_b;
reg r_sign; wire [:] sub_add = r_sign?({reg_r,q[]} + {'b0,reg_b}):({reg_r,q[31]} - {1'b0,reg_b}); assign q = reg_q; always @ (posedge clock or posedge reset)
if (reset) begin
count <= ;
busy <= ;
over <= ;
end
else begin
if (start) begin
reg_r <= ;
r_sign <= ;
if(dividend<)
reg_q <= -dividend;
else
reg_q <= dividend;
if(divisor<)
reg_b <= -divisor;
else
reg_b <= divisor;
count <= ;
busy <= ;
end
else if(busy) begin
if(count<=) begin
reg_r <= sub_add[:];
r_sign <= sub_add[];
reg_q <= {reg_q[:],~sub_add[]};
count <= count + ;
end
else begin
if(dividend[]^divisor[])
reg_q<=-reg_q;
if(!dividend[])
r<=r_sign? reg_r + reg_b : reg_r;
else
r<=-(r_sign? reg_r + reg_b : reg_r);
busy <= ;
over <= ;
end
end
end
endmodule
Verilog MIPS32 CPU(七)-- DIV、DIVU的更多相关文章
- Verilog MIPS32 CPU(八)-- 控制器
Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...
- Verilog MIPS32 CPU(六)-- MDU
Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...
- Verilog MIPS32 CPU(五)-- CP0
Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...
- Verilog MIPS32 CPU(四)-- RAM
Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...
- Verilog MIPS32 CPU(三)-- ALU
Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...
- Verilog MIPS32 CPU(二)-- Regfiles
Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...
- Verilog MIPS32 CPU(一)-- PC寄存器
Verilog MIPS32 CPU(一)-- PC寄存器 Verilog MIPS32 CPU(二)-- Regfiles Verilog MIPS32 CPU(三)-- ALU Verilog M ...
- Verilog MIPS32 CPU(九)-- 顶层文件
`timescale 1ns / 1ps /////////////////////////////////////////////////////////////////////////////// ...
- P4-verilog实现mips单周期CPU
最近对学习的掌控可能出现了问题,左支右绌,p2挂了,p2.p3.p4.p5每周在计组花的连续时间少了很多,学习到的东西也少了很多,流水线都还没真正开始写,和别人比落后了一大截,随笔自然就荒废了,我得尽 ...
随机推荐
- Spring源码研究--下载-编译-导入eclipse-验证
一,环境配置 操作系统:Unbutu14.04LTS JDK: 1.8.0_40 git: 1.9.1 gradle: 2.2.1 二,源码下载-编译-导入eclipse-验证 1,下载 使用git直 ...
- Django models拆分
大多数Django教程都是将models放在models.py文件(模块)中, 然而随着models类的增加, 将类放在一个文件中太混乱了, 于是将models做成一个package: 这样就可以将m ...
- 系统架构设计方法论——TOGAF
https://blog.csdn.net/watermelonbig/article/details/77620847 1.ADM的架构开发阶段 ADM方法是由一组按照架构领域的架构开发顺序而排列成 ...
- Spyder kernel died 错误
Keras 2.2.4版本和 tensorflow1.2.1 版本不兼容导致的错误.降低Keras 为2.1.2版本 import keras 出现: Using TensorFlow backend ...
- pl/sql中if语句的使用
- 依赖VUE组件通讯机制实现场景游戏切换
- 82. Remove Duplicates from Sorted List II (List)
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numb ...
- Python tkinter 副窗体置顶和取消置顶
root = Tk() #置顶root.wm_attributes('-topmost',1) #取消置顶 root.wm_attributes('-topmost',0)
- ECS 游戏架构 应用
转载自:http://blog.csdn.net/i_dovelemon/article/details/30250049 如何在cocos2d-x中使用ECS(实体-组件-系统)架构方法开发一个游戏 ...
- 查看并解除Oracle锁
当某个数据库用户在数据库中插入.更新.删除一个表的数据,或者增加一个表的主键时或者表的索引时, 常常会出现ora-00054:resource busy and acquire with nowait ...