山东大学FPGA课程实验一 加法器设计

【实验题目】

  1. 设计一个16位二进制全加器模块。
  2. 用层次化设计方法,设计一个16位二进制全加器模块。
  3. 设计一个16位二进制超前进位全加器模块。
  4. 设计一个16-bit 8421-BCD码全加器模块。

【实验软件工具】

  1. QuartusII;
  2. ModelSim SE.

【实验要求】

  1. 实验内容与原理说明(包括框图、逻辑表达式和真值表);
  2. 实验模块程序代码(设计模块Design Block)和激励代码(激励模块Test Bench);
  3. 仿真波形图;
  4. 综合得到的门级电路图;
  5. 实验结果分析及思考。

【实验内容】

一、设计一个16位二进制全加器模块

1. 实验内容与原理说明

写出16位二进制全加器真值表如下:

a

b

cin

co

sun

0

0

0

0

0

0

0

1

0

1

0

1

0

0

1

0

1

1

1

0

1

0

0

0

1

1

0

1

1

0

1

1

0

1

0

1

1

1

1

1

2.实验模块程序代码(设计模块Design Block)和激励代码(激励模块Test Bench)

设计模块Design Block的程序代码:

// 16-bit adder design using verilog primitive gates

`timescale 1ns/100ps

`default_nettype none

module adder_16bit(input  wire [15:0]  a,

                   input  wire [15:0]  b,

                   input  wire cin,

                   output wire [15:0]  s,

                   output wire cout);

//Internal carry connections

wire [3:0] c;    //carry out of 4 4bit adders

// Instantiate 4 x adder_4bit

adder_4bit adder4b0 (a[3:0],   b[3:0],   cin,  s[3:0],   c[0]);

adder_4bit adder4b1 (a[7:4],   b[7:4],   c[0], s[7:4],   c[1]);

adder_4bit adder4b2 (a[11:8],  b[11:8],  c[1], s[11:8],  c[2]);

adder_4bit adder4b3 (a[15:12], b[15:12], c[2], s[15:12], cout);

endmodule

`default_nettype wire

激励模块Test Bench的激励代码:

// 16-bit adder design using verilog primitive gates

`timescale 1ns/100ps

`default_nettype none

module adder_16bit(input  wire [15:0]  a,

                   input  wire [15:0]  b,

                   input  wire         cin,

                   output wire [15:0]  s,

                   output wire         cout);

//Internal carry connections

wire [3:0] c;    //carry out of 4 4bit adders

// Instantiate 4 x adder_4bit

adder_4bit adder4b0 (a[3:0],   b[3:0],   cin,  s[3:0],   c[0]);

adder_4bit adder4b1 (a[7:4],   b[7:4],   c[0], s[7:4],   c[1]);

adder_4bit adder4b2 (a[11:8],  b[11:8],  c[1], s[11:8],  c[2]);

adder_4bit adder4b3 (a[15:12], b[15:12], c[2], s[15:12], cout);

endmodule

`default_nettype wire

3.仿真波形图

4.综合得

你可能感兴趣的:(fpga开发)