Digital Systems - Mock Exam 3
Questa pagina non ha ancora la versione ripasso: qui sotto c'è il testo completo.
In questa pagina 24
Mock exam built on the model of the written exams of the equivalent course in Italian (Circuiti Digitali, Information Engineering, UniPD; sessions of 21 June 2022 and 11 July 2022). The real papers have 20 multiple-choice questions on the whole syllabus (correct answer , wrong answer , no answer ) and 3 exercises on separate sheets: (1) minimization of a function with Karnaugh maps, (2) design of a finite state machine, (3) VHDL of a state machine with a test bench. This mock keeps the same structure. Because the course in English also covers computer organisation and memory, 4 of the 20 questions (17 to 20) are on addressing modes and virtual memory.
Duration: 2 hours 30 minutes. The real papers do not print the points of the exercises: here they are proposed as questions points, Exercise 1 points, Exercise 2 points, Exercise 3 points (total , grade out of 30 points ). No material is allowed: no books, notes, calculators or phones. This mock is centred on codes, CMOS technology, programmable logic, RTL, datapath and control unit.
Quiz 1
The binary number is converted into the Gray code (most significant bit on the left). The result is:
- a.
- b.
- c.
Show the result
c.
Show the full solution
The conversion rule copies the most significant bit and then computes : , , , , so . Check on the table of the 4-bit Gray code: the number has Gray code . Choice a comes from XOR-ing each bit with the bit on its right ( shifted left), the wrong direction; choice b is the Gray code of , i.e. input and output exchanged. Theory: Binary Codes - BCD, ASCII, Unicode, Parity and GrayAn n-bit code distinguishes 2^n elements. BCD encodes each decimal digit on 4 bits (1010 to 1111 unused; it differs from the plain binary of the number). ASCII uses 7 bits for 128 characters; Unicode UTF-8 uses 1 to 4 bytes and is ASCII compatible. A parity bit detects errors on an odd number of bits. Hamming distance is the number of differing bits. Gray code makes consecutive numbers differ by one bit and is built by reflection or with g_i = b_i xor b_(i+1).Binary Codes - BCD, ASCII, Unicode, Parity and Gray →.
Quiz 2
Words of 8 bits (7 data bits plus 1 parity bit) are transmitted with even parity. Which of the following received words certainly contains an error?
- a.
- b.
- c.
Show the result
a.
Show the full solution
With even parity the number of 1s in the whole word, parity bit included, must be even. has five 1s: odd, so at least one bit is wrong. has four 1s and has none: both are acceptable (parity detects errors on an odd number of bits, so two compensating errors would go unnoticed, but these words show no sign of error). Typical mistake: saying that parity can also locate and correct the wrong bit. Theory: Binary Codes - BCD, ASCII, Unicode, Parity and GrayAn n-bit code distinguishes 2^n elements. BCD encodes each decimal digit on 4 bits (1010 to 1111 unused; it differs from the plain binary of the number). ASCII uses 7 bits for 128 characters; Unicode UTF-8 uses 1 to 4 bytes and is ASCII compatible. A parity bit detects errors on an odd number of bits. Hamming distance is the number of differing bits. Gray code makes consecutive numbers differ by one bit and is built by reflection or with g_i = b_i xor b_(i+1).Binary Codes - BCD, ASCII, Unicode, Parity and Gray →.
Quiz 3
A cyclic Gray code for words is built by taking the code of the first five words, , and appending their mirror image with the most significant bit set to . The word that follows is:
- a.
- b.
- c.
Show the result
b.
Show the full solution
The mirror image of the first five words, in reverse order and with the MSB at , is . So after (the last word of the first half) comes , which differs from in one bit only (the MSB), as a Gray code requires; the code is also cyclic because and differ by one bit. Choice a is the word that follows in the full -bit Gray code of words, which is not the code asked. Choice c is the second word of the reflected half and differs from in three bits. Theory: Binary Codes - BCD, ASCII, Unicode, Parity and GrayAn n-bit code distinguishes 2^n elements. BCD encodes each decimal digit on 4 bits (1010 to 1111 unused; it differs from the plain binary of the number). ASCII uses 7 bits for 128 characters; Unicode UTF-8 uses 1 to 4 bytes and is ASCII compatible. A parity bit detects errors on an odd number of bits. Hamming distance is the number of differing bits. Gray code makes consecutive numbers differ by one bit and is built by reflection or with g_i = b_i xor b_(i+1).Binary Codes - BCD, ASCII, Unicode, Parity and Gray →.
Quiz 4
Let clk, rst, en, d, q be std_logic signals. The VHDL fragment
process (clk, rst)
begin
if rst = '0' then
q <= '0';
elsif clk'event and clk = '1' then
if en = '1' then q <= d; end if;
end if;
end process;describes:
- a. a D latch with enable
enand active-low clear - b. a positive-edge-triggered flip-flop with asynchronous active-low reset and load enable
- c. a positive-edge-triggered flip-flop with synchronous reset
Show the result
b.
Show the full solution
rst is in the sensitivity list and is tested first, outside the branch of the clock edge: the reset acts at any time, without waiting for the clock (asynchronous), and it is active at '0'. The condition clk'event and clk = '1' is the rising edge, so the element is edge-triggered, not a latch (a latch would be level-sensitive and have d in the list). Inside the edge, if en = '1' without else makes the register hold its value when en = '0': this is the load enable. For a synchronous reset, rst would be missing from the list and tested inside the edge branch. Theory: VHDL - Latches, Flip-Flops and ResetsIn VHDL a memory element is a process in which some branch does not assign the signal: the D latch is process(D,C) with if C='1' then Q<=D, the positive-edge-triggered flip-flop is process(CLK) with if CLK'event and CLK='1'. Asynchronous reset: RST is in the sensitivity list and tested first (if RST='1' ... elsif clock edge); synchronous reset: only CLK in the list and RST tested inside the clock-edge branch, so a clock edge is needed for it to act. The testbench of a synchronous circuit has a process generating the clock and one applying inputs away from the active edge.VHDL - Latches, Flip-Flops and Resets →, Registers and Load ControlAn n-bit register is n flip-flops with a common clock, and a counter is a register that steps through a sequence of states. Loading can be controlled by clock gating (an OR with the clock, which saves power but adds delays and clock skew) or, preferably, by load enable (a 2-to-1 MUX before each D input selecting the new data or the flip-flop's own output). Complex systems are split into a datapath (registers and arithmetic-logic blocks) and a control unit (an FSM that sends control signals and receives status signals).Registers and Load Control →.
Quiz 5
In a static CMOS 3-input NOR gate the inputs are , , . How many transistors conduct and what is the output ?
- a. nMOS and pMOS conduct,
- b. nMOS and pMOS conduct,
- c. nMOS and pMOS conduct,
Show the result
a.
Show the full solution
An nMOS conducts when its gate is , a pMOS when its gate is . With : the nMOS of conducts ( nMOS) and the pMOS of and conduct ( pMOS). In the NOR the pull-up network is three pMOS in series: it needs all three on, but the pMOS of is off, so the pull-up is open. The pull-down network is three nMOS in parallel: the nMOS of is on, so the output is connected to ground, (indeed ). Choice b swaps the roles of nMOS and pMOS; choice c has the right count of devices but the wrong output: the two networks are never both on or both off. Theory: CMOS Gates and Technology ParametersIn CMOS integrated circuits MOSFETs are modelled as switches: nMOS closed when the gate is 1, pMOS closed when the gate is 0. A static gate has a pull-up network (only pMOS, to Vdd) and a dual pull-down network (only nMOS, to ground): one is ON and the other OFF. NAND has series nMOS and parallel pMOS, NOR the opposite; an n-input gate has 2n transistors. Real-gate parameters: fan-in, fan-out, noise margin, propagation delay, power dissipation and cost.CMOS Gates and Technology Parameters →.
Quiz 6
A 4-input AND gate is built in static CMOS as a NAND followed by an inverter. The number of transistors is:
- a.
- b.
- c.
Show the result
c.
Show the full solution
A NAND (or NOR) with inputs has transistors ( nMOS and pMOS): for the 4-input NAND. The inverter adds transistors: (formula ). Choice a forgets the inverter; this is also why AND and OR gates cost more than NAND and NOR, and circuits are normally mapped on NAND and NOR. Theory: CMOS Gates and Technology ParametersIn CMOS integrated circuits MOSFETs are modelled as switches: nMOS closed when the gate is 1, pMOS closed when the gate is 0. A static gate has a pull-up network (only pMOS, to Vdd) and a dual pull-down network (only nMOS, to ground): one is ON and the other OFF. NAND has series nMOS and parallel pMOS, NOR the opposite; an n-input gate has 2n transistors. Real-gate parameters: fan-in, fan-out, noise margin, propagation delay, power dissipation and cost.CMOS Gates and Technology Parameters →, Implementation Technologies - CMOS Gates and Technology ParametersIn CMOS integrated circuits MOSFETs behave as switches: an nMOS conducts when its gate is 1, a pMOS when its gate is 0. A static gate has a pull-up network (only pMOS, to Vdd) and a dual pull-down network (only nMOS, to ground), exactly one of which is on. NAND has series nMOS and parallel pMOS, NOR the opposite; an n-input NAND or NOR has 2n transistors. Technology parameters are fan-in, fan-out, noise margin, propagation delay (limits clock frequency), power dissipation and cost (silicon area, NRE and production costs).Implementation Technologies - CMOS Gates and Technology Parameters →.
Quiz 7
The dynamic power dissipated by a CMOS circuit is . If the supply voltage is halved while the clock frequency and the circuit stay the same, the power becomes:
- a. one half
- b. one quarter
- c. unchanged
Show the result
b.
Show the full solution
grows with the square of : with we get . Choice a would hold if were proportional to (as it is to ). Lowering the voltage is the most effective way of reducing power, at the price of slower gates (a larger delay and so a lower maximum frequency). Theory: CMOS Gates and Technology ParametersIn CMOS integrated circuits MOSFETs are modelled as switches: nMOS closed when the gate is 1, pMOS closed when the gate is 0. A static gate has a pull-up network (only pMOS, to Vdd) and a dual pull-down network (only nMOS, to ground): one is ON and the other OFF. NAND has series nMOS and parallel pMOS, NOR the opposite; an n-input gate has 2n transistors. Real-gate parameters: fan-in, fan-out, noise margin, propagation delay, power dissipation and cost.CMOS Gates and Technology Parameters →.
Quiz 8
The two functions and are to be implemented. How many product terms (AND gates of the AND array) are needed in a PLA and in a PAL, respectively?
- a. and
- b. and
- c. and
Show the result
a.
Show the full solution
The distinct products are , and . In a PLA both arrays are programmable and a product can be shared between outputs: is generated once and enters both ORs, so products are enough. In a PAL the OR array is fixed and every output has its own ANDs: needs and , needs again and , so products. Typical mistake: believing that the PAL can share products too. Theory: Programmable Logic Devices - ROM, PLA, PAL and FPGAProgrammable logic devices (PLD) have logic structures configurable by the manufacturer or the user, which is hardware configuration and not software programming. ROM: 2^k words of n bits, a decoder followed by programmable ORs, so a physical truth table; PLA: programmable AND and OR arrays with product terms shared between outputs; PAL: programmable ANDs and fixed ORs, no sharing; FPGA: programmable logic blocks with look-up tables and flip-flops, programmable routing and I/O, with a volatile or non-volatile configuration memory. Programming is irreversible (fuse, anti-fuse, mask) or reconfigurable (SRAM, floating gate).Programmable Logic Devices - ROM, PLA, PAL and FPGA →.
Quiz 9
A ROM has address inputs and data outputs. Its capacity in bytes is:
- a.
- b.
- c.
Show the result
c.
Show the full solution
A ROM has words of bits. Here words of bits, i.e. bits, and dividing by : bytes (equivalently, words of bytes). Choice a is the number of words, choice b the number of bits. Theory: Programmable Logic Devices - ROM, PLA, PAL and FPGAProgrammable logic devices (PLD) have logic structures configurable by the manufacturer or the user, which is hardware configuration and not software programming. ROM: 2^k words of n bits, a decoder followed by programmable ORs, so a physical truth table; PLA: programmable AND and OR arrays with product terms shared between outputs; PAL: programmable ANDs and fixed ORs, no sharing; FPGA: programmable logic blocks with look-up tables and flip-flops, programmable routing and I/O, with a volatile or non-volatile configuration memory. Programming is irreversible (fuse, anti-fuse, mask) or reconfigurable (SRAM, floating gate).Programmable Logic Devices - ROM, PLA, PAL and FPGA →, Memories - ROM, RAM, SRAM and DRAMA memory is a set of cells organised in words, with control circuitry. It is classified as read-only (ROM) or read/write, random access (RAM), serial (SAM) or hybrid (Flash), volatile (SRAM, DRAM) or non-volatile. A RAM 2^k x n has k address bits (independent of n), n data bits, read/write and chip select. SRAM uses a bistable latch cell, is fast and needs no refresh; DRAM stores charge on a capacitor, is denser and needs refresh. Chips are organised as a row/column matrix with coincident selection and tri-state outputs, and combined in arrays for more words or more bits per word.Memories - ROM, RAM, SRAM and DRAM →.
Quiz 10
A look-up table (LUT) with inputs, as used in the logic blocks of an FPGA, needs how many configuration bits?
- a.
- b.
- c.
Show the result
b.
Show the full solution
A LUT with inputs is a memory of bits, one for each row of the truth table of the function it implements (the bits drive the data inputs of a multiplexer selected by the inputs). With : bits, which can realise different functions. Choice a confuses the number of inputs with the number of bits. Theory: Programmable Logic Devices - ROM, PLA, PAL and FPGAProgrammable logic devices (PLD) have logic structures configurable by the manufacturer or the user, which is hardware configuration and not software programming. ROM: 2^k words of n bits, a decoder followed by programmable ORs, so a physical truth table; PLA: programmable AND and OR arrays with product terms shared between outputs; PAL: programmable ANDs and fixed ORs, no sharing; FPGA: programmable logic blocks with look-up tables and flip-flops, programmable routing and I/O, with a volatile or non-volatile configuration memory. Programming is irreversible (fuse, anti-fuse, mask) or reconfigurable (SRAM, floating gate).Programmable Logic Devices - ROM, PLA, PAL and FPGA →.
Quiz 11
The following microoperations are specified in RTL (both conditions can be in the same cycle): At a clock edge with , , and , the register becomes:
- a.
- b.
- c.
Show the result
a.
Show the full solution
The second condition contains : it is when , so the second transfer does not take place. The two statements behave as an if-then-else with priority to : . In the circuit a multiplexer selects the source and enables the loading. Choice c would be the logical OR of the two sources, which is not what a conditional transfer does. Theory: Microoperations and RTLA microoperation is an elementary operation on register data, written in Register Transfer Language (RTL), for example K1: R2 <- R1 meaning that when K1 is 1 the content of R1 is copied into R2 at the clock edge. Microoperations are transfers (simultaneous ones separated by commas exchange contents), arithmetic (add, subtract, increment, decrement), logic bit by bit with masks (AND clears, OR sets to 1, XOR complements) and shifts (sl towards the MSB doubles, sr towards the LSB halves).Microoperations and RTL →, Registers and Load ControlAn n-bit register is n flip-flops with a common clock, and a counter is a register that steps through a sequence of states. Loading can be controlled by clock gating (an OR with the clock, which saves power but adds delays and clock skew) or, preferably, by load enable (a 2-to-1 MUX before each D input selecting the new data or the flip-flop's own output). Complex systems are split into a datapath (registers and arithmetic-logic blocks) and a control unit (an FSM that sends control signals and receives status signals).Registers and Load Control →.
Quiz 12
An 8-bit register contains . The microoperation (bitwise XOR with a mask) gives:
- a.
- b.
- c.
Show the result
b.
Show the full solution
XOR with complements the bit, XOR with leaves it unchanged. The mask complements the four most significant bits and keeps the four least significant: , , so . Choice a is the result of an AND with the mask (it clears the low nibble), choice c of an OR (it sets the high nibble to ). Theory: Microoperations and RTLA microoperation is an elementary operation on register data, written in Register Transfer Language (RTL), for example K1: R2 <- R1 meaning that when K1 is 1 the content of R1 is copied into R2 at the clock edge. Microoperations are transfers (simultaneous ones separated by commas exchange contents), arithmetic (add, subtract, increment, decrement), logic bit by bit with masks (AND clears, OR sets to 1, XOR complements) and shifts (sl towards the MSB doubles, sr towards the LSB halves).Microoperations and RTL →.
Quiz 13
The 8-bit register (unsigned value ) executes the shift microoperation (shift left, the bit entering on the right is ). The new content is:
- a.
- b.
- c.
Show the result
c.
Show the full solution
A shift left moves every bit one position towards the MSB; the bit that leaves is the leftmost ( here) and a enters on the right: , which is . A shift left multiplies by as long as no significant bit is lost (here the leaving bit was ). Choice a is the shift right (); choice b enters a instead of a . Theory: Microoperations and RTLA microoperation is an elementary operation on register data, written in Register Transfer Language (RTL), for example K1: R2 <- R1 meaning that when K1 is 1 the content of R1 is copied into R2 at the clock edge. Microoperations are transfers (simultaneous ones separated by commas exchange contents), arithmetic (add, subtract, increment, decrement), logic bit by bit with masks (AND clears, OR sets to 1, XOR complements) and shifts (sl towards the MSB doubles, sr towards the LSB halves).Microoperations and RTL →, Shift Registers and CountersA shift register is a chain of D flip-flops, each output feeding the next input, so bits move one position per clock edge; it has serial input and output, optional parallel load (Shift has priority over Load) and a bidirectional version with a 4-to-1 MUX per stage (S1S0: 00 hold, 01 shift left, 10 shift right, 11 load). Uses: serial/parallel conversion, serial interfaces, delay lines, pseudo-random generators. Counters step through a sequence of states: the ripple (asynchronous) counter clocks each flip-flop with the previous output and accumulates delay, the synchronous counter uses one clock for all flip-flops and is faster, with EN and CO for cascading.Shift Registers and Counters →.
Quiz 14
A non-programmable digital system is divided into a datapath and a control unit. The control unit:
- a. fetches instructions from a memory using a program counter
- b. is a purely combinational network with no state
- c. determines the microoperations only from its own inputs and from the status signals of the datapath
Show the result
c.
Show the full solution
In a non-programmable system the control unit executes no instructions: it is a state machine with fixed logic that, from the input signals and the status signals coming from the datapath (for instance a counter reaching zero), produces the control signals that trigger the microoperations. Choice a describes the control unit of a programmable system such as a CPU. Choice b is false: it needs states (for instance ready, acc, init) to remember the phase of the operation. Theory: Datapath and Control UnitA register cell is a flip-flop with logic for microoperations, shared across the n cells of a register. In a programmable system (CPU) the control unit executes instructions fetched from memory using a program counter; in a non-programmable system the control unit decides the microoperations only from inputs and datapath status signals. Complete example: summing five values with start, res and busy; the datapath has ACC_REG, OUT_REG and CNT_REG (decrementer, MUX, status signal zero); microoperations are combinations of control signals; the control unit is a 3-state Mealy machine (ready, acc, init).Datapath and Control Unit →, Registers and Load ControlAn n-bit register is n flip-flops with a common clock, and a counter is a register that steps through a sequence of states. Loading can be controlled by clock gating (an OR with the clock, which saves power but adds delays and clock skew) or, preferably, by load enable (a 2-to-1 MUX before each D input selecting the new data or the flip-flop's own output). Complex systems are split into a datapath (registers and arithmetic-logic blocks) and a control unit (an FSM that sends control signals and receives status signals).Registers and Load Control →.
Quiz 15
A register implements the logic microoperations , and , enabled by the control signals , and (at most one is ; if all are the register holds). With and the other two signals at , the input of the flip-flop of bit is:
- a.
- b.
- c.
Show the result
a.
Show the full solution
The equation of the register cell is with , , , where is the hold condition. With , and : , , , so . Choice c is the case and choice b the case . Theory: Datapath and Control UnitA register cell is a flip-flop with logic for microoperations, shared across the n cells of a register. In a programmable system (CPU) the control unit executes instructions fetched from memory using a program counter; in a non-programmable system the control unit decides the microoperations only from inputs and datapath status signals. Complete example: summing five values with start, res and busy; the datapath has ACC_REG, OUT_REG and CNT_REG (decrementer, MUX, status signal zero); microoperations are combinations of control signals; the control unit is a 3-state Mealy machine (ready, acc, init).Datapath and Control Unit →.
Quiz 16
In the system that sums five values (control unit with states ready, acc, init; the counter is initialised to ), the signal start is asserted for one clock cycle while the system is in ready. For how many clock cycles, counting the cycle in which start is , is busy equal to ?
- a.
- b.
- c.
Show the result
b.
Show the full solution
busy is in the cycle with start=1 (state ready, first value accumulated, counter ): cycle. Then the machine is in acc with the counter at (four more values accumulated) and finally at , when zero=1 and the sum is copied to the output: cycles in acc. Last, init clears the accumulator and reloads the counter: cycle. Total cycles; then the machine is back in ready and busy=0. Choice a counts only the acc cycles. Theory: Datapath and Control UnitA register cell is a flip-flop with logic for microoperations, shared across the n cells of a register. In a programmable system (CPU) the control unit executes instructions fetched from memory using a program counter; in a non-programmable system the control unit decides the microoperations only from inputs and datapath status signals. Complete example: summing five values with start, res and busy; the datapath has ACC_REG, OUT_REG and CNT_REG (decrementer, MUX, status signal zero); microoperations are combinations of control signals; the control unit is a 3-state Mealy machine (ready, acc, init).Datapath and Control Unit →.
Quiz 17
In an instruction BRZ (branch if the tested register is zero) located at address , the 6-bit offset field is , interpreted in two's complement, and the target address is with the address of the instruction. If the register is zero, the next instruction is at address:
- a.
- b.
- c.
Show the result
a.
Show the full solution
The 6-bit offset has the sign bit equal to : it is negative. In two's complement . The target is (branch backwards). Choice b reads the offset as unsigned (); choice c uses , the magnitude without the sign. If the register were not zero the next address would be . Theory: Machine Instructions, Addressing Modes, RISC and CISCA machine instruction is a fixed-width word split into an opcode and operand fields; in a load/store architecture only load and store reach memory, and operands are given by a few addressing modes (register, register indirect, immediate, PC-relative). RISC machines use simple fixed-length instructions that fit one pass through the pipeline, 32 registers with R0 equal to 0 and four addressing modes; CISC machines have complex variable-length instructions, many addressing modes and a microprogrammed control (a ROM-based state machine) taking several cycles.Machine Instructions, Addressing Modes, RISC and CISC →, Simple Computer - Instruction Set, Single-Cycle and Multi-Cycle ControlThe 16-bit instruction word has an opcode of 7 bits plus register fields (DR, SA, SB or an immediate OP) or a branch format with a 6-bit PC-relative signed offset; the instruction set is load/store with ADD, SUB, logic, shifts, LDI, ADI, LD, ST, BRZ, BRN and JMP. In the single-cycle computer (separate instruction and data memories) a combinational instruction decoder derives MB, MD, RW, MW, PL, JB, BC from bits 15, 14, 13 and 9 and FS from bits 12 to 9, and the clock period is the sum of the delays on the critical path (9.8 ns in the example). In the multi-cycle computer (one memory) an instruction register, internal registers R8 to R15 and a sequential decoder are needed: fetch (INF) plus one or more execution states.Simple Computer - Instruction Set, Single-Cycle and Multi-Cycle Control →.
Quiz 18
A load/store processor executes LD R3,(R5) with register-indirect addressing. The register contains , the memory location at address contains and the memory location at address contains . After the instruction contains:
- a.
- b.
- c.
Show the result
c.
Show the full solution
In register-indirect addressing the register holds the address of the operand: . Choice a is the content of the address register itself (it would be a register move); choice b is , the double indirect load, a CISC-style mode that takes two memory accesses and is not available here. Theory: Machine Instructions, Addressing Modes, RISC and CISCA machine instruction is a fixed-width word split into an opcode and operand fields; in a load/store architecture only load and store reach memory, and operands are given by a few addressing modes (register, register indirect, immediate, PC-relative). RISC machines use simple fixed-length instructions that fit one pass through the pipeline, 32 registers with R0 equal to 0 and four addressing modes; CISC machines have complex variable-length instructions, many addressing modes and a microprogrammed control (a ROM-based state machine) taking several cycles.Machine Instructions, Addressing Modes, RISC and CISC →.
Quiz 19
A system has -bit virtual addresses and KB pages, so the page number is made of the high bits and the offset of the low bits. The page table maps virtual page to physical frame (valid). The virtual address 0x2A5C is translated into the physical address:
- a.
0x2A5C - b.
0x9A5C - c.
0xA25C
Show the result
b.
Show the full solution
0x2A5C splits into page number and offset 0xA5C. The translation replaces the page number with the frame number () and leaves the offset unchanged: 0x9A5C. Choice a would be the address without translation; choice c swaps digits. Typical mistake: translating the offset as well. Theory: Virtual Memory and PagingVirtual memory shows every program the whole size of main memory plus disk, with the same addresses usable by all programs without interference; dedicated hardware translates virtual to physical addresses page by page using a page table whose rows carry valid, dirty and used bits. The offset is unchanged by the translation. The TLB caches recent translations to avoid extra memory accesses, and a page fault (valid bit 0) means the page must be fetched from disk.Virtual Memory and Paging →.
Quiz 20
In a virtual memory system a page that is a candidate for replacement has valid bit and dirty bit . This means that:
- a. it must be written back to the disk before its frame is reused
- b. it can be overwritten immediately, because the disk already holds an identical copy
- c. a page fault has occurred
Show the result
a.
Show the full solution
The dirty bit is set when at least one write occurred in the page since it was loaded: the copy in main memory is more recent than the one on the disk, which would be lost if the frame were reused. The operating system must therefore save the page to the disk first. With dirty bit the page could be discarded (choice b). A page fault (choice c) happens when the valid bit is , i.e. the requested page is not in memory and must be fetched from the disk. Theory: Virtual Memory and PagingVirtual memory shows every program the whole size of main memory plus disk, with the same addresses usable by all programs without interference; dedicated hardware translates virtual to physical addresses page by page using a page table whose rows carry valid, dirty and used bits. The offset is unchanged by the translation. The TLB caches recent translations to avoid extra memory accesses, and a page fault (valid bit 0) means the page must be fetched from disk.Virtual Memory and Paging →, Memory Hierarchy and Cache MemoryMemories form a hierarchy (small fast SRAM, larger slower DRAM, huge slow disks) which works because programs reuse data close in time and in space (locality). A cache hit or miss gives an average access time t_hit plus miss rate times miss penalty; placement can be direct mapped (index = low address bits, tag = high bits), fully associative (tag = whole address, compared in parallel by an associative memory) or k-way set associative (a block can sit in k locations of one set).Memory Hierarchy and Cache Memory →.
Exercise 1 (points 10)
A circuit receives a decimal digit in BCD on the variables ( most significant bit, least significant bit; the combinations to never occur) and drives the top-left segment of a seven-segment display. The segments are named as in the figure: top, top right, bottom right, bottom, bottom left, top left, middle. The digits are drawn as follows: , , , , , , , , , . The output must be when segment has to be lit and otherwise.
- Write the truth table of and the Karnaugh map, marking the don't-care conditions.
- Find the minimal product-of-sums (POS) expression of , showing the groups of zeros used on the map, and say which groups are essential.
- Find the minimal sum-of-products (SOP) expression and compare the two forms (number of terms and of literals). What would the POS be if the don't-care conditions were not used?
- Draw the circuit that implements the POS with NOR gates only (inverters allowed for the complemented inputs) and count gates, gate inputs and CMOS transistors. Compare with the NAND-NAND realisation of the SOP.
- What do the POS and the SOP circuits output for the unused input combinations to ? Does it matter?
Show the result
- for the digits ; for ; don't care for to .
- , three essential groups of zeros: , , . Without don't cares: .
- ( products, literals); the POS has sums and literals.
- : two 2-input NORs, one 3-input NOR, one 3-input NOR at the output, two inverters: gates, gate inputs plus inverters, transistors. The NAND-NAND of the SOP uses inverters, three 2-input NANDs and one 4-input NAND: transistors.
- POS circuit on : ; SOP circuit: . They differ on , which does not matter because those inputs never occur.
Show the full solution
Point 1: truth table and map. For every digit one looks at whether the drawing contains segment (top-left): it is lit in and off in (the is drawn with three segments only, as stated). The rows to are not BCD digits and become don't care (Binary Codes - BCD, ASCII, Unicode, Parity and GrayAn n-bit code distinguishes 2^n elements. BCD encodes each decimal digit on 4 bits (1010 to 1111 unused; it differs from the plain binary of the number). ASCII uses 7 bits for 128 characters; Unicode UTF-8 uses 1 to 4 bytes and is ASCII compatible. A parity bit detects errors on an odd number of bits. Hamming distance is the number of differing bits. Gray code makes consecutive numbers differ by one bit and is built by reflection or with g_i = b_i xor b_(i+1).Binary Codes - BCD, ASCII, Unicode, Parity and Gray →).
| digit | digit | ||||
|---|---|---|---|---|---|
| 0 | 0000 | 1 | 8 | 1000 | 1 |
| 1 | 0001 | 0 | 9 | 1001 | 1 |
| 2 | 0010 | 0 | 10 | 1010 | X |
| 3 | 0011 | 0 | 11 | 1011 | X |
| 4 | 0100 | 1 | 12 | 1100 | X |
| 5 | 0101 | 1 | 13 | 1101 | X |
| 6 | 0110 | 1 | 14 | 1110 | X |
| 7 | 0111 | 0 | 15 | 1111 | X |
Karnaugh map (rows , columns in Gray order; the cell index is the digit):
| 00 | 01 | 11 | 10 | |
|---|---|---|---|---|
| 00 | 1 (0) | 0 (1) | 0 (3) | 0 (2) |
| 01 | 1 (4) | 1 (5) | 0 (7) | 1 (6) |
| 11 | X (12) | X (13) | X (15) | X (14) |
| 10 | 1 (8) | 1 (9) | X (11) | X (10) |
Point 2: minimal POS. For a POS one groups the zeros (the cells ), using the don't cares as zeros where this enlarges the groups, and then complements each group with De Morgan (Karnaugh Maps and Two-Level MinimizationA Karnaugh map is the truth table arranged in a grid with rows and columns in Gray code, so that adjacent cells (also across opposite edges) differ in one variable. Groups of 2^k ones eliminate k variables and give a product. A prime implicant is a maximal group, an essential one is the only cover of some minterm; the minimum cover has all essentials plus few other primes. For POS, group the zeros. Don't cares may be used as 1 or 0. XOR functions have a checkerboard map and do not simplify.Karnaugh Maps and Two-Level Minimization →, Canonical Forms - Minterms, Maxterms, SOP and POSA minterm is a product containing every variable exactly once and is 1 on a single truth-table row; a maxterm is the dual sum and is 0 on a single row; with n variables there are 2^n of each and the complement of minterm i is maxterm i. Canonical SOP = sum of minterms of rows with F=1; canonical POS = product of maxterms of rows with F=0. They come mechanically from the truth table but are redundant, so they are the starting point for minimization. SOP and POS are two-level circuits.Canonical Forms - Minterms, Maxterms, SOP and POS →). Groups of zeros:
- : varies, , ; the product for is , the sum is . It is essential: it is the only large group that contains cell .
- (the column ): , the sum is . Essential: it is the only large group containing cell .
- : , the sum is . Essential: cell has no larger group (its neighbours , , are ones, which cannot be in a group of zeros).
In a sum, a variable is direct if it is in the group and negated if it is (reversed with respect to the SOP). Therefore Check: the digit gives ; the digit gives because ; the digit gives . A script enumerated the sixteen inputs and confirmed that the formula is correct on all valid digits. If the don't cares were not used (the rows to taken as ), those six cells would become zeros that must be covered: the group (, sum ) is needed in addition, while the other three groups stay the same ( and are now made of true zeros). The minimal POS (confirmed with sympy) is with sums and literals: using the don't cares saves one sum and two literals. Typical mistake: forgetting to use the don't cares, or making a group only of don't cares.
Point 3: minimal SOP and comparison. Grouping the ones and the don't cares: (the whole lower half ), (cells ), (cells ), (cells ). All four are essential (cell only by , cell only by , cell only by , cell only by ): SOP: products and literals; POS: sums and literals. Same literals, but the POS has one term less. Gate-input cost: POS (three OR gates and one AND), SOP (three AND gates and one OR; enters directly): equal.
Point 4: NOR-NOR. A POS maps directly on NOR-NOR (Combinational Design - Hierarchy and NAND-NOR MappingA combinational circuit has outputs depending only on the present inputs (no memory, no feedback); a sequential one also depends on history (state, memory, feedback). Design flow: specification, truth table, minimum-cost function, logic diagram, verification. With many inputs the hierarchical approach splits the system into reusable blocks (regularity). Basic blocks: one-variable functions, vectors, enabling. Technology mapping in CMOS: SOP to NAND-NAND, POS to NOR-NOR.Combinational Design - Hierarchy and NAND-NOR Mapping →): with each produced by a NOR. Here Gates: , , , final , plus two inverters for and (shared by the sums). Six gates, gate inputs and two inverters. Transistors (a gate with inputs has transistors, CMOS Gates and Technology ParametersIn CMOS integrated circuits MOSFETs are modelled as switches: nMOS closed when the gate is 1, pMOS closed when the gate is 0. A static gate has a pull-up network (only pMOS, to Vdd) and a dual pull-down network (only nMOS, to ground): one is ON and the other OFF. NAND has series nMOS and parallel pMOS, NOR the opposite; an n-input gate has 2n transistors. Real-gate parameters: fan-in, fan-out, noise margin, propagation delay, power dissipation and cost.CMOS Gates and Technology Parameters →): . The SOP on NAND-NAND is : three 2-input NANDs ( transistors), one 4-input NAND (), and three inverters for , , (): transistors. The NOR-NOR form is slightly cheaper (one inverter less); both have fan-in at most . A script checked on all inputs that the two circuits equal the POS and the SOP, respectively.
Point 5: unused combinations. Evaluating the POS on (): and have , so and ; and give ; has , so . The result is . The SOP contains and gives on all six. The two circuits are not equal as Boolean functions but they are equal on the valid inputs, which is all that is required: the don't cares were exactly the freedom to choose these values. Typical mistake: claiming that the two minimal forms must coincide.
Exercise 2 (points 10)
A synchronous counter is made of three positive-edge-triggered D flip-flops with outputs ( most significant bit; the state number is the value of in binary). It has an input and an output . When , at each rising edge of the clock the counter goes through the cyclic sequence of states and when it holds its state. The output is only when the counter is in state (Moore output). A reset brings the counter to state .
- Write the state table for and identify the unused states. How many flip-flops are needed?
- Find the minimal expressions of the next-state functions (for ) with Karnaugh maps, using the unused states as don't cares, and the expression of .
- Include the enable and write the equations of .
- Check that the counter is self-starting: what happens if, after power-up, it is in one of the unused states?
- Starting from state , find the sequence of states and of for (one value per clock cycle).
- With and a clock at MHz, what are frequency and duty cycle of ?
Show the result
- Five states: ; unused states , , ; three flip-flops.
- , , , .
- for (a 2-to-1 multiplexer with select in front of each flip-flop).
- Yes: , , ; no loops among unused states; a valid state is reached in at most clock cycles.
- Present states: ; (the next state after the last cycle is ).
- MHz, duty cycle .
Show the full solution
Point 1: state table. Five states need flip-flops (Finite State Machines - SynthesisSynthesis of a synchronous sequential circuit follows specifications, state diagram, state table (merging equivalent states), binary state encoding, choice of D flip-flop, flip-flop input and output equations, minimisation, circuit and verification. A state summarises the useful part of history; a sequence recogniser has one state per recognised prefix, reusing states for overlaps. A reset gives a known initial state. Gray encoding (minimum flip-flops) versus one-hot (one flip-flop per state, simpler logic): for the 1101 recogniser Gray costs about half.Finite State Machines - Synthesis →); the encoding is given by the state number. With three bits there are combinations: are unused. For :
| present state | next state | |||
|---|---|---|---|---|
| 0 | 000 | 2 | 010 | 0 |
| 2 | 010 | 3 | 011 | 0 |
| 3 | 011 | 5 | 101 | 0 |
| 5 | 101 | 6 | 110 | 0 |
| 6 | 110 | 0 | 000 | 1 |
| 1 | 001 | unused | X | X |
| 4 | 100 | unused | X | X |
| 7 | 111 | unused | X | X |
Since the counter must hold when , the design is split: first the next state for ( variables, easy maps), then the enable (Registers and Load ControlAn n-bit register is n flip-flops with a common clock, and a counter is a register that steps through a sequence of states. Loading can be controlled by clock gating (an OR with the clock, which saves power but adds delays and clock skew) or, preferably, by load enable (a 2-to-1 MUX before each D input selecting the new data or the flip-flop's own output). Complex systems are split into a datapath (registers and arithmetic-logic blocks) and a control unit (an FSM that sends control signals and receives status signals).Registers and Load Control →).
Point 2: Karnaugh maps. The next state of a D flip-flop is its input (Finite State Machines - SynthesisSynthesis of a synchronous sequential circuit follows specifications, state diagram, state table (merging equivalent states), binary state encoding, choice of D flip-flop, flip-flop input and output equations, minimisation, circuit and verification. A state summarises the useful part of history; a sequence recogniser has one state per recognised prefix, reusing states for overlaps. A reset gives a known initial state. Gray encoding (minimum flip-flops) versus one-hot (one flip-flop per state, simpler logic): for the 1101 recogniser Gray costs about half.Finite State Machines - Synthesis →). Maps with rows and columns in Gray order (the number in brackets is the state):
(ones in states and ):
| 00 | 01 | 11 | 10 | |
|---|---|---|---|---|
| 0 | 0 (0) | X (1) | 1 (3) | 0 (2) |
| 1 | X (4) | 1 (5) | X (7) | 0 (6) |
The column (: two ones and two don't cares) gives .
(ones in ):
| 00 | 01 | 11 | 10 | |
|---|---|---|---|---|
| 0 | 1 (0) | X (1) | 0 (3) | 1 (2) |
| 1 | X (4) | 1 (5) | X (7) | 0 (6) |
Groups: (the don't cares are used as ones): ; : . So .
(ones in ):
| 00 | 01 | 11 | 10 | |
|---|---|---|---|---|
| 0 | 0 (0) | X (1) | 1 (3) | 1 (2) |
| 1 | X (4) | 0 (5) | X (7) | 0 (6) |
One group : . (The cell cannot be used: the group would contain the zero in cell .)
Output: in state and don't care in (unused): the group gives (also would be minimal, using the unused state instead of ). The equations were checked by a script: for they reproduce the cycle . Typical mistakes: treating the unused states as zeros (more complex equations), or using the don't cares in a group made only of don't cares.
Point 3: enable. With the load enable technique the register input is chosen by a 2-to-1 multiplexer: loads the new state, feeds back the flip-flop output (Registers and Load ControlAn n-bit register is n flip-flops with a common clock, and a counter is a register that steps through a sequence of states. Loading can be controlled by clock gating (an OR with the clock, which saves power but adds delays and clock skew) or, preferably, by load enable (a 2-to-1 MUX before each D input selecting the new data or the flip-flop's own output). Complex systems are split into a datapath (registers and arithmetic-logic blocks) and a control unit (an FSM that sends control signals and receives status signals).Registers and Load Control →): that is , , . With every state, valid or unused, is held. (Clock gating on would be a worse alternative, because of the clock skew.)
Point 4: self-start. At power-up the flip-flops can be in any of the combinations; if the equations send an unused state into a loop of unused states the counter is stuck. Evaluating the equations ():
- (): , , , so the next state is (state , valid);
- : , , , next state (state , valid);
- : , , , next state (unused), then . No unused state leads to another loop: after at most two clock edges the counter is in the valid cycle (). This is the point of the check: with a different use of the don't cares the result could be a lock-up and a reset would be needed. Note that in state the output is once, a harmless glitch after an abnormal start.
Point 5: sequence. The output is Moore: it is read in the present state. For each cycle (present state, , next state):
| cycle | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| present state | 000 | 010 | 011 | 011 | 101 | 110 | 000 | 000 | 010 | 011 | 101 |
| 1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | |
| next state | 010 | 011 | 011 | 101 | 110 | 000 | 000 | 010 | 011 | 101 | 110 |
| 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
The cycles with (3 and 7) do not advance the count. The counter has returned to state after five advances (cycles 1, 2, 4, 5, 6): modulo .
Point 6: frequency of . With the sequence has period clock cycles and in one of them: MHz and duty cycle . The circuit is a divider by with a narrow output pulse (Shift Registers and CountersA shift register is a chain of D flip-flops, each output feeding the next input, so bits move one position per clock edge; it has serial input and output, optional parallel load (Shift has priority over Load) and a bidirectional version with a 4-to-1 MUX per stage (S1S0: 00 hold, 01 shift left, 10 shift right, 11 load). Uses: serial/parallel conversion, serial interfaces, delay lines, pseudo-random generators. Counters step through a sequence of states: the ripple (asynchronous) counter clocks each flip-flop with the previous output and accumulates delay, the synchronous counter uses one clock for all flip-flops and is faster, with EN and CO for cascading.Shift Registers and Counters →). Typical mistake: dividing by , the number of combinations of three bits, instead of the number of states in the sequence.
Exercise 3 (points 10)
Describe in VHDL the counter of Exercise 2: inputs clk, rst, en, outputs q (3 bits, the state ) and z. With en='1' the state goes through at each rising edge of clk, with en='0' it holds; z is '1' only in state . The reset rst is asynchronous, active high, and brings the state to . Separate the memory element from the combinational parts in the code.
- Write the VHDL code (entity and architecture).
- Write a test bench that makes the counter go through all the states, tests the hold with
en='0'and the asynchronous reset. - Report the expected states and output at the rising edges of the test bench.
- The circuit of Exercise 2 is built with these delays (ns): flip-flop maximum and minimum, , ; inverter ; AND2 ; OR2 ; NAND2 ; multiplexer 2-to-1: data output , select output (maximum/minimum). The next-state logic is: (wire), (an OR2 followed by a NAND2), (an inverter and an AND2); a multiplexer in front of every flip-flop implements the enable;
encomes from a flip-flop of the same clock. Find the critical path, the minimum clock period and the maximum frequency, check the hold constraint and say whether the circuit works at MHz.
Show the result
- Three processes: state register with asynchronous reset (
state <= "000"whenrst='1',state <= next_stateon the rising edge), next-state process withcaseandif en='0', outputz <= '1' when state = "110". - A test bench with a clock process and an input process: reset,
en='1'for cycles,en='0'for cycles,en='1'for cycles, then a reset pulse in the middle of a clock phase. - States after the rising edges at ns: (with after ns); hold at at and ns; at ns, at ns; the reset pulse at ns brings the state to immediately (no edge).
- Critical path or OR2 NAND2 MUX data: ns; ns; MHz. Hold: , slack ns. At MHz ( ns) the setup is violated by ns: no.
Show the full solution
Point 1: code. The three-process scheme of an FSM (VHDL - Finite State Machines and Sequential TestbenchesA finite state machine is described in behavioral VHDL with an enumerated type for the states and three processes: the state register (reset and state <= next_state on the clock edge), the next state as a combinational function of state and input (case state, with default next_state <= state), and the output as a combinational function of the state alone (Moore) or of state and input (Mealy). The testbench has a clock process and an input process (initial reset, then a test sequence that visits all states).VHDL - Finite State Machines and Sequential Testbenches →): process 1 is the state register, with the asynchronous reset tested first and rst in the sensitivity list (VHDL - Latches, Flip-Flops and ResetsIn VHDL a memory element is a process in which some branch does not assign the signal: the D latch is process(D,C) with if C='1' then Q<=D, the positive-edge-triggered flip-flop is process(CLK) with if CLK'event and CLK='1'. Asynchronous reset: RST is in the sensitivity list and tested first (if RST='1' ... elsif clock edge); synchronous reset: only CLK in the list and RST tested inside the clock-edge branch, so a clock edge is needed for it to act. The testbench of a synchronous circuit has a process generating the clock and one applying inputs away from the active edge.VHDL - Latches, Flip-Flops and Resets →); process 2 computes the next state combinationally from state and en; the output is a concurrent assignment (VHDL - Concurrent Statements, Processes and TestbenchesConcurrent VHDL statements are the plain signal assignment, when-else (priority logic, conditions evaluated in order) and with-select (parallel logic, every case covered once, others required). A process is a concurrent statement with a sequential body (if, case, loop) that wakes up when a signal in its sensitivity list changes; for combinational logic the list holds all inputs; signals are updated when the process suspends and the last assignment wins. An if without else or an uncovered case creates unwanted memory. A testbench has an empty entity, the instantiated DUT and a stimulus process with wait statements.VHDL - Concurrent Statements, Processes and Testbenches →).
library IEEE;
use IEEE.std_logic_1164.all;
entity cnt5 is
port ( clk, rst, en : in std_logic;
q : out std_logic_vector(2 downto 0);
z : out std_logic );
end cnt5;
architecture beh of cnt5 is
signal state, next_state : std_logic_vector(2 downto 0);
begin
-- process 1: state register (3 D flip-flops), asynchronous reset active high
reg : process (clk, rst)
begin
if rst = '1' then
state <= "000";
elsif clk'event and clk = '1' then
state <= next_state;
end if;
end process;
-- process 2: next state, purely combinational; every branch assigns next_state
nxt : process (state, en)
begin
if en = '0' then
next_state <= state; -- hold
else
case state is
when "000" => next_state <= "010";
when "010" => next_state <= "011";
when "011" => next_state <= "101";
when "101" => next_state <= "110";
when "110" => next_state <= "000";
when others => next_state <= "000"; -- unused states: restart
end case;
end if;
end process;
-- outputs: Moore, they depend only on the state
q <= state;
z <= '1' when state = "110" else '0';
end beh;Remarks. (i) en is in the list of the process nxt, together with state: if en were missing the simulation would ignore its changes. (ii) Every branch assigns next_state ( and the else of the if), so no latch is inferred. (iii) The when others branch is required because std_logic_vector has many more values than the used; here the unused states restart from , a choice stronger than the one obtained from the minimised equations of Exercise 2 (where goes first to ): both are self-starting and equal on the valid sequence. (iv) In the VHDL is exactly state = "110", whereas the minimised circuit has which is also in the unused state : again a difference only outside the valid cycle. The code could not be compiled in the preparation of this mock and was checked by hand against the transition table of Exercise 2 and by a program that simulates the same table.
Point 2: test bench. A clock process and an input process, with the inputs changed on the falling edge, away from the active edge (VHDL - Finite State Machines and Sequential TestbenchesA finite state machine is described in behavioral VHDL with an enumerated type for the states and three processes: the state register (reset and state <= next_state on the clock edge), the next state as a combinational function of state and input (case state, with default next_state <= state), and the output as a combinational function of the state alone (Moore) or of state and input (Mealy). The testbench has a clock process and an input process (initial reset, then a test sequence that visits all states).VHDL - Finite State Machines and Sequential Testbenches →, Timing of Sequential Systems - Setup, Hold and Maximum Clock FrequencyA flip-flop stores the right value only if its input is stable for the setup time before and the hold time after the clock edge, and its output changes after the propagation delay. In a synchronous circuit the clock period must satisfy T >= t_pd,FF + t_COMB + t_s,FF + t_slack, which fixes the maximum frequency; slowing the clock cures setup violations but not hold violations, which require t_pd,FF,min + t_COMB,min >= t_h. Clock skew modifies both constraints.Timing of Sequential Systems - Setup, Hold and Maximum Clock Frequency →). The clock starts at : rising edges at ns, falling edges at ns.
library IEEE;
use IEEE.std_logic_1164.all;
entity tb_cnt5 is
end tb_cnt5;
architecture test of tb_cnt5 is
signal clk, rst, en, z : std_logic;
signal q : std_logic_vector(2 downto 0);
constant PERIOD : time := 20 ns;
begin
dut : entity work.cnt5(beh) port map (clk, rst, en, q, z);
gen_clock : process
begin
clk <= '0'; wait for PERIOD/2;
clk <= '1'; wait for PERIOD/2;
end process;
apply_inputs : process
begin
rst <= '1'; en <= '0';
wait for 2*PERIOD; -- reset until 40 ns (falling edge)
rst <= '0'; en <= '1';
wait for 7*PERIOD; -- 7 rising edges with en = 1: 50 ... 170 ns
en <= '0'; -- at 180 ns: hold for the edges at 190 and 210 ns
wait for 2*PERIOD;
en <= '1'; -- at 220 ns: two more steps (230, 250 ns)
wait for 2*PERIOD;
wait for PERIOD/4; -- 265 ns: clock low, no edge
rst <= '1'; -- asynchronous reset: the state must change at once
wait for 3*PERIOD/4;
rst <= '0'; -- at 280 ns (falling edge): counting restarts at 290 ns
wait for 3*PERIOD;
std.env.stop;
end process;
end test;The sequence passes through all five states and through the five arcs with en='1'; the hold () is shown in state only; the unused states cannot be reached from the test bench, because the state is internal.
Point 3: expected result. The state is shown after each rising edge (Moore: z changes together with the state):
| time (ns) | rst |
en |
state after the edge | z |
what is tested |
|---|---|---|---|---|---|
| 10, 30 | 1 | 0 | 000 | 0 | reset |
| 50 | 0 | 1 | 010 | 0 | arc |
| 70 | 0 | 1 | 011 | 0 | arc |
| 90 | 0 | 1 | 101 | 0 | arc |
| 110 | 0 | 1 | 110 | 1 | arc , |
| 130 | 0 | 1 | 000 | 0 | arc |
| 150, 170 | 0 | 1 | 010, 011 | 0 | second round |
| 190, 210 | 0 | 0 | 011, 011 | 0 | hold |
| 230, 250 | 0 | 1 | 101, 110 | 0, 1 | counting resumes |
| 265 (no edge) | 1 | 1 | 000 | 0 | asynchronous reset |
| 270 | 1 | 1 | 000 | 0 | reset has priority over the clock |
| 290, 310, 330 | 0 | 1 | 010, 011, 101 | 0 | restart after reset |
The key observation is the line at ns: the state and z return to before any clock edge, which would not happen with a synchronous reset (the state would change only at ns). A script that simulates the transition table with these stimuli reproduced this table. Typical mistakes: changing the inputs on the rising edge (a race with the clock), forgetting the initial reset (the state is undefined 'U' and never recovers), never testing en='0'.
Point 4: timing analysis. The constraint is with the maximum delays (Timing of Sequential Systems - Setup, Hold and Maximum Clock FrequencyA flip-flop stores the right value only if its input is stable for the setup time before and the hold time after the clock edge, and its output changes after the propagation delay. In a synchronous circuit the clock period must satisfy T >= t_pd,FF + t_COMB + t_s,FF + t_slack, which fixes the maximum frequency; slowing the clock cures setup violations but not hold violations, which require t_pd,FF,min + t_COMB,min >= t_h. Clock skew modifies both constraints.Timing of Sequential Systems - Setup, Hold and Maximum Clock Frequency →). Delays of the paths from a flip-flop output to a flip-flop input (everything ends in the data input of a multiplexer, ns):
- : wire and multiplexer, ns; hold path multiplexer: ns;
- NAND2 MUX : ns;
- or OR2 NAND2 MUX : ns;
- AND2 MUX : ns; inverter AND2 MUX : ns;
- select of the MUX: ns.
The critical path is the one through the OR2 and the NAND2: ns, so (Check of the logic: .)
Hold. With the minimum delays the shortest path is a flip-flop output straight into a multiplexer data input ( ns); the select path takes ns and all the others more. : the constraint is satisfied with a slack of ns. Hold does not depend on the clock frequency.
MHz. ns ns: the setup is violated by ns (slack ns) and the circuit does not work. It can be cured by lowering the frequency (at MHz, ns, the slack is ns; any frequency up to MHz works) or by shortening the critical path (for instance with a faster gate for ). Typical mistakes: taking the select path of the multiplexer as the critical one only because the select delay is larger than the data delay; forgetting and ; using the minimum delays for the setup check or the maximum delays for the hold check.
Self-assessment grid
| exercise | points | what must be there for full points | typical mistakes |
|---|---|---|---|
| Quiz 1-20 | 20 | one answer per question; each wrong answer costs , so leave blank when really unsure | Gray conversion in the wrong direction, parity "correcting" errors, instead of , offset of the branch read as unsigned, offset translated in the page address |
| Ex. 1, points 1-2 | 5 | truth table and map with don't cares; three groups of zeros; with correct signs | wrong sign of the literals in the sums, don't cares ignored, groups not maximal |
| Ex. 1, point 3 | 1.5 | minimal SOP with four products; comparison in terms of terms and literals; POS without don't cares has 4 sums | SOP from zeros, wrong count of literals |
| Ex. 1, points 4-5 | 3.5 | NOR-NOR circuit with inverters, gate and transistor count ( per gate); outputs on the unused inputs | NAND instead of NOR for a POS, forgetting inverters, saying the circuits must coincide on all inputs |
| Ex. 2, points 1-3 | 5 | state table with three unused states; and minimal; with the enable | unused states as zeros, enable put on the clock, without the hold |
| Ex. 2, points 4-6 | 5 | self-start check for , , ; sequence of states and read in the present state; MHz and | not checking the unused states, reading in the next state, dividing by |
| Ex. 3, points 1-2 | 4 | three-process VHDL, reset asynchronous and first in the process, en in the list, no latch; test bench with clock, reset, hold and asynchronous reset |
rst inside the edge branch, missing else or when others, inputs on the rising edge |
| Ex. 3, point 3 | 2 | table of states and z at each rising edge; reset visible at ns with no edge |
not noticing that the asynchronous reset acts before the edge |
| Ex. 3, point 4 | 4 | critical path ns, ns, MHz; hold slack ns; MHz fails by ns with the remedies | missing or , minimum delays in the setup check, "lower the frequency" proposed for a hold violation |