-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
W02_PHJ #6
base: main
Are you sure you want to change the base?
W02_PHJ #6
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Counter(i_Clk, i_Rst, i_Push, o_LED1,o_LED2, o_FND); | ||
input i_Clk; // 50MHz | ||
input i_Rst; | ||
input [1:0] i_Push; | ||
output wire [3:0] o_LED1; | ||
output wire [3:0] o_LED2; | ||
output wire [6:0] o_FND; | ||
|
||
reg [3:0] c_Cnt, n_Cnt; | ||
reg [1:0] c_UpDn, n_UpDn; | ||
|
||
wire fUp; | ||
wire fDn; | ||
|
||
FND FND0(c_Cnt, o_FND); | ||
|
||
always@(posedge i_Clk, posedge i_Rst) | ||
if(i_Rst) begin | ||
c_Cnt = 0; | ||
c_UpDn = 2'b11; | ||
end else begin | ||
c_Cnt = n_Cnt; | ||
c_UpDn = n_UpDn; | ||
end | ||
|
||
assign {fUp, fDn} = ~i_Push & c_UpDn; | ||
assign o_LED1 = c_Cnt >= 10 ? c_Cnt / 10 : 0; | ||
assign o_LED2 = c_Cnt >= 10 ? c_Cnt % 10 : c_Cnt; | ||
|
||
always@* | ||
begin | ||
n_UpDn = i_Push; | ||
n_Cnt = fUp ? c_Cnt * 2 : | ||
fDn ? c_Cnt / 2 : c_Cnt + 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여긴 일부러 손본건가요? 여기 있는 코드 대로라면
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 일부러 손댄 것이 맞습니다 원래 1씩 더해지고 빼는 식이었는데 저는 2가 계속 곱해도보고 나누고 싶었고 둘 다 아니라면 2를 더하고 싶었숨다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1번 버튼은 * 2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ㅋㅎㅋㅎㅋㅎㅋㅎㅋㅎ 이때 왜 그랬는지는 모르겠는데 지금 다시 보니까 +2가 없고 그냥 c_Cnt로 했었어야 했는데 그래서 고쳐서 올릴려고 해요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yuyu0830 LED지우고 코드 FND를 추가했는데 맞는지 확인 부탁드려도 될까요..?🥺 |
||
end | ||
|
||
endmodule |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module FND(i_Num, o_FND); | ||
input [3:0] i_Num; | ||
output reg [6:0] o_FND; | ||
|
||
always@* | ||
case(i_Num) | ||
4'h0: o_FND = 7'b1000000; | ||
4'h1: o_FND = 7'b1111001; | ||
4'h2: o_FND = 7'b0100100; | ||
4'h3: o_FND = 7'b0110000; | ||
4'h4: o_FND = 7'b0011001; | ||
4'h5: o_FND = 7'b0010010; | ||
4'h6: o_FND = 7'b0000010; | ||
4'h7: o_FND = 7'b1111000; | ||
4'h8: o_FND = 7'b0000000; | ||
4'h9: o_FND = 7'b0010000; | ||
default: o_FND = 7'b1111111; | ||
endcase | ||
|
||
endmodule |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
`timescale 1 ns / 1ns | ||
module tb_Cnt(); | ||
reg Clk; | ||
reg Rst; | ||
reg [1:0] Push; | ||
wire[3:0] Cnt_o_LED; | ||
|
||
Counter U0(Clk, Rst, Push, Cnt_o_LED,); | ||
|
||
always | ||
#10 Clk = ~Clk; | ||
|
||
initial | ||
begin | ||
// initialize | ||
Clk = 1; | ||
Rst = 1; | ||
Push = 2'b11; | ||
|
||
// reset | ||
@(posedge Clk) Rst = 1; | ||
@(negedge Clk) Rst = 0; | ||
|
||
// action | ||
#200 Push = 2'b01; #200 Push = 2'b11; | ||
#200 Push = 2'b01; #200 Push = 2'b11; | ||
#200 Push = 2'b01; #200 Push = 2'b11; | ||
#200 Push = 2'b01; #200 Push = 2'b11; | ||
#200 Push = 2'b01; #200 Push = 2'b11; | ||
#200 Push = 2'b01; #200 Push = 2'b11; | ||
#200 Push = 2'b01; #200 Push = 2'b11; | ||
#200 Push = 2'b01; #200 Push = 2'b11; | ||
#200 Push = 2'b01; #200 Push = 2'b11; | ||
#200 Push = 2'b10; #200 Push = 2'b11; | ||
#200 Push = 2'b10; #200 Push = 2'b11; | ||
#200 Push = 2'b10; #200 Push = 2'b11; | ||
#200 Push = 2'b10; #200 Push = 2'b11; | ||
#200 Push = 2'b10; #200 Push = 2'b11; | ||
#200 Push = 2'b10; #200 Push = 2'b11; | ||
#200 Push = 2'b10; #200 Push = 2'b11; | ||
#200 Push = 2'b10; #200 Push = 2'b11; | ||
end | ||
endmodule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
새로운 해결방법! o_LED에 대한 값을 10 처리를 했네요 ㅎㅎ
아쉬운건 어차피 값은 c_Cnt에 저장이 되니 c_Cnt에 저장되는 부분을 손봤으면 어땠을까 싶네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그 때 설명을 들었을때 한 세그먼트에 0~9까지 표현이 된다고 기억을 했습니다 그래서 저는 1의 자리와 10의 자리도 표현하고 싶어서 세그먼트를 하나 더 만들려고 했고 그거를 10으로 나누어서 몫과 나머지로 표현,,,하고자 했습니다