Control Unit
Control Unit
Madhu Mutyam
Assistant Professor
Computer Architecture and Systems Laboratory
Department of Computer Science and Engineering
Indian Institute of Technology, Madras
[email protected]
http://www.cse.iitm.ac.in/~madhu
Three registers, R1, R2, and R3
Swap the contents of R1 and R2
T1: R3 [R2]
T2: R2 [R1]
T3: R1 [R3]
Control signals:
T1: R2out, R3in
T2: R1out, R2in
T3: R3out, R1in
Control signals:
T1 T2 T3
1 0 0
0 1 0
0 0 1
module regn(R, Rin, Clk, Q); module shiftr(Resetn, w, Clk, Q);
parameter n = 8; parameter m = 4;
input [n-1:0] R; input Resetn, w, Clk;
input Rin, Clk; output reg [1:m] Q;
output reg [n-1:0] Q; integer k;
assign F = E? Y : ‘bz;
endmodule
module swap(Data, Resetn, w, Clk, Extern, RinExt, BusWires);
input Resetn, w, Clk, Extern;
input [7:0] Data;
input [1:3] RinExt;
output tri [7:0] BusWires;
wire [1:3] Rin, Rout, Q;
wire [7:0] R1, R2, R3;
Bus
R0 R3 A B
Clk
G
Data
Bus
R0 R3 A B
Clk
Gout
w AddSub
Control unit Gin
Instruction
Extern
Done
Load and Move require one clock cycle.
Add and Sub require three clock cycles:
◦ A [Rx]
◦ Bus [Ry]; Perform Add/Sub; Result is
stored in G
◦ Rx [G]
T0 T1 T2 T3
T0 No operation
T1 1st step of an y0 y1 y2 y3
operation
2-to-4 decoder
T2 2nd step of an w1 w0 En
operation
T3 3rd step of an 1
operation
Q1 Q0
Clk
Up-counter
Clear Reset
I0 I1 I2 I3 X0 X1 X2 X3 Y0 Y1 Y2 Y3
y0 y1 y2 y3 y0 y1 y2 y3 y0 y1 y2 y3
1 1 1
Clk
IRin Instruction Register (IR) I0 Load
I1 Move
f1 f0 Rx1 Rx0 Ry1 Ry0 I2 Add
I3 Sub
Instruction
Clear = (~w)T0 + Done
IRin = wT0
T1 T2 T3
Extern, Rin = X,
(Load): I0
Done
Rin = X, Rout = Y,
(Move): I1
Done
(Add): I2 Rout = X, Ain Rout = Y, Gin, Gout, Rin = X,
AddSub = 0 Done
(Sub): I3 Rout = X, Ain Rout = Y, Gin, Gout, Rin = X,
AddSub = 1 Done
Extern = I0T1
Done = (I0 + I1)T1 + (I2 + I3)T3
Ain = (I2 + I3)T1
Gin = (I2 + I3)T2
Gout = (I2 + I3)T3
AddSub = I3
R0in = (I0 + I1)T1X0 + (I2 + I3)T3X0
R0out = I1T1Y0 + (I2 + I3)(T1X0 + T2Y0)
R1in, R2in, R3in, R1out, R2out, and R3out are derived in the
same way.
Timing constructs are ignored.
initial construct is not supported.
◦ Use reset mechanism to initialize signals in the circuit.
For sequential logic, the always statement must
contain @(posedge clk) or @(negedge clk).
For combinational logic, the always statement must be
triggered by a signal other than the clk, reset, or preset.
Specify all signal widths and variable widths explicitly.
while and forever loops must contain @(posedge clk)
or @(negedge clk).
Thank You