Shift Register
Coddy Verilog 여정의 기초 섹션에 포함된 레슨. 90개 중 86번째.
챌린지
shift 레지스터는 각 클록 에지에서 data를 왼쪽에서 오른쪽으로 shift합니다. 각 비트는 다음 위치로 이동합니다.
4비트 shift 레지스터의 작동 방식
Initial: q0=0, q1=0, q2=0, q3=0
Clock 1: q0 = d, q1 = old q0, q2 = old q1, q3 = old q2
Clock 2: q0 = d, q1 = old q0, q2 = old q1, q3 = old q24번의 클록 사이클 후 첫 번째 input 비트가 q3에 도달합니다.
module 인터페이스
| 포트 | 방향 | 너비 | 설명 |
|---|---|---|---|
clk | input | 1 bit | 클록 신호 |
reset | input | 1 bit | 모든 output을 0으로 reset |
d | input | 1 bit | data input |
q0 | output | 1 bit | 첫 번째 플립플롭 output |
q1 | output | 1 bit | 두 번째 플립플롭 output |
q2 | output | 1 bit | 세 번째 플립플롭 output |
q3 | output | 1 bit | 네 번째 플립플롭 output |
여러분의 과제는 아래의 module을 완성하는 것입니다.
수행할 작업:
reset에서 모든 output을 0으로 설정합니다- 각 상승 클록 에지에서 data를 왼쪽에서 오른쪽으로 shift합니다:
q0은d를 받습니다q1은 oldq0를 받습니다q2는 oldq1을 받습니다q3는 oldq2를 받습니다
직접 해보기
module shift_register (
input clk,
input reset,
input d,
output reg q0,
output reg q1,
output reg q2,
output reg q3
);
// TODO: always @(posedge clk or posedge reset) 추가
// 리셋 시: q0<=0, q1<=0, q2<=0, q3<=0
// 그 외: 데이터 시프트: q0 <= d, q1 <= q0, q2 <= q1, q3 <= q2
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 컴파일러