1. 문제 및 설명
- 0부터 9까지 카운트하는 주기 10의 카운터를 구현하시오
- reset입력은 동기식이며, 카운터를 0으로 초기화해야 한다.
- slowena 입력이 들어올 때만 카운터가 증가해야 한다.
2. 모듈 정의
module top_module (
input clk,
input slowena,
input reset,
output [3:0] q);
3. 답
module top_module (
input clk,
input slowena,
input reset,
output [3:0] q);
always @(posedge clk)
if (reset) // Count to 10 requires rolling over 9->0 instead of the more natural 15->0
q <= 4'd0;
else
begin
if(slowena == 1'b1)
begin
q <= q + 4'd1;
if(q==4'd9)
q <= 4'd0;
end
end
endmodule
'Verilog > HDLbits' 카테고리의 다른 글
| [HDLBits] Exams/ece241 2014 q7b (0) | 2026.01.14 |
|---|---|
| [HDLBits] Exams/ece241 2014 q7a (0) | 2026.01.06 |
| [HDLBits] Count1to10 (0) | 2026.01.05 |
| [HDLBits] Count10 (0) | 2026.01.05 |
| [HDLBits] Count15 (0) | 2026.01.03 |