1. 문제 및 설명
- 다음과 같은 입력과 출력을 갖는 1 ~ 12 카운터를 설계하시오
- 입력: reset, enable, clk
- 출력: Q[3:0] (카운터의 출력값)
- 출력: c_enable, c_load, c_d[3:0] (제공된 4비트 카운터로 전달되는 제어 신호)
- 아래에 정의된 4비트 이진 카운터는 enable 입력과 동기식 병렬 로드 입력을 가지며, load는 enable보다 우선 순위가 높다.
- count4
module count4(
input clk,
input enable,
input load,
input [3:0] d,
output reg [3:0] Q
);
2. 모듈 정의
module top_module (
input clk,
input reset,
input enable,
output [3:0] Q,
output c_enable,
output c_load,
output [3:0] c_d
);
3. 답
module top_module (
input clk,
input reset,
input enable,
output [3:0] Q,
output c_enable,
output c_load,
output [3:0] c_d
); //
count4 the_counter (clk, c_enable, c_load, c_d, Q);
assign c_enable = enable;
assign c_load = reset|(c_enable&(Q==4'd12));
always@(posedge clk)
begin
if(c_load)
begin
c_d <= 1'b1;
end
end
endmodule'Verilog > HDLbits' 카테고리의 다른 글
| [HDLBits] Countbcd (0) | 2026.01.14 |
|---|---|
| [HDLBits] Exams/ece241 2014 q7b (0) | 2026.01.14 |
| [HDLBits] Countslow (0) | 2026.01.05 |
| [HDLBits] Count1to10 (0) | 2026.01.05 |
| [HDLBits] Count10 (0) | 2026.01.05 |