Loading lessons...
Register Transfer Language, Bus Transfers & Arithmetic Microoperations
Register Transfer Language, Bus Transfers & Arithmetic Microoperations
A digital computer is a collection of registers connected by data paths. What it does is the set of small operations it performs on the data in those registers. This lesson gives a precise notation for those operations, register transfer language (RTL), then shows how transfers are wired (bus and memory transfers) and how the arithmetic microoperations are built from adders and multiplexers.
1. Microoperations and RTL
A microoperation is an elementary operation performed on the data stored in registers during one clock pulse: shift, count, clear, load, add, and so on. An instruction like ADD is carried out as a sequence of microoperations (the T0, T1, ldots steps of the previous lesson).
The internal organisation of a digital system is defined by:
- the set of registers and their functions,
- the sequence of microoperations performed on the data in them, and
- the control that starts each sequence.
Register transfer language is the symbolic notation used to describe these microoperation transfers.
1.1 Notation
| Symbol | Meaning | Example |
|---|---|---|
| Capital letters (and numerals) | a register | MAR, R2, PC |
| Parentheses | part of a register | R2(0-7), PC(L) for the low byte |
| Arrow ← | transfer of information | R2 ← R1 |
| Comma , | two microoperations in the same clock | R2 ← R1, \ R1 ← R2 |
| Colon : | ends a control function | P: R2 ← R1 |
| Square brackets [ ] | a memory word at an address | DR ← M[AR] |
R2 ← R1 copies the contents of R1 into R2. R1 is unchanged (the transfer is a copy, not a move). It implies that a path exists from the outputs of R1 to the inputs of R2 and that R2 has a parallel-load capability.
1.2 Transfers under a control condition
Usually a transfer should happen only when a control condition holds:
means "if P = 1 then R2 ← R1". In hardware, P drives the LOAD input of R2, and the transfer happens on the clock edge at which P is 1.
P enables the load input of R2; the transfer happens at the clock edge after P becomes 1
P is generated by the control circuit just after one clock edge (time t) and stays 1 for one clock period. The load happens at the next edge (time t + 1), when R2 samples its inputs. This is why every register transfer in this course is written for a timing step and happens at the end of it.
Two transfers with a comma happen at the same edge. Since flip-flops sample their inputs before they change, the statement
exchanges R1 and R2 in one clock, with no temporary register.
Show the hardware statements for: if T1 = 1 then R1 ← R2, else if T2 = 1 then R1 ← R3.
- The first transfer needs only T1: T1: R1 ← R2.
- The second is done only when T1 = 0 and T2 = 1: T1' T2: R1 ← R3.
- Hardware: R1's input comes through a 2 × 1 MUX (select = T1: R2 when 1, R3 when 0); R1's LOAD = T1 + T1' T2 = T1 + T2.
2. Bus and Memory Transfers
Connecting every register to every other one with its own wires would need far too many paths. Instead registers share a common bus: a set of lines, one per bit, with control signals that pick which register drives the bus at a given time.
2.1 Bus built from multiplexers
For k registers of n bits each, the bus needs:
- n multiplexers (one per bit), each of size k × 1, and
- log2 k select lines shared by all the multiplexers.
Multiplexer i takes bit i of every register. The select lines choose one register; its n bits appear on the n bus lines. The basic computer's bus of lesson 25 is exactly this with k = 8, n = 16.
A transfer through the bus is written BUS ← C, \ R1 ← BUS, or simply R1 ← C when the bus is understood.
2.2 Bus built from three-state buffers
A three-state buffer has a normal input, an output and a control input. With control = 1 it passes its input (output 0 or 1). With control = 0 its output is in the high-impedance state: it behaves like an open circuit, so many buffer outputs can be tied to one line as long as only one is enabled.
A bus for k registers of n bits needs k × n three-state buffers. A log2 k × k decoder drives the buffer enables so that exactly one register's buffers are on at a time.
2.3 Memory transfers
The memory word selected by the address in AR is written M[AR]. With DR as the data register:
A system has 16 registers of 32 bits each. Design a common bus with multiplexers.
- One multiplexer per bit: 32 multiplexers.
- Each chooses among 16 registers: size 16 × 1.
- Select lines: log2 16 = 4, shared by all 32 multiplexers.
The same 16 registers of 32 bits use a three-state bus instead.
- Buffers: k × n = 16 × 32 = 512 buffers.
- Decoder: 4 select inputs, 16 outputs: a 4 × 16 decoder, each output enabling the 32 buffers of one register.
3. Arithmetic Microoperations
The basic arithmetic microoperations are add, subtract, increment, decrement and shift (shift is treated in the next lesson).
| Symbolic designation | Description |
|---|---|
| R3 ← R1 + R2 | contents of R1 plus R2 transferred to R3 |
| R3 ← R1 - R2 | contents of R1 minus R2 transferred to R3 |
| R2 ← overline{R2} | complement the contents of R2 (1's complement) |
| R2 ← overline{R2} + 1 | 2's complement the contents of R2 (negate) |
| R3 ← R1 + overline{R2} + 1 | R1 plus the 2's complement of R2 (subtraction) |
| R1 ← R1 + 1 | increment R1 by one |
| R1 ← R1 - 1 | decrement R1 by one |
Subtraction is normally done by complementing and adding: R1 - R2 = R1 + overline{R2} + 1. Multiply and divide are not listed: they are either sequences of add and shift microoperations, or done by special combinational circuits (Unit IV).
3.1 Binary adder and adder-subtractor
A 4-bit binary adder is a chain of four full adders, the carry of each feeding the next (ripple carry, lesson 10). Adding XOR gates on the B inputs gives the adder-subtractor: with mode M = 0 each XOR passes Bi and C0 = 0, so the circuit adds; with M = 1 the XORs complement B and C0 = 1, so it computes A + overline{B} + 1 = A - B.
4-bit adder-subtractor: XOR gates controlled by M
3.2 Binary incrementer
The increment R ← R + 1 can use the adder with B = 0 and C0 = 1, but a cheaper circuit is a chain of half adders: one input of the first is fixed at 1, and each carry goes into the next stage.
Binary incrementer from four half adders
When A = 1111, the output is D = 0000 with C4 = 1.
3.3 The arithmetic circuit
All the arithmetic microoperations come from one circuit: a parallel adder whose X inputs are A, whose Y inputs are chosen by a 4 × 1 multiplexer per bit, plus the input carry Cin. The multiplexer inputs are Bi, overline{Bi}, 0 and 1, selected by S1 S0. The output is
4-bit arithmetic circuit
| S1 | S0 | Cin | Y input | Output D = A + Y + Cin | Microoperation |
|---|---|---|---|---|---|
| 0 | 0 | 0 | B | D = A + B | add |
| 0 | 0 | 1 | B | D = A + B + 1 | add with carry |
| 0 | 1 | 0 | overline{B} | D = A + overline{B} | subtract with borrow |
| 0 | 1 | 1 | overline{B} | D = A + overline{B} + 1 | subtract |
| 1 | 0 | 0 | 0 | D = A | transfer A |
| 1 | 0 | 1 | 0 | D = A + 1 | increment |
| 1 | 1 | 0 | all 1s | D = A - 1 | decrement |
| 1 | 1 | 1 | all 1s | D = A | transfer A |
Two rows need explaining:
- Decrement (S1 S0 Cin = 110): Y = 1111, which is -1 in 2's complement, so A + 1111 = A - 1 (the carry out is discarded).
- Subtract with borrow (010): A + overline{B} = A - B - 1, used for multi-word subtraction when the previous word produced a borrow.
A = 0110 (6), B = 0011 (3). Find D and Cout for S1 S0 Cin = 011, 110 and 001.
- 011: Y = overline{B} = 1100, D = 0110 + 1100 + 1 = 1 0011. D = 0011 (3 = 6 − 3), Cout = 1.
- 110: Y = 1111, D = 0110 + 1111 = 1 0101. D = 0101 (5 = 6 − 1), Cout = 1.
- 001: Y = 0011, D = 0110 + 0011 + 1 = 1010 (10), Cout = 0.
In a 4-bit adder-subtractor, A = 0111 and B = 0101. Find the output and carry for M = 0 and M = 1.
- M = 0 (add): 0111 + 0101 = 1100, C4 = 0. As unsigned 7 + 5 = 12 ✓. (As signed it overflows: V = C4 oplus C3 = 0 oplus 1 = 1.)
- M = 1 (subtract): B is complemented to 1010 and C0 = 1: 0111 + 1010 + 1 = 1 0010. Result 0010 (2 = 7 − 5), C4 = 1 (no borrow).
Write RTL to (a) exchange R1 and R2 in one clock when T = 1; (b) form the 2's complement of R2 and add it to R1, storing in R3; (c) read the word at the address in AR into DR and then increment AR.
- (a) T: R1 ← R2, \ R2 ← R1.
- (b) R3 ← R1 + overline{R2} + 1 (that is, R3 ← R1 - R2).
- (c) DR ← M[AR], \ AR ← AR + 1 (both in one clock: the read uses the old AR).
4. Verilog: The 4-Bit Arithmetic Circuit
The model builds each stage from a 4 × 1 multiplexer and a full adder, chains four stages with a generate loop, and runs all eight select combinations on A = 6, B = 3:
// 4-bit arithmetic circuit (Mano): D = A + Y + Cin, Y chosen by a 4 x 1 MUX
module full_adder (
input x,
input y,
input c,
output s,
output co
);
assign s = x ^ y ^ c;
assign co = (x & y) | (c & (x ^ y));
endmodule
module arith_stage (
input a,
input b,
input [1:0] sel,
input cin,
output d,
output cout
);
reg y;
always @(*)
case (sel)
2'b00: y = b;
2'b01: y = ~b;
2'b10: y = 1'b0;
default: y = 1'b1;
endcase
full_adder fa (a, y, cin, d, cout);
endmodule
module arith_circuit (
input [3:0] a,
input [3:0] b,
input [1:0] sel,
input cin,
output [3:0] d,
output cout
);
wire [4:0] c;
assign c[0] = cin;
genvar i;
generate
for (i = 0; i < 4; i = i + 1) begin : stage
arith_stage st (a[i], b[i], sel, c[i], d[i], c[i + 1]);
end
endgenerate
assign cout = c[4];
endmodule
module tb;
reg [3:0] a = 4'd6, b = 4'd3;
reg [1:0] sel;
reg cin;
wire [3:0] d;
wire cout;
integer k;
reg [8*30:1] name [0:7];
arith_circuit u (a, b, sel, cin, d, cout);
initial begin
name[0] = "add: A + B";
name[1] = "add with carry: A + B + 1";
name[2] = "subtract with borrow: A + B'";
name[3] = "subtract: A + B' + 1";
name[4] = "transfer A";
name[5] = "increment: A + 1";
name[6] = "decrement: A - 1";
name[7] = "transfer A";
$display("A=%b (6) B=%b (3)", a, b);
for (k = 0; k < 8; k = k + 1) begin
{sel, cin} = k;
#1 $display("S1S0Cin=%b%b D=%b (%0d) Cout=%b %0s",
sel, cin, d, d, cout, name[k]);
end
end
endmoduleEvery row of the function table appears, including the decrement (5 = 6 − 1) and the subtraction (3 = 6 − 3) worked in Example 4:
A=0110 (6) B=0011 (3)
S1S0Cin=000 D=1001 (9) Cout=0 add: A + B
S1S0Cin=001 D=1010 (10) Cout=0 add with carry: A + B + 1
S1S0Cin=010 D=0010 (2) Cout=1 subtract with borrow: A + B'
S1S0Cin=011 D=0011 (3) Cout=1 subtract: A + B' + 1
S1S0Cin=100 D=0110 (6) Cout=0 transfer A
S1S0Cin=101 D=0111 (7) Cout=0 increment: A + 1
S1S0Cin=110 D=0101 (5) Cout=1 decrement: A - 1
S1S0Cin=111 D=0110 (6) Cout=1 transfer AKey points to remember
- Microoperation: one elementary operation on register data in one clock pulse.
- P: R2 ← R1 means P enables R2's LOAD; comma = same clock, so R1 ← R2, R2 ← R1 swaps.
- MUX bus: n multiplexers of k × 1; three-state bus: k n buffers and a decoder.
- Subtract = add the 2's complement: A + overline{B} + 1.
- Arithmetic circuit: D = A + Y + Cin, Y from a MUX (B, B', 0, 1). 110 is decrement.
📝 IPU End-Term Exam Corner (5-10 Marks)
- Q1. What is register transfer language? Explain the symbols used in RTL with examples and the meaning of P: R2 ← R1 with a block and timing diagram. (5 Marks)
- Q2. Explain how a common bus can be built with (a) multiplexers and (b) three-state buffers. How many of each are needed for 8 registers of 16 bits? (10 Marks)
- Write: 16 MUXes of 8 × 1 with 3 select lines; 128 buffers with a 3 × 8 decoder.
- Q3. Draw a 4-bit arithmetic circuit and give its function table for all values of S1, S0, Cin. (10 Marks)
- Q4. Draw a 4-bit binary adder-subtractor and explain its working. (5 Marks)
- Q5. Explain how the arithmetic circuit performs the decrement microoperation. (2.5 Marks)