Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- uart 통신
- soc 설계
- KEYPAD
- vivado
- LED
- dataflow modeling
- DHT11
- atmega 128a
- Recursion
- test bench
- java
- hc-sr04
- stop watch
- ring counter
- pwm
- FND
- prescaling
- behavioral modeling
- Algorithm
- verilog
- gpio
- structural modeling
- i2c 통신
- half adder
- Edge Detector
- Pspice
- BASYS3
- Linked List
- ATMEGA128A
- D Flip Flop
Archives
- Today
- Total
거북이처럼 천천히
Verilog RTL 설계 (6월 13일 - 5) 본문
1. Parameter를 갖는 Module 설계
- Q) 왜 Parameter를 갖는 Module를 설계하는가?
- 모듈의 재사용성 및 범용성
- Parameter를 변경함으로써 다양한 디자인 요구에 쉽게 대응하기 위해서
- 시뮬레이션와 테스트의 편의성을 위해서
- 성능 최적화
- 예시를 통해 Verilog에서 Module를 정의할 때, 어떻게 Parameter를 갖는 Module를 정의할 수 있는지를
살펴보자.
2. Parameter를 갖는 8bit comparator
- 이번에는 입력 변수의 크기를 parameter로 정의한 comparator에 대해서 설계한다.
< Source - Parameter module >
module Comparator_by_using_parameter #(parameter N = 8) (
input [N-1:0] a, b,
output equal, greater, less );
assign equal = (a == b)? 1 : 0;
assign greater = (a > b)? 1: 0;
assign less = (a < b)? 1 : 0;
endmodule
< Source - 2bit comparator >
module Comparator_2bit_Structural_modeling_by_using_parameter (
input [1:0] a, b,
output equal, greater, less );
Comparator_by_using_parameter #(.N(2)) comparator (.a(a), .b(b),
.equal(equal), .greater(greater), .less(less));
endmodule
< Simulation >
- Q) Parameter를 갖는 Module에서 "module Comparator_by_using_parameter #(paramter N = 8)" 가 갖는 의미가 무엇인가?
- A) module를 이용하여 instance를 생성했을 때, argument N값을 통해 Input 변수의 데이터 크기를 정할 수 있는데, 만약 argument를 정하지 않는다면 기본적으로 8비트 크기의 입력 데이터를 Compare할 수 있는 Comparator가 생성된다.
- 위 코드를 볼 수 있듯이 parameter를 갖는 module를 사용하려면 호출하는 module은 structural modeling으로 구현할 필요가 있다.
3. Paramter를 갖는 Module를 만든 뒤, 이를 이용하여 3bit comparator를 만들기
< Source >
module Parameter_comparator #(parameter N = 8)(
input [N-1:0] a, b,
output equal, greater, less );
assign equal = (a == b)? 1 : 0;
assign greater = (a >b)? 1 : 0;
assign less = (a < b)? 1 : 0;
endmodule
module Comparator_3bit (
input [2:0] a, b,
output equal, greater, less );
Parameter_comparator #(.N(3)) comparator_3bit (
a, b, equal, greater, less);
endmodule
< Simulation >
4. parameter를 comparator를 만드는 데, 해당 모듈을 behavior modeling으로 설계하고, 이를 이용한 2bit comparator를 만들기
< Source - parameter comparator - behavioral modeling >
module Comparator_parameter_behavioral_modeling #(parameter N=8) (
input [N-1:0] a, b,
output reg equal, greater, less );
always @(a, b) begin
equal = 0;
greater = 0;
less = 0;
if(a == b) equal = 1;
else if(a <b) less = 1;
else greater = 1;
end
endmodule
< Source - 2bit comparator >
module Comparator_2bit_by_using_parameter_module (
input [1:0] a, b,
output equal, greater, less );
Comparator_parameter_behavioral_modeling #(.N(2)) comparator (
a, b, equal, greater, less );
endmodule
< Simulation >
'RTL Design > Verilog RTL 설계' 카테고리의 다른 글
Verilog RTL 설계 (6월 24일 - 2) (0) | 2024.06.25 |
---|---|
Verilog RTL 설계 (6월 24일 - 1) (0) | 2024.06.24 |
Verilog RTL 설계 (6월 13일 - 4) (1) | 2024.06.15 |
Verilog RTL 설계 (6월 13일 - 3) (1) | 2024.06.15 |
Verilog RTL 설계 (6월 13일 - 2) (0) | 2024.06.14 |