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的更多相关文章

  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(五)-- CP0

    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. P4-verilog实现mips单周期CPU

    最近对学习的掌控可能出现了问题,左支右绌,p2挂了,p2.p3.p4.p5每周在计组花的连续时间少了很多,学习到的东西也少了很多,流水线都还没真正开始写,和别人比落后了一大截,随笔自然就荒废了,我得尽 ...

随机推荐

  1. AJAX跨域调用ASP.NET MVC的问题及解决方案

    AJAX跨域调用ASP.NET MVC的问题及解决方案 问题描述: 解决方法: 只需要在web.config中添加如下标为红色的内容即可: <system.webServer> <h ...

  2. CSS——创建css

    CreateInlineStyle: function () { //创建一个内联样式表 var style = document.createElement('style'); //创建一个styl ...

  3. Django xadmin的使用 (三)

    关于报错: 1.在页面添加好新的用户后登录报错 解决方法: 新建一个app,名叫app D:\myfiles\study\python\django\datas>python manage.py ...

  4. 什么时候必须使用UI相机? 多个相机的作用原理?

    首先,要从主画布说起,maincanvas,这个有什么限制?主画布是一张默认用来绘制UI的地方,这些UI必须是系统提供的UI组件,在画面下挂一个3D物体或非UI的2D物品是不会被绘制到画布上的,但是仍 ...

  5. GameObject.DestroyImmediate(go, true)会使磁盘资源数据丢失,导致不可用

    GameObject.DestroyImmediate(go, true)会使磁盘资源数据丢失,导致不可用 第二个参数true表示 allowDestroyingAssets,表示允许销毁资源. 实测 ...

  6. cdoj525-猴子选大王 (约瑟夫环)

    http://acm.uestc.edu.cn/#/problem/show/525 猴子选大王 Time Limit: 3000/1000MS (Java/Others)     Memory Li ...

  7. 解决svn Key usage violation in certificate has been detected

    ubuntu系统 #!/bin/shecho "This script will reconfigure subversion to work with certs correctly.&q ...

  8. 关于使用PL/SQL连接本地oracle时报错:ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务解决

    转自:https://blog.csdn.net/a657281084/article/details/49490069 问题:Oracle主服务和监听器服务已经启动,使用SQL Plus能够正常连接 ...

  9. 《DNA比对》蓝桥杯复赛试题

    题目描述 脱氧核糖核酸即常说的DNA,是一类带有遗传信息的生物大分子.它由4种主要的脱氧核苷酸(dAMP.dGMP.dCMT和dTMP)通过磷酸二酯键连接而成.这4种核苷酸可以分别记为:A.G.C.T ...

  10. spring4-3-AOP-AspectJ注解-01-简单使用

    1.引入类库 <dependency> <groupId>org.springframework</groupId> <artifactId>sprin ...