Salta al contenuto
Note per Studenti Microoperations and RTL Report

Microoperations and RTL

A microoperation is an elementary operation performed on the data in a register: incrementing it, swapping the data of two registers, shifting its bits. The result may replace the value in the register itself or be transferred into another register, leaving the first unchanged. The language used to write them is the Register Transfer Language (RTL), similar to HDL statements but not identical to VHDL.

Notation. Registers have upper-case names, often with numbers (AR address register, PC program counter, R1, R2). Bits are indicated in parentheses after the name: R(7:0)R(7:0). Little endian puts bit index 00 (LSB) on the right, big endian on the left; a long register can be divided into most significant (H) and least significant (L) byte.

Types of microoperations

Definition (transfer). R2←R1R_2\leftarrow R_1: the content of R1R_1 (source) is copied into R2R_2 (destination); by definition only the destination changes. In the circuit the nn output bits of R1R_1 are connected to the inputs of R2R_2 and control signal K1K_1 drives the LoadLoad of R2R_2. A transfer is conditional if it occurs only when a control signal is 1: K1: R2←R1K_1:\ R_2\leftarrow R_1 (the condition precedes the colon). The clock does not appear in the statement: everything is assumed to happen on the active edge. Simultaneous transfers are separated by a comma: K3: R1←R2, R2←R1K_3:\ R_1\leftarrow R_2,\ R_2\leftarrow R_1 swaps the contents at the clock edge where K3=1K_3=1 (both read the old values).

Example. K1: R2←R1K_1:\ R_2\leftarrow R_1 with R1=0110R_1=0110, R2=1001R_2=1001: if K1=1K_1=1 at the clock edge, R2=0110R_2=0110 and R1R_1 stays 01100110.

Transfer from several sources. A destination register may receive data from several sources. As an if-then-else controlled by K1,K2K_1,K_2: K1: R0←R1,K1‾K2: R0←R2.K_1:\ R_0\leftarrow R_1,\qquad \overline{K_1}K_2:\ R_0\leftarrow R_2 . If K1=1K_1=1, R1R_1 goes to R0R_0 whatever K2K_2 is (priority to K1K_1); if K1=0K_1=0 and K2=1K_2=1, R2R_2 goes to R0R_0; if both are 0, R0R_0 holds. A multiplexer chooses the source register and Load=K1+K2Load=K_1+K_2 enables loading. With nn sources use an nn-to-1 MUX; if the controls are nn one-hot lines, an encoder turns them into the binary select code.

Formula (arithmetic microoperations). Addition (++), subtraction (−-), increment (+1+1), decrement (−1-1), complement. Multiplication and division are not elementary: they are sequences of basic microoperations. An adder-subtractor with control signals XX (0 add, 1 subtract) and K1K_1: X‾K1: R1←R1+R2,XK1: R1←R1+R2‾+1.\overline X K_1:\ R_1\leftarrow R_1+R_2,\qquad XK_1:\ R_1\leftarrow R_1+\overline{R_2}+1 .

Example. R1=0110R_1=0110, R2=0011R_2=0011, K1=1K_1=1: if X=0X=0, R1←0110+0011=1001R_1\leftarrow0110+0011=1001; if X=1X=1, R1←0110+1100+1=(1) 0011R_1\leftarrow0110+1100+1=(1)\,0011, i.e. 6−3=36-3=3 (two's complement subtraction).

Property (masks to clear, set and complement bits). Bitwise operations: each register bit is a binary variable (NOT, AND, OR, XOR). In RTL the symbol ++ may be arithmetic addition or logical OR: the context tells (inside a Boolean function it is OR). They are also used to modify some bits with a mask:

purpose operation mask
clear some bits AND 00 on the bits to clear, 11 elsewhere
set to 1 some bits OR 11 on the bits to set, 00 elsewhere
complement some bits XOR 11 on the bits to complement, 00 elsewhere

Example. R=1010 1101R=1010\,1101: AND with 0000 11110000\,1111 gives 0000 11010000\,1101; OR with 1111 00001111\,0000 gives 1111 11011111\,1101; XOR with 1111 00001111\,0000 gives 0101 11010101\,1101.

With R1=1010 1101  1010 1011R_1=1010\,1101\;1010\,1011: clear the first 8 bits with mask 0000 0000  1111 11110000\,0000\;1111\,1111 gives 0000 0000  1010 10110000\,0000\;1010\,1011; set them with OR and mask 1111 1111  0000 00001111\,1111\;0000\,0000 gives 1111 1111  1010 10111111\,1111\;1010\,1011; complement them with XOR and the same mask gives 0101 0010  1010 10110101\,0010\;1010\,1011.

Why it works: X⋅0=0X\cdot0=0 and X⋅1=XX\cdot1=X (AND); X+1=1X+1=1 and X+0=XX+0=X (OR); X⊕1=X‾X\oplus1=\overline X and X⊕0=XX\oplus0=X (XOR).

Definition (shift microoperations). They move the bits of a register sideways. Shift left (slsl): bits move towards the MSB; the bit leaving is the leftmost of the source, the bit entering is in the rightmost position of the destination. Shift right (srsr): bits move towards the LSB; the bit leaving is on the right, the one entering on the left. Here the entering bit is 00 and the leaving bit is discarded. R←sl RR\leftarrow sl\,R multiplies by 22 (if no overflow), R←sr RR\leftarrow sr\,R divides unsigned by 22.

Example. R=0011R=0011 (33): sl R=0110sl\,R=0110 (6=3⋅26=3\cdot2) and sr R=0001sr\,R=0001.

A microoperation may belong to several types: the one's complement is both logic and arithmetic. Registers that implement shifts are in 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 →; microoperations as control-signal combinations are in 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 →.

Versione ripasso

  • Microoperation: elementary operation on register data, written in RTL. Registers upper case (AR, PC, R1), bits R(7:0)R(7:0), little endian = LSB on the right.
  • Transfer: K1:R2←R1K_1:R_2\leftarrow R_1 changes only the destination; the clock is implicit; simultaneous transfers separated by commas, K3:R1←R2,R2←R1K_3:R_1\leftarrow R_2,R_2\leftarrow R_1 swaps (both read old values). Example: R1=0110R_1=0110, R2=1001R_2=1001, K1=1K_1=1 gives R2=0110R_2=0110.
  • Several sources: K1:R0←R1K_1:R_0\leftarrow R_1, K1‾K2:R0←R2\overline{K_1}K_2:R_0\leftarrow R_2; priority to K1K_1, hold if both 0; MUX plus Load=K1+K2Load=K_1+K_2; encoder for one-hot controls.
  • Arithmetic: X‾K1:R1←R1+R2\overline XK_1:R_1\leftarrow R_1+R_2, XK1:R1←R1+R2‾+1XK_1:R_1\leftarrow R_1+\overline{R_2}+1. With R1=0110R_1=0110, R2=0011R_2=0011: 10011001 or 33. Multiplication and division are sequences.
  • Masks: AND with 0 clears, OR with 1 sets, XOR with 1 complements. 1010 11011010\,1101 AND 0000 11110000\,1111 gives 0000 11010000\,1101; XOR 1111 00001111\,0000 gives 0101 11010101\,1101.
  • Shifts: slsl towards MSB (times 2), srsr towards LSB (divide by 2); entering bit 0, leaving bit lost. R=0011R=0011: sl R=0110sl\,R=0110, sr R=0001sr\,R=0001.
  • Mistakes: thinking R2←R1R_2\leftarrow R_1 changes R1R_1; swapping the masks; reading ++ always as addition (in Boolean functions it is OR); confusing slsl and srsr.

Teoria collegata