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
- FND
- D Flip Flop
- hc-sr04
- atmega 128a
- Recursion
- structural modeling
- i2c 통신
- LED
- DHT11
- ring counter
- KEYPAD
- behavioral modeling
- vivado
- verilog
- uart 통신
- stop watch
- soc 설계
- gpio
- Edge Detector
- ATMEGA128A
- test bench
- pwm
- Algorithm
- BASYS3
- half adder
- Pspice
- dataflow modeling
- Linked List
- java
- prescaling
Archives
- Today
- Total
거북이처럼 천천히
Verilog RTL 설계(7월 12일 - 5, 동기식 업/다운 카운터) 본문
1. Synchronous Up Down Counter (Negative edge trigger)
- Up counter로 동작하며, Down Counter로서 동작할 수 있다.
< Source >
// Syncrhronous Up Down Counter implemented with D Flip Flop
module Synchronous_Up_Down_Counter_Negative(
input up_down,
input clk, enable, reset_p,
output reg [3:0] count );
// 0 : Up Counting, 1 : Down Counting
always @(negedge clk or posedge reset_p) begin
if(reset_p) count = 0;
else if(enable) begin
if(up_down) count = count - 1;
else count = count + 1;
end
else count = count;
end
endmodule
< Simulation >
- up_down 변수가 0인 경우 (= Up Counter로 동작하는 경우)
- up_down 변수가 1인 경우 (= Down Counter로 동작하는 경우)
< RTL Analysis >
< Synthesis >
2. Synchronous BCD Up Down Counter (Positive edge trigger)
< Source >
// Synchronous BCD Up Down Counter implemented with D Flip Flop (Positive)
module Synchronous_BCD_Up_Down_Counter_Positive(
input up_down,
input clk, enable, reset_n,
output reg [3:0] count );
// Up Counter : 1, Down Counter : 0
always @(posedge clk or negedge reset_n) begin
if(!reset_n) begin
if(up_down) count = 0;
else count = 9;
end
else if(enable) begin
if(up_down) begin
if(count >= 9) count = 0;
else count = count + 1;
end
else begin
if(count >= 10 | count <=0) count = 9;
count = count - 1;
end
end
else count = count;
end
endmodule
< Simulation >
- up_down 변수가 0인 경우 (= Down Counter로 동작하는 경우)
- up_down 변수가 1인 경우 (= Up Counter로 동작하는 경우)
< RTL Analysis >
< Synthesis >
'RTL Design > Verilog RTL 설계' 카테고리의 다른 글
Verilog RTL 설계(7월 12일 - 6, Edge detector) (0) | 2024.07.15 |
---|---|
Verilog RTL 설계(7월 12일 - 6, 링 카운터) (0) | 2024.07.14 |
Verilog RTL 설계(7월 12일 - 4, 동기식 BCD 카운터) (2) | 2024.07.14 |
Verilog RTL 설계(7월 12일 - 3, 동기식 카운터 - 2) (2) | 2024.07.14 |
Verilog RTL 설계(7월 12일 - 2, 동기식 카운터 - 1) (0) | 2024.07.13 |