-
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
[3주차 과제] StopWatch & FND #11
Open
ParkHyeon89
wants to merge
1
commit into
main
Choose a base branch
from
PH_3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
module StopWatch(i_Clk, i_Rst, i_fStart, i_fStop,i_fRecord, | ||
o_Sec0, o_Sec1, o_Sec2, | ||
o_Sec3, o_Sec4, o_Sec5); | ||
input i_Clk, i_Rst; | ||
input i_fStart, i_fStop; //,i_fRecord; | ||
output wire [6:0] o_Sec0, o_Sec1, o_Sec2, | ||
o_Sec3, o_Sec4, o_Sec5; | ||
|
||
reg [1:0] c_State, n_State; | ||
|
||
reg [3:0] c_Sec0, n_Sec0; | ||
reg [3:0] c_Sec2, n_Sec2; | ||
reg [3:0] c_Sec1, n_Sec1; | ||
reg [3:0] c_Sec3; //, n_Sec3; | ||
reg [3:0] c_Sec4; //, n_Sec4; | ||
reg [3:0] c_Sec5; //, n_Sec5; | ||
|
||
reg [22:0] c_ClkCnt, n_ClkCnt; | ||
reg c_fStart, n_fStart; | ||
reg c_fStop, n_fStop; | ||
|
||
wire fLstClk; | ||
wire fLstSec0, fLstSec1, fLstSec2, | ||
fLstSec3, fLstSec4, fLstSec5; | ||
wire fIncSec0, fIncSec1, fIncSec2; | ||
//,fIncSec3, fIncSec4, fIncSec5; | ||
|
||
wire fStart, fStop; //?? ?? ??? ??// | ||
|
||
parameter LST_CLK = 100_000_000/20 - 1; | ||
parameter IDLE = 2'b00, WORK = 2'b01, | ||
PAUSE = 2'b10;, RECORD = 2'b11;//??? ???? | ||
|
||
FND FND0(c_Sec0, o_Sec0); | ||
FND FND1(c_Sec1, o_Sec1); | ||
FND FND2(c_Sec2, o_Sec2); | ||
//??? | ||
FND FND3(c_Sec3, o_Sec3); | ||
FND FND4(c_Sec4, o_Sec4); | ||
FND FND5(c_Sec5, o_Sec5); | ||
|
||
always@(posedge i_Clk, negedge i_Rst) //??? ?? ? 0 | ||
|
||
if(!i_Rst) begin | ||
c_State = IDLE; | ||
c_ClkCnt = 0; | ||
c_Sec0 = 0; | ||
c_Sec1 = 0; | ||
c_Sec2 = 0; | ||
c_fStart = 1; | ||
c_fStop = 1; | ||
end else begin | ||
c_State = n_State ; | ||
c_ClkCnt = n_ClkCnt ; | ||
c_Sec0 = n_Sec0 ; | ||
c_Sec1 = n_Sec1 ; | ||
c_Sec2 = n_Sec2 ; | ||
c_fStart = n_fStart ; | ||
c_fStop = n_fStop ; | ||
end | ||
if(i_Record) begin | ||
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. 현주도 같은 실수를 했었는데 ㅋㅋㅋ
|
||
c_Sec3 = c_Sec0; | ||
c_Sec4 = c_Sec1; | ||
c_Sec5 = c_Sec2; | ||
end | ||
|
||
assign fStart = !i_fStart && c_fStart, | ||
fStop = !i_fStop && c_fStop; | ||
assign fLstClk = c_ClkCnt == LST_CLK, | ||
fLstSec0= c_Sec0 == 9, | ||
fLstSec1= c_Sec1 == 9, | ||
fLstSec2= c_Sec2 == 9; | ||
|
||
assign fIncSec0= fLstClk, | ||
fIncSec1= fIncSec0 && fLstSec0, | ||
fIncSec2= fIncSec1 && fLstSec1; | ||
//?? | ||
always@* | ||
begin //?? ??? ?? ?? ?? ? ?? ?? ???, ??? ???? | ||
n_fStart = i_fStart ; | ||
n_fStop = i_fStop ; | ||
n_State = c_State ; | ||
n_ClkCnt = c_ClkCnt ; | ||
n_Sec0 = c_Sec0 ; | ||
n_Sec1 = c_Sec1 ; | ||
n_Sec2 = c_Sec2 ; | ||
|
||
case(c_State) | ||
IDLE: begin | ||
n_ClkCnt = 0; | ||
n_Sec0 = 0; | ||
n_Sec1 = 0; | ||
n_Sec2 = 0; | ||
if(fStart) n_State = WORK; | ||
end | ||
WORK: begin | ||
n_ClkCnt = fLstClk ? 0 : c_ClkCnt + 1; | ||
n_Sec0 = fIncSec0 ? fLstSec0 ? 0 : c_Sec0 + 1 : c_Sec0; | ||
n_Sec1 = fIncSec1 ? fLstSec1 ? 0 : c_Sec1 + 1 : c_Sec1; | ||
n_Sec2 = fIncSec2 ? fLstSec2 ? 0 : c_Sec2 + 1 : c_Sec2; | ||
if(fStop) n_State = IDLE; | ||
else if(fStart)n_State = PAUSE; | ||
end | ||
PAUSE: begin | ||
if(fStop) n_State = IDLE; | ||
else if(fStart)n_State = WORK; | ||
end | ||
|
||
RECORD: | ||
if(fRecord) | ||
n_Sec = | ||
n_Sec = | ||
n_Sec = | ||
endcase | ||
end | ||
endmodule |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
c_ 레지스터는 Current 현재값을 저장하고, n_ 레지스터는 Next 다음 값을 저장합니다. c_가 있으면 n_가 세트로 따라붙어야해요!
Record 버튼이 눌렸다면 c_Sec3, c_Sec4, c_Sec5는 c_Sec0, c_Sec1, c_Sec2 의 현재 값을 복사하면 되지만 Record 버튼이 눌리지 않은 경우에 c_Sec3, c_Sec4, c_Sec5 값은 어떤 값이 있나요..?
현재 값을 유지하기 위해서 c_, n_ 두 세트는 항상 필요합니다!