You are on page 1of 25

디지털 시스템 실험

5주차

(7-Segment)

KECE210 ( 07 )
목요일 6-8교시

High Performance Computing


& Computational Intelligence LAB
실험 목표

▪ 7-Segment의 구조 이해
▪ Decoder를 이용한 Binary-to-BCD Converter 설계
▪ Verilog reg, always, case 사용법 숙지
▪ BCD-to-7 Segment Converter 설계
▪ 7 Segment calculator 설계

High Performance Computing & Systems Lab 2


7-Segment

High Performance Computing & Systems Lab 3


7-Segment

High Performance Computing & Systems Lab 4


7-Segment

High Performance Computing & Systems Lab 5


7-Segment pin mapping

High Performance Computing & Systems Lab 6


7-Segment pin mapping

flow seg_com[0..3] seg_data[0..7]


1 “0111” “01100000”
2 “1011” “11011010”
3 “1101” “11110010”
4 “1110” “01100110”

High Performance Computing & Systems Lab 7


BCD to 7-Segment Convertor

BCD_to_7Segment Converter 진리표

High Performance Computing & Systems Lab 8


Binary to 7-Segment 구조

▪ Binary to BCD (using line decoder)


▪ BCD to 7-Segment

High Performance Computing & Systems Lab 9


Binary to BCD Converter using line decoder
Input(A3A2A1A0) 이 5이상
이므로, 3을 더함.
Shift는 회로에서 line
shift and add-3 algorithm을 이용한 decoder decoder 배치를 통해 구현.

High Performance Computing & Systems Lab 10


Binary to BCD & Line decoder codes

5주차 강의자료의 verilog 파일 참조

High Performance Computing & Systems Lab 11


Verilog 참고자료

▪ wire vs reg
▪ wire
▪ wire는 물리적인 연결선으로, 특정 값을 저장할 수 없다.

▪ 연속적인 할당을 구현할 때 사용된다.

▪ reg
▪ reg는 다음 값이 할당되기 전까지 현재 값을 유지한다.
▪ 절차적인 할당을 구현할 때 사용된다.

▪ 연속적인 할당 : assign을 사용한 할당 (wire 사용)


▪ 절차적인 할당 : always문 안에서의 할당 (reg 사용)

참고 링크 : https://dreamsailor.tistory.com/8
https://m.blog.naver.com/tlsrka649/221812697411

High Performance Computing & Systems Lab 12


Verilog 참고자료
▪ Behavioral modeling
▪ Behavioral modeling
▪ Blocking
– 현재 할당문의 실행이 완료된 이후에 그 다음의 할당문이 실행
– 순차적 흐름

reg_lvalue = [delay_or_event_operator] expression;

Reg 타입 변수

▪ Non blocking
– 나열된 할당문들이 동시에 실행되어 값을 할당

reg_lvalue <= [delay_or_event_operator] expression;

Reg 타입 변수

High Performance Computing & Systems Lab 13


Verilog 참고자료

▪ Behavioral modeling
▪ Blocking, Non blocking 비교
module blk1; module non_blk1;
output out; output out;
reg a, b, clk; reg a, b, clk;

initial begin initial begin


a = 0; a = 0;
b = 1; b = 1;
clk = 0; clk = 0;
end end

always clk = #5 ~clk; always clk = #5 ~clk;

always @(posedge clk) begin always @(posedge clk) begin


a = b; // a=1 a <= b;
b = a; // b=a=1 b <= a;
end end
endmodule endmodule

High Performance Computing & Systems Lab 14


Verilog 참고자료

High Performance Computing & Systems Lab 15


Verilog 참고자료

▪ case 조건문
case(expression)
case_item {, case_item} : statement_or_null;
| default [:] statement_or_null;
endcase

✓ case 조건식의 값과 일치하는 case_item의 문장이 실행


✓ 모든 case_item들에 대한 비교에서 일치되는 항이 없는 경우에는 default 항이 실행, default 항이 없으면 변수
는 이전에 할당받은 값을 유지

module case_example(a, b, sel, out);


input [1:0] a, b;
input sel;
output [1:0] out;
reg [1:0] out;

always @(a or b or sel) begin


case(sel)
0 : out = a;
1 : out = b;
default : out = 0;
endcase
end
endmodule

High Performance Computing & Systems Lab 16


Binary to 7-Segment 구조

▪ Binary to BCD (using line decoder)


▪ BCD to 7-Segment

High Performance Computing & Systems Lab 17


BCD to 7-Segment

코드 빈칸 채워서 완성 후, pin planner 세팅하기

High Performance Computing & Systems Lab 18


7-Segment Block Diagram

High Performance Computing & Systems Lab 19


조별 실습

▪ Binary-to-7Segment 설계
▪ 강의자료에 포함된 아래의 파일들 사용.
▪ linedecoder.v

▪ binary_to_BCD.v

▪ SevenSeg_CTRL.v

▪ 코드를 완성하여 사용.


▪ BCD_to_7segment.v

▪ seven_seg.v

High Performance Computing & Systems Lab 20


조별 실습

High Performance Computing & Systems Lab 21


조별 실습
▪ BCD_to_7segment.v always문을 사용하여, bcd-7segment code 완성하기

▪ seven_seg.v u1, u2, u3, u4 모듈 뒤의 빈칸 채우기

High Performance Computing & Systems Lab 22


조별 실습
▪ RTL viewer

High Performance Computing & Systems Lab 23


결과보고서 필수 첨부 사항

▪ BCD_to_7segment.v , seven_seg.v 코드 완성하여 첨부


▪ seven_seg RTL viewer 회로 캡쳐 하여 첨부

High Performance Computing & Systems Lab 24


Thank you

High Performance Computing & Systems Lab

You might also like