Designing The Logic
Parte da seção Fundamentos do Journey de Verilog da Coddy. Lição 44 de 90.
Desafio
Projetar a lógica significa descobrir quais equações o circuito precisa com base na tabela-verdade.
Tabela-verdade:
| a | b | sum | carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Etapa 2: Encontre o padrão para sum
- sum = 1 quando a=0,b=1 ou a=1,b=0
- sum = 1 quando a e b são diferentes
- Diferente = XOR →
sum = a ^ b
Etapa 3: Encontre o padrão para carry
- carry = 1 somente quando a=1 e b=1
- Ambos = AND →
carry = a & b
Etapa 4: Escreva as equações
sum = a ^ b
carry = a & b
O que fazer:
Sua tarefa é adicionar as equações lógicas ausentes dentro do module.
1. Adicione uma instrução assign para sum (a XOR b)
2. Adicione uma instrução assign para carry (a AND b)
Experimente você mesmo
module half_adder (
input a,
input b,
output sum,
output carry
);
endmoduleTodas as lições de Fundamentos
1Introdução
O que é VerilogHardware vs. SoftwareSeu primeiro móduloComentáriosNíveis de abstração de projeto4Operators 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 LogicPratique por conta própria: Compilador de Verilog online