第一范文网 - 专业文章范例文档资料分享平台

北航verilog实验报告 - 图文

来源:用户分享 时间:2025/6/1 7:44:31 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

begin a=4'h3;

$display(\ #100 a=4'h7;

$display(\ #100 a=4'hf;

$display(\ #100 a=4'ha;

$display(\ #100 a=4'h2;

$display(\

#100 $display(\ $stop; end

non_blocking non_blocking(clk,a,b2,c2); blocking blocking(clk,a,b1,c1); endmodule

五.综合仿真结果

实验五 用always块实现较复杂的组合逻辑:

一.实验目的:

1.掌握用always实现较大组合逻辑电路的方法。

2.进一步了解assign与always两种组合电路实现方法的区别和注意点。 3.学习测试模块中随机数的产生和应用。 4.学习综合不同层次的仿真,并比较结果 二.实验设备:

安装Modelsim-6.5c的PC机。 三.实验内容:

设计一个简单的指令译码电路,该电路通过对指令的判断,对输入数据执行相应的操作,包括加、减、与、或和求反,并且无论是指令作用的数据还是指令本身发生变化,都有要作出及时的反应。

四.实验代码

`define plus 3'd0

`define minus 3'd1 `define band 3'd2 `define bor 3'd3 `define unegate 3'd4

module alu(out,opcode,a,b); output [7:0]out; reg [7:0]out;

input [2:0]opcode; input [7:0]a,b;

always @(opcode or a or b) begin

case(opcode) `plus: out=a+b; `minus: out=a-b; `band: out=a&b; `bor: out=a|b; `unegate: out=~a;

default: out=8'hx; endcase end endmodule

`timescale 1ns/1ns module alutest; wire [7:0]out; reg [7:0]a,b; reg [2:0]opcode; parameter times=5; initial begin

a={$random}%6; b={$random}%6; opcode=3'h0; repeat(times) begin

#100 a={$random}%6; b={$random}%6; opcode=opcode+1; end

#100 $stop; end

alu alu1(out,opcode,a,b); endmodule

五.综合仿真结果

实验六 在 Verilog HDL中使用函数

一.实验目的:

1.了解函数的定义和在模块设计中的使用。 2.了解函数的可综合性问题。

3.了解许多综合器不能综合复杂的算术运算。 二.实验设备:

安装Modelsim-6.5c的PC机。 三.实验内容:

做一个函数调用的示例,采用同步时钟触发运算的执行,每个clk时钟周期执行一次运算,在测试模块中,调用系统任务$display及在时钟的下降沿显示每次运算的结果。

四.实验代码

module tryfunct(clk,n,result,reset); output [31:0]result; input [3:0]n; input reset,clk; reg [31:0]result;

always @(posedge clk) begin

if(!reset) result<=0; else begin

result<=n*factorial(n)/((n*2)+1); end end

function [31:0]factorial; input [3:0]operand; reg [3:0]index; begin

factorial=operand? 1:0;

for(index=2;index<=operand;index=index+1) factorial=index*factorial; end

endfunction

搜索更多关于: 北航verilog实验报告 - 图文 的文档
北航verilog实验报告 - 图文.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c5m5ba0o3ir1emx12t1jo_3.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top