






Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!







Digital Logic Laboratory Report
1 D Flip-Flop
A flip-flop, also called a data flip-flop or delay flip-flop, is a basic electronic component used to store one bit of information. It has two stable states, called SET and RESET, which represent the binary values 1 and 0.
Figure 1: D Flip-Flop Circuit Diagram
Table 1: D Flip-Flop Truth Table
Clk (edge) D Q Q’ Q(n+1) Q’(n+1) ↓ 0 0 1 Q (no change) Q’ (no change) ↓ 1 0 1 Q (no change) Q’ (no change) ↑ 0 0 1 0 1 ↑ 1 1 0 1 0
Figure 4: D Flip-Flop Data Storage Register
1.6.2 Data Transferring as Shift Registers
Data enters via the Serial Data In line at D 3 and shifts one stage to the right with each rising clock edge. The first bit is latched into Q 3 , then propagates sequentially through Q 2 , Q 1 , and Q 0 over subsequent cycles. This operation, known as right-shift transmission, moves data from left to right (D 3 → D 0 ) across the register, effectively converting the one-bit-at-a-time input into a complete 4-bit value that can be read simultaneously from Q 3 – Q 0.
Figure 5: D Flip-Flop 4-bit Shift Register
2 Full Adder
A full adder is a combinational circuit that adds three binary inputs: A, B, and a carry input Cin. It produces two outputs: the sum (S) and the carry output (Cout). The sum is the result of the addition, and the carry output is sent to the next stage if there is an overflow.
Figure 6: Full Adder Block Diagram
We use a full adder because when a carry-in bit is available, a 1-bit half-adder cannot be used since it does not take a carry-in bit.
Table 2: Full Adder Truth Table
A B Cin S Cout 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1
S = A ⊕ B ⊕ Cin (1) Cout = A · B + Cin · (A ⊕ B) (2)
The governing equations are:
ci+1 = ai · bi + (ai ⊕ bi) · ci (3) si = ai ⊕ bi ⊕ ci (4)
Figure 9: N-bit Ripple Carry Adder
2.6.2 Arithmetic Logic Units (ALUs)
4.2.1 — Definition and Structural Composition of the ALU An Arithmetic Logic Unit (ALU) is a digital subsystem designed to perform arithmetic and logical op- erations on binary data. It is composed of multiple interconnected combinational circuits operating in parallel, with control logic selecting the desired operation and producing a final result along with status indicators.
Figure 10: ALU Block Diagram
4.2.2 — Fundamental Blocks of the ALU The ALU is constructed from the fol- lowing essential components:
a) Logic Gates (AND, OR, XOR) These implement bitwise logical operations:
b) Arithmetic Unit (Adder/Subtractor) Built from cascaded full adders, this unit performs:
c) Multiplexer (MUX) Selects one of several computed outputs based on control signals.
d) Status Flags Provide information about the result:
e) Control Signals Define which operation the ALU performs.
4.2.3 — Role of the Full Adder in the ALU The full adder is the fundamental building block of the arithmetic unit. It enables the ALU to perform binary addition, which is the basis for most arithmetic operations.
Construction of a Multi-bit Adder A multi-bit adder is constructed by cascad- ing multiple full adders in series. For a 32-bit system:
The carry propagates as:
ci+1 = ai · bi + (ai ⊕ bi) · ci (5)
This structure is known as a ripple-carry adder.
Implementation of Subtraction Subtraction is performed using the two’s com- plement method: A − B = A + (−B) = A + B + 1 (6) To implement this in hardware, each bit of B is XORed with a control signal SUB, and the initial carry-in is set to:
Cin = SUB (7)
17 -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 18 architecture behavioral of adder_subtractor is 19 20 signal B_mod : std_logic_vector (N -1 downto 0) ; 21 signal carry : std_logic_vector ( N downto 0) ; 22 23 begin 24 -- Step 1: XOR each B bit with ctrl ( inverts B when ctrl =1) 25 B_mod <= B xor ( others = > ctrl ) ; 26 27 -- Step 2: ctrl is also the initial carry - in ( adds +1 for two ’ s complement ) 28 carry (0) <= ctrl ; 29 30 -- Step 3: Chain N full adders 31 gen : for i in 0 to N -1 generate 32 result ( i ) <= A ( i ) xor B_mod ( i ) xor carry ( i ) ; 33 carry ( i +1) <= ( A ( i ) and B_mod ( i ) ) or ( carry ( i ) and ( A ( i ) xor B_mod ( i ) ) ) ; 34 end generate ; 35 36 cout <= carry ( N ) ; 37 38 end architecture behavioral ;
Listing 1: 32-bit Parameterized Adder/Subtractor