Reg Type
Coddy Verilog 여정의 기초 섹션에 포함된 레슨. 90개 중 7번째.
Reg는 Verilog의 두 번째 주요 데이터 유형입니다. wire와 달리 reg는 값을 저장합니다. 이는 무언가가 값을 변경할 때까지 값을 유지하는 변수입니다.
reg는 값을 저장할 수 있습니다reg는always블록에서 사용됩니다- 하드웨어에서
reg는 "register"를 의미하지 않습니다. 단지 “storage”를 의미합니다
reg 선언하기
reg x; // 단일 비트 reg
reg y, z; // 한 줄에 여러 regreg의 작동 방식
module reg_example;
reg x;
initial begin
x = 0; // x가 0이 됨
$display("x = %d", x); // 출력: x = 0
x = 1; // x가 1이 됨
$display("x = %d", x); // 출력: x = 1
end
endmodule챌린지
해야 할 일:
-
count라는 reg를 추가하세요
직접 해보기
module counter(
input clk,
input reset,
output out // 기본적으로 wire (reg 제거)
);
// 여기에 reg count 선언
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 Design5Operators 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 컴파일러