You are on page 1of 17

Họ và tên: Phạm Trung Hiếu

MSV: 20021130
Lớp: 2223II_EMA3028_20

BÁO CÁO GIỮA KỲ


I. Lab00: To be familiar with VHDL simulation
1. Getting started
-What is the VHDL design style used in the file mux2in1b.vhd?
File mux2in1b.vhd sử dụng phong cách thiết kế ngôn ngữ VHDL dataflow.
-Perform the following steps to compile the file and simulation the circuit :
 Creat your own working directory.
Em đã tạo đường dẫn thư mục làm việc ra desktop

 Create then map the working library to the default library.


 Copy the VHDL code file into your working directory, then compile.

 Start simulation the circuit (entity mux2in1b) using Tcl commands.


Datain0 1 1 1 1 0 0 0 0
Datain1 1 0 1 0 1 1 0 0
Sel 1 1 0 0 1 0 1 0
Dataout 1 0 1 1 1 1 0 0

-The file mux2in1b_3state.vhd describes a multiplexer with 2 1-bit data inputs


(DataIn0 and DataIn1), a select input Sel and a tri-state buffer enable input OE.
 What is the VHDL design style used in the file mux2in1b_3state.vhd?
File mux2in1b_3state.vhd sử dụng phong cách thiết kế ngôn ngữ VHDL behavioral.
 Repeat the steps above to compile the file and simulation the circuit
mux2in1b_3state using a script file .do. Compare the two simulation results?
Datain0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
Datain1 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0
Sel 1 1 0 0 1 0 1 0 1 1 0 0 1 0 1 0
OE 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
Dataout Z Z Z Z Z Z Z Z 1 1 1 1 1 0 0 0
+So sánh :
Trong phần mô phỏng mux2in1b_3state, kết quả phụ thuộc vào 4 biến đầu vào và
xuất hiện thêm kết quả “Z” khi đầu vào OE = 0

2. NAND gate modeling example


-Write the truth table and find the logic function of NAND gate
+Bảng chân lý :
A 1 1 0 0
B 1 0 1 0
output 0 1 1 1

+ Hàm NAND : output = A . B


+ Giải thích : giá trị đầu vào a=1, b=1 thì a.b =1 => z = a . b = 0 , tương tự các giá trị
của a lần lượt là 1,0,0 giá trị b lần lượt là 0,0,1 , giá trị z nhận được là 1,1,1.

3. Xor3 gate in different design styles


-Write the truth table and find the logic function of xor3 gate.
+ Bảng chân lý:
A 1 1 0 0
B 1 0 1 0
Output 0 1 1 1

+ Hàm XOR : Output = A B+B A


-With each design style:
 Make the complete vhdl file to describe xor3 gate:
 Simulate and try to test the design with all possible combination of inputs to
verify that the circuit works as expected. Your simulation results (including
waveform) should be includes in report.
+ dataflow style:
- Compare three simulation results:
+ kết quả mô phỏng của 3 cách giống nhau, behavior style không cần biến nhớ
+structure style:

+behavior style:
4 Simulation using testbench
-Include simulation results in your report with explanation.

+ Giải thích : file testbench sẽ gán các giá trị đầu vào thành các vector, có 8 giá trị
cho vector đầu vào , giá trị của đầu ra sẽ giống kết quả trong bảng chân lý của mạch
xor3

-Write the testbench file for NAND gate which introduced in section 2.

+ Phần code:
+ Mô phỏng :

II. Lab 01 Combinational Logic, VHDL simulation, and Test


Bench
1. 1-Bit comparator
1.1 1-bit comparator truth table
- Bảng chân lý:
x 1 1 0 0 1 1 0 0
y 1 0 1 0 1 0 1 0
eqi 1 1 1 1 0 0 0 0
eqo 1 0 0 1 0 0 0 0

- Hàm tối giản : eqo <= ‘1’ when eqi = ‘1’ and x = y else ‘0’

1.2 Simulation of 1-bit comparator with the above truth table


- Mô phỏng :

- Giải thích : khi đầu vào epi = 1 và x=y thì epo = 1, còn các trường hợp khác epo=0

1.3 1-bit comparator with structural description


- Mô phỏng :
-Giải thích : kết quả mô phỏng đầu ra giống với mô phỏng sử dụng flowdata, nhưng
khi đầu ra thay đổi trạng thái, tín hiệu sẽ bị chậm 2ns so với tín hiệu đầu vào, nguyên
nhân là do function phụ sử dụng hàm delay 1ns, và được áp dụng 2 lần.

2 Comparator with variable size of inputs


2.1 Modeling combinational logic using process statement
-Mô phỏng sử dụng testbench cho 8 bit dữ liệu đầu vào:
2.2 Generating iterative structure
-Phần code :

-Phần mô phỏng:
3 7-Segment encoder
- Mô phỏng :

- Phần code chính:


- Testbench:

III. Lab 02: Sequential Logic Modeling


1 Flip-flops and latches
1.1 Different types of Flip-flops/latches
- Mô phỏng theo các bước trong lab02:

- Đây là loại flip-flop d, rst_n có vai trò như tín hiệu bắt đầu , clk có vai trò xung
nhịp để đếm.

1.2 Modeling T flip-flop


2 Binary Counter
2.1 Behavior description of a binary counter with asynchronous
reset and synchronous set
- Mô phỏng bộ đếm 8 bit sử dụng kiến trúc behavior:
2.2 Binary counter design using flip-flop
- Mô phỏng bộ đếm 8 bit sử dụng T-flipflop:

3 Parallel-to-serial data converter

You might also like