Computer Architecture Lab 5: Verilog and Digital Circuits, Lab Reports of Computer Science

A lab assignment from texas a&m university's computer science department for cpsc 321: computer architecture. The lab focuses on introducing students to verilog, a hardware description language, and designing digital circuits such as half adders, full adders, multi-bit adders, decoders, and multiplexers. Students are required to write verilog code, compile it with vcs, and test the designs using provided test benches.

Typology: Lab Reports

Pre 2010

Uploaded on 02/13/2009

koofers-user-d26
koofers-user-d26 🇺🇸

9 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CPSC 321:501-503 - Computer Architecture
Texas A&M University
Department of Computer Science
Fall 2006
Lab 5 - Introduction to Verilog (100 pts)
Complete by yourself
Release date: 16 October 2006
Due date: One week after the lab
Objective
In this lab, you will be introduced to Verilog. You will work on structural designs and specifications.
A simple example
Implementing a simple arbitrary Boolean function
Using primitive Verilog gates, implement the Boolean function: ab + a'. Name this module
first_module. Write a test bench - test_first - to examine the outputs for varying input
combinations. Compile the code with VCS and run the executable.
Here is what your Verilog code would look like:
module first_module(out, a, b);
input a, b;
output out;
wire a1, a2;
not n1(a1, a);
and and1(a2, a, b);
or or1(out,a1,a2);
endmodule
module test_first();
reg a, b;
wire out;
first_module fm(out,a,b);
initial begin
$monitor ($time,"\ta=%b\tb=%b\tout=%b",a,b,out);
a = 0; b = 0;
Page
1
of
3
CPSC 321
-
Lab 5
9/1/2006
pf3

Partial preview of the text

Download Computer Architecture Lab 5: Verilog and Digital Circuits and more Lab Reports Computer Science in PDF only on Docsity!

CPSC 321:501-503 - Computer Architecture

Texas A&M University

Department of Computer Science

Fall 2006

Lab 5 - Introduction to Verilog (100 pts)

Complete by yourself

Release date: 16 October 2006 Due date: One week after the lab

Objective

In this lab, you will be introduced to Verilog. You will work on structural designs and specifications.

A simple example

Implementing a simple arbitrary Boolean function

Using primitive Verilog gates, implement the Boolean function: ab^ + a'. Name this module first_module. Write a test bench - test_first (^) - to examine the outputs for varying input

combinations. Compile the code with VCS and run the executable.

Here is what your Verilog code would look like:

module first_module(out, a, b); input a, b; output out; wire a1, a2;

not n1(a1, a); and and1(a2, a, b); or or1(out,a1,a2); endmodule

module test_first(); reg a, b; wire out;

first_module fm(out,a,b);

initial begin $monitor ($time,"\ta=%b\tb=%b\tout=%b",a,b,out); a = 0; b = 0;

#1 a = 0; b = 1; #1 a = 1; b = 0; #1 a = 1; b = 1; end

endmodule

Enter this code into your text editor (vi or emacs). Compile this code with VCS (Look at the VCS help document for further instructions).

Assignment

1. [10 pts] Half adder

A half-adder is a combinational circuit that adds two 1-bit inputs a and b , and generates 1-bit sum s and

carry out c. The truth-table for a half-adder is shown below:

Structurally define a half-adder. Prepare a test bench to test the half-adder and evaluate with VCS. Test this module completely, since you will be using it as a building block for the full-adder.

2. [10 pts] Full adder

Structurally define a 1-bit full adder using two half adders (from above). The truth table for the full- adder is shown below:

Prepare a test bench to test the full-adder and evaluate with VCS. Test this module completely, since you will be using it as a building block for your multi-bit adders.

a b s c 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 1

a b carryIn sum carryOut 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1