Play with HDLBits
- Compliling (Logic Synthesis)
HDL->Circuits - Simulation
Circuit match/mismatch (ref)
Waveform match/mismatch (timing diagram, ref)
- Wire: directional, continuous assignment. Assignment creates connections between wires. Wires are declared at the input/output, 1bit default.
- Inverter: bitwise-NOT(~), logical-NOT(!)
- AND-Gate: bitwise-AND(&), logical-AND(&&)
- OR-Gate: bitwise-OR(|), logical-OR(||)
- XNOR-Gate: bitwise-XOR(^), no logical-XOR
- Declaring wires: connect internal components together
- type [upper:lower] vector_name
- Implicit nets
In Verilog, net-type signals can be implicitly created by an assign statement or by attaching something undeclared to a module port. Implicit nets are always one-bit wires. `default_nettype none // Disable implicit nets. Reduces some types of bugs. - vector cannot be reversed directly, by bit assignment with concatenation to save a bit of coding.
- Sign-extending, concatenation/replication
- The hierarchy of modules is created by instantiating one module inside another.
- Connect signals to module ports: by position/name
- Full adder equations: sum = a^b^cin, cout = a&b|a&cin|b&cin
- ripple carry adder -> delay of stage computing carry-out; carry-select adder: faster with a 2-to-1 mux.
- Two types of always blocks: combinational: always @(*); clocked: always @(posedge clk)
- Blocking vs. Non-Blocking assignment
- Always if: 2-to-1 mux; conditional operator
- Always case: 6-to-1 mux
- Priority Encoder: outputs the position of the first 1 bit in the vector, using if or casez
- Conditional Ternary Operator: (()? a: ()? b: c))
- Reduction operators: parity check; operate all bits of one vector
- Long vector reversal: combinational for
- Popcount: combinational for, if
- array instantiation/generate for multiple instantiation such as Multiple bit full_adder, ripple carry adder