Timescale Directive
Coddy Verilog 여정의 기초 섹션에 포함된 레슨. 90개 중 70번째.
timescale 지시문은 시뮬레이션의 time unit과 time precision을 설정합니다. 이는 시뮬레이터에 #10과 같은 지연 값을 해석하는 방법을 알려 줍니다.
이전 레슨에서는 “10”이 무엇을 의미하는지 지정하지 않고 #10과 같은 지연을 사용했습니다. 10 nanoseconds일까요? 10 picoseconds일까요? timescale directive가 이 질문에 답해 줍니다.
구문:
`timescale time_unit / time_precision| 부분 | 의미 | 예시 |
|---|---|---|
time_unit | 지연 시간의 기본 단위 | 1ns |
time_precision | 시뮬레이션의 정밀도 | 1ps |
timescale 앞의 백틱 `은 컴파일러 지시문임을 의미합니다.
예시
`timescale 1ns / 1pstime_unit = 1ns→#10은 10나노초를 의미합니다time_precision = 1ps→ 시뮬레이션은 가장 가까운 피코초 단위로 반올림됩니다
일반적인 timescale 값
| 시간 단위 | 정밀도 | 사용 사례 |
|---|---|---|
1ns / 1ns | 나노초 | 간단한 시뮬레이션 |
1ns / 1ps | 피코초 | 더 정밀함 |
1ps / 1ps | 피코초 | 고속 설계 |
1us / 1ns | 마이크로초 | 느린 시뮬레이션 |
지연에 미치는 영향
`timescale 1ns / 1ps
initial begin
#10 a = 1; // 10 나노초를 기다립니다
endtimescale이 없으면 일부 시뮬레이터는 기본값(대개 1ns)을 가정합니다. 항상 이를 지정하는 것이 가장 좋습니다.
중요한 규칙
| 규칙 | 설명 |
|---|---|
| 모듈 외부에 있어야 함 | 모든 모듈 정의 앞에 배치 |
| 백틱 기호 | `timescale이며 'timescale이 아님 |
| Time unit ≥ time precision | 1ns / 1ps는 올바르지만, 1ps / 1ns는 올바르지 않음 |
| 파일의 모든 지연에 영향을 줌 | 일반 지연, 게이트 지연, 할당 지연 |
챌린지
해야 할 일:
지연 시간이 10ns, 20ns, 30ns를 나타내도록 누락된 timescale directive를 추가하세요.
직접 해보기
// TODO: timescale 지시어 추가 (1ns / 1ps)
module timescale_challenge;
initial begin
$display("Time %0t", $time);
#10 $display("Time %0t (10ns = 10000ps)", $time);
#10 $display("Time %0t (20ns = 20000ps)", $time);
#10 $display("Time %0t (30ns = 30000ps)", $time);
$finish;
end
endmodule이 레슨에는 짧은 퀴즈가 포함되어 있습니다. 레슨을 시작해 문제를 풀고 진행 상황을 기록하세요.
기초의 모든 레슨
4Operators Part 1
Arithmetic OperatorsModulo OperatorComparison OperatorsRecap - Simple MathBitwise Operators7Assign And Gates
Continuous AssignmentAssign With OperatorsBuilt In Gate PrimitivesAND OR NOT GatesXOR XNOR GatesRecap - Logic Gate Circuit10Decision Making
If StatementIf - ElseRecap - Simple ComparatorCase StatementCasex And CasezRecap - ALU Design13Timing And Delays
What Are DelaysGate DelaysAssignment DelaysTimescale DirectiveClock GenerationRecap - Timing Control5Operators Part 2
Logical OperatorsReduction OperatorsShift OperatorsConcatenation OperatorConditional OperatorRecap - Operator Challenge3Number System
Binary RepresentationSized NumbersUnsized NumbersNegative NumbersSpecial Values X And ZRecap - Number Formats6Modules
Module StructureInput And Output PortsInout PortsModule InstantiationPort Mapping By NamePort Mapping By OrderRecap - Build A Module9Procedural Blocks
Always BlockInitial BlockSensitivity ListBlocking AssignmentNon Blocking AssignmentRecap - Always vs Initial15Traffic Light Controller
Defining The StatesState Machine Logic직접 연습해 보세요: 온라인 Verilog 컴파일러