Use three positive-edge-triggered D flip-flops, all driven by the same clock signal . Write the current binary representation as , with the least significant bit. The next state is the current value plus one when and minus one when , in each case modulo eight. A bit toggles under exclusive or with a one.
For upward counting, toggles when , while toggles when , the respective carry conditions. For downward counting the corresponding borrow conditions are and . Define the shared inverted direction and the two direction-match signals
Each is one exactly when : it equals for upward counting and for downward counting. Thus the Boolean functions for the three D inputs are
Implement this with two NOT gates for , four two-input exclusive or gates for , and one two-input AND gate. Connect to the D flip-flop whose output is ; feed the three outputs back into the indicated gates. All three flip-flops capture simultaneously, so each equation uses the old state.
Figure 1.
Synchronous three-bit up-down binary counter: common clock signal, explicit D inputs and feedback
. Details.
Current Next for Next for
000001111
001010000
010011001
011100010
100101011
101110100
110111101
111000110
Every three-bit state is valid. A reset may initialize the binary counter to zero if required; counting itself needs no extra state. The direction input must meet the setup time and hold time requirements at the active clock edge.
For a normal half-precision floating-point number, write the stored fields as sign , biased exponent and ten-bit fraction . The value is for . The leading one is implicit: the ten stored fraction bits give eleven significant binary digits including that one. The normalized binary representations and stored fields are
ValueNormalized binary representationSign, biased exponent, fraction
0 01110 0000000000
0 01110 0100000000
1 01100 1000000000
0 10010 1111000000
Thus the four 16-bit words are
Every conversion is exact: all four numbers have terminating binary representations within the available precision.
Both signs are positive, so perform addition of the aligned significands. The true exponents are and , a difference of four. Shift the smaller significand right four places, retaining its low bits:
Add at the common exponent:
Renormalization raises the true exponent to and the biased exponent to . There are only seven fraction places to retain, so no floating-point rounding changes the result:
The complete word is 0100110000001000.
The smallest positive normal half-precision floating-point number uses and a zero fraction, while the largest uses and all ten fraction bits equal to one. Hence
The corresponding words are 0 00001 0000000000 and 0 11110 1111111111. The stored exponent is reserved and cannot extend the finite normal range.
For a subnormal number, and the implicit leading bit becomes zero, while the scale remains . The least positive nonzero fraction is , giving
Using scale here would be incorrect: the subnormal number convention uses the minimum normal scale, not the ordinary biased-exponent formula at .
For the unsigned interpretation of the binary string, the set positions have weights . Thus
In 16-bit two's complement, the most significant bit is set, so subtract from that unsigned interpretation:
For a half-precision floating-point number, split the fields at their actual boundaries rather than the printed groups of four:
The sign is negative, the true exponent is , and the fraction is . It is a normal finite value, so
Use a block allocation bitmap, one bit per allocatable disk block number, or a free-block list. Allocation removes a free block from the free representation; deallocation inserts it. Reserved file system structures, including the inode table and the free-space representation itself, must never be offered as free file data blocks. Free inodes can be tracked separately by an inode allocation bitmap.
A file data block becomes reusable when the file system has removed its ownership from the file. This happens, for example, when truncation discards that portion of the file, or when the file is finally destroyed. Destruction requires both removal of its last hard link and release of its last live reference: unlinking an open file must not reclaim blocks still needed through an open file description. A memory-mapped file, if supported, also requires its references to be accounted for. The indirect block pointers' own blocks are reclaimed when they are no longer needed.
There are two relevant notions of accessibility. Pathname-accessible files are those reached from the root through valid directory entries, subject to permissions; their allocated blocks are found through their inodes. Already-open files can additionally remain accessible through file descriptors even after their last names disappear. Allocated file system structures and blocks pinned by an operation must also be excluded from allocation. A block allocation bitmap must therefore describe actual allocation, rather than merely the blocks of currently named regular files.
One processor can still run several processes and be interrupted. Updating ownership and the free-space representation must therefore be serialized with respect to competing operations, for example through an appropriate kernel critical section. Persistence across a crash additionally requires file-system crash consistency, such as ordered updates or file-system journaling.
Each parenthesized pair in the given Boolean function tests equality of two input bits:
This is logical equivalence, or the two-input XNOR gate function. Thus is one whenever either input pair agrees. Generate the four complemented inputs with four inverters, and define the following NAND gate outputs:
Feed these four outputs into a single four-input NAND gate. De Morgan's laws give
Here juxtaposition denotes logical conjunction. The construction uses only inverters, two-input NAND gates and one four-input NAND gate, as required.
In the pictured single-cycle MIPS architecture, RegDst selects the write address of the register file: zero selects instruction bits , the rt field used by a load; one selects bits , the rd field used by an MIPS R-type instruction. RegWrite enables the clocked write to the selected processor register.
ALUSrc selects the second ALU input: zero uses the second register file read output, while one uses the sign-extended 16-bit immediate field. The zero signal is produced by the ALU, rather than being an opcode-decoder output: it is one exactly when the ALU result is zero. During beq, the ALU subtracts its operands, so zero tests equality. The diagram combines it with Branch to select the branch target instead of .
Again use independent externally initialized MIPS instruction tests. First preset $t0=7, $t1=5, and execute
add $t2, $t0, $t1
The normal result, also obtained with ALUSrc stuck at zero, is 12. If the line is stuck at one, the second ALU operand is the sign-extended low 16 instruction bits. For this exact instruction they encode rd=10, shift amount zero and function , giving . The erroneous result is therefore .
For the second test, preset $s0=L, $t3=4, memory at to 37 and memory at to 99, with both words valid and aligned. Execute
lw $t3, 0($s0)
Normally, and with ALUSrc stuck at one, the address is and the result is 37. With the line stuck at zero, the second ALU operand is the old $t3=4, so the load reads 99 from . Thus
The register file in this datapath supplies both read ports combinationally for whatever read addresses the instruction fields present. Reading a processor register is harmless, and a result that the current MIPS instruction does not need can simply be ignored. Only writes require an explicit enable because writes change architectural state. There is consequently no functional need for RegRead in this design.
The data-memory read interface has an explicit MemRead enable. Non-load MIPS instructions can present irrelevant or invalid addresses at the memory address input; an external memory transaction should not be initiated merely because those bits happen to be present. An explicit enable also permits interfaces with memory-mapped input-output, where a read can have a side effect. It can reduce unnecessary activity even for ordinary memory.
This is a distinction in the supplied datapath, rather than a universal physical prohibition: other register files can have read enables, and an ideal side-effect-free memory can be modeled with continuous reads.
Use a synchronous binary counter with three positive-edge-triggered D flip-flops, all driven by the same clock signal. Write their outputs , with the least significant bit. The next-state Boolean functions are
Implement these with one NOT gate, two exclusive or gates, and one AND gate. Connect each to its corresponding D flip-flop; its output is address line . A reset input clears all three flip-flops to zero, so the first selected sensor is sensor zero.
The state sequence is
The low bit toggles at every clock edge, the middle bit toggles exactly when the old low bit is one, and the high bit toggles exactly when both old lower bits are one. These are precisely the carry conditions for incrementing a three-bit binary representation. Every possible state belongs to the cycle, so there is no unused state requiring recovery. Choose a clock period allowing the combinational logic to settle before the next capture.
For data inputs and selection bits , use a three-to-eight binary decoder. Its output is the minterm that is one exactly when the selection equals the three-bit binary representation of . For example,
Gate each data input with its decoded selection using an AND gate, then combine all eight results with an OR gate:
Exactly one is asserted, so for the selected , regardless of the other data inputs. A direct implementation uses three shared NOT gates, eight three-input AND gates for the binary decoder, eight two-input AND gates for the data, and one eight-input OR gate. Equivalently, combine each decoder term with its data input in one four-input AND gate. Larger logic gates may be built from two-input ones.
Use eight parallel 8:1 multiplexers and one shared three-bit binary counter. If is bit from sensor , connect to multiplexer . Connect all selection inputs to the binary counter outputs. Then data line carries , so all eight data lines belong to the same selected sensor. Send the three counter outputs to the receiver as the address lines as well.
Figure 1.
One shared binary counter selects the same sensor in eight parallel multiplexers
. Details.
After reset the receiver sees sensors , one per clock period. Sample the data and address only after the binary counter and multiplexers have settled, for example on the opposite clock edge with a sufficiently long clock period. Changing addresses can otherwise cause transient logic hazards. The transmitter uses eleven signal lines, apart from any shared clock or reset connection.
Use an eight-bit modulo-256 binary counter, eight 256:1 multiplexers, eight data lines and eight address lines. Thus there are sixteen signal lines, apart from clock and reset, and a full scan takes 256 clock periods. The counter next-state equations generalize to
A 256:1 multiplexer for one data bit can be made hierarchically: 32 first-stage 8:1 multiplexers select within eight-sensor groups using ; four second-stage 8:1 multiplexers select groups using ; one final 4:1 multiplexer selects using . A final 8:1 multiplexer also works if one select input is fixed to zero and only four data inputs are used. Repeat this network eight times, sharing all selection lines. Allow for the extra propagation delay when choosing the clock period.
Generate four partial-product bits with AND gates:
The binary multiplication expansion is . Add the two weight-two bits with a half adder, then add its carry to with a second half adder. The complete combinational logic is
Thus four AND gates for the partial products and two half adders suffice. Each half adder contains one exclusive or gate and one AND gate. In the largest case , these equations produce , including the necessary fourth output bit.
Split the four-bit unsigned inputs into two-bit halves: and . Use four copies of the two-bit binary multiplier to compute , , , and . Then
The extreme terms occupy disjoint output positions: uses positions zero to three and uses positions four to seven. Form by concatenating their four-bit outputs, with in the upper half and in the lower half. This needs wiring alone, so without an adder.
Use the first eight-bit adder to form after zero-extension, and the second to form . Thus four two-bit binary multipliers and two eight-bit adders suffice. The fixed left bit shift is also wiring alone.
The middle sum can reach , so preserve all five of its potentially nonzero bits; retaining only four would be wrong. Its shifted value is at most 72. The final result is at most , so both additions fit in eight bits. Concatenating the disjoint extreme terms is what saves an addition.
Use unsigned inputs as in the preceding parts. Store a 16-bit accumulator , a 16-bit shifted multiplicand , an eight-bit multiplier , and a three-bit iteration binary counter . The sequential circuit has one 16-bit adder, a 16-bit multiplexer selecting or zero from , fixed one-place bit shifts, and load/hold selection for the digital registers. The input values are captured when start is accepted, so later input changes cannot alter the operation.
Figure 1.
The shift-and-add binary multiplier reuses one 16-bit adder for eight iterations
. Details.
Use three control states with the following synchronous transition table. All assignments in a row use the old digital register values and occur together at the active clock edge.
StateConditionRegister updatesNext stateIDLEstart = 0Hold all digital registersIDLEIDLEstart = 1, , , RUNRUN, , , RUNRUN, , ; hold DONEDONEstart = 1Hold all digital registersDONEDONEstart = 0Hold all digital registersIDLE
Reset selects IDLE and clears the digital registers. Set and done = 1 exactly in DONE. A start pulse in IDLE launches one multiplication; further pulses during RUN are ignored. Holding start high cannot repeatedly launch operations: DONE waits for it to go low before rearming. The product remains stored while waiting and through the following IDLE state. There are eight RUN clock edges after the loading edge; the last addition is captured before done becomes high.
For correctness, let denote the captured values. After iterations, for , the loop invariant is
so . Writing , the next accumulation adds , the left bit shift doubles , and the logical right shift changes to . Hence the invariant is preserved. At , , giving . The largest product is , so the accumulator fits. Even the final shifted multiplicand is , so it also fits.
Take as the four input bits, of weights , and let 1 light a segment of the seven-segment display. The required truth table is
value   wxyz   abcdefg
 0      0000   1111110
 1      0001   0110000
 2      0010   1101101
 3      0011   1111001
 4      0100   0110011
 5      0101   1011011
 6      0110   1011111
 7      0111   1110000
 8      1000   1111111
 9      1001   1111011
10      1010   0000000
11      1011   0000000
12      1100   0000000
13      1101   0000000
14      1110   0000000
15      1111   0000000
Here binary-coded decimal represents one decimal digit per group of four bits. The six unused codes must be zeros in every output for this part; they are not don't-care conditions.
Use as the three select bits of the 8-to-1 multiplexer, so address selects data input . Connect
A single NOT gate produces , shared by and ; the other connections are wires and constant logic levels. For each fixed select address the data input reproduces the corresponding two rows of the truth table, including zeros for all invalid codes.
Address a read-only memory with the two state bits and two input bits. Each word stores the two next-state bits and INC, so a direct replacement for all the combinational logic is bits, or 48 bits. Program its 16 words from the state table, duplicating a state's output over all four input addresses. The two D flip-flops and clock remain outside the ROM.
If INC retains its separate two-state-bit decoder, only the next-state logic needs a -bit ROM, plus that output gate. Storing output in a separate state-only ROM would use further bits. These factored options have a different boundary from replacing all the combinational logic with one ROM.