1.0 The Design of Datapath Decoder: Ece 522/computer Organization
1.0 The Design of Datapath Decoder: Ece 522/computer Organization
Decoder
The register file requires a 2‐line to 4‐line decoder with HI‐true outputs and one HI‐true
enable input as shown in the circuit.
Multiplexer
Register
The four registers R0, R1, R2 and R3 in the diagram below are to be implemented using the
VHDL code. Each register comprises 4 positive edge‐triggered D flipflops. The clock input
to all flipflops in the register is defined as Clk. Then we will design the register file using the
by connecting the multiplexer, decoder and four registers as shown below.
1
ECE 522/COMPUTER ORGANIZATION
Datapath
The register file forms the basis of a "datapath" which is a fundamental building block of a
computer. Data is selected from any register then stored back into any other register in the
register file, all in a single clock cycle ( a lo‐hi‐lo pulse applied to the load enable LE input).
A Quad 2:1 MUX included as shown below allows external data to be inserted into the
datapath. Data can thus be transferred between any two registers of our register file or any
register can be loaded with external data. This datapath can execute the following operations:
(a) any register can be loaded with external data from switches Rd ← data (4‐bits)
(where d=0,1,2 or 3)
(b) any register can be loaded with the data contained in any one of the other registers,
The implementation is shown below. The inputs [ D1, D0, S1, S0, DS ] form a 5‐bit
"control" word which specifies the source (S1, S0) and destination (D1, D0) registers of the
register file and an operation (DS) that is to take place. For DS=0, external data from
switches is loaded into the destination register; for DS=1, data is transferred from the source
register to the destination register. Once the control word and data input (if appropriate) are
set on the level switches, execution is achieved by applying a load enable (LE) input to the
register file. This LE input may be considered as the clock to the entire system.
2
ECE 522/COMPUTER ORGANIZATION
ALU
An ALU is a combinational logic circuit that performs various arithmetic and logic operations
on n-bit data (operands). The number of bits on the "function select" input determines how
many operations may be performed on the operands.
To be able to include an ALU in our datapath, we must first modify our register file design so
that it has the capability to select two registers as outputs (Source Register A and Source
Register B). This will allow the contents of any two registers to be applied to the A and B
inputs of the ALU. This is easily achieved by adding a second Quad 4:1 MUX to the design of
the register file as shown below:
3
ECE 522/COMPUTER ORGANIZATION
Destination register select (2 bits), source register A select (2 bits), source register B select (2
bits) and load enable (1 bit). The outputs are Data Out A and Data Out B (each 4 bits) as
shown above.
Now, the datapath design can be extended by including the ALU and the register file as
shown in the next figure:
The inputs [ D1, D0, SA1, SA0, SB1, SB0, s2, s1, s0, DS ] comprise a 10‐bit control word
which specifies a destination register (D1, D0) , the two source registers (SA1, SA0) and
(SB1, SB0), and the ALU function (s2, s1, s0) that operates on the source registers. The DS
input allows loading of the registers with external data via the Quad 2:1 MUX. For DS=0,
external data from switches is loaded into the destination register; for DS=1, data is
transferred from the ALU output to the destination register. Once the control word and data
input are set on the level switches, execution is achieved by applying a load enable (LE) input
(pulse lo‐hi‐lo) to the register file. This LE input may be considered as the clock to the entire
system. You can view the results of each operation using four LEDs connected to the output
of the ALU as shown. The function that is executed in response to a control word and a LE
clock input is called a microoperation. A series of microoperations applied to a datapath is
called a microprogram.
4
ECE 522/COMPUTER ORGANIZATION
2.1 Objective
To gain insight into the internal logic for data movement between registers in a
computer
To introduce the concept of a control word for implementing an elementary set of
micro‐operations.
To gain experience with the use of VHDL constructs
To gain experience with incremental, modular design
A quad 2-to-1 multiplexer is attached to each of the two address inputs to the register file, to
select between an address from the microcontroller and an address from the instruction.
5
ECE 522/COMPUTER ORGANIZATION
There is a 5-bit signal in the microcontroller for the combined destination and source address
DSA, in addition another 5-bit signal for the B address SB. The first bit of each of these fields
selects the register file address source. If the first bit is 0 it selects the microcontroller(MC),
else it selects the instruction(IR). If an instruction is selected, whether it is DST or SRC is
determined by an additional quad 2-to-1 multiplexer. This 1 multiplexer is controlled by the
second bit of the DSA or SB field, depending on which of them has 1 as the first bit. Only one
of the signals DSA and SB is allowed to have a 1 in the first bit, thereby ensuring that the
proper second bit is used to determine the register address. A 0 is appended to the left of the
3-bit fields DST and SRC to cause them to address R0 through R7. In addition to the first bit,
which selects the address source, the addresses from the microcontroller contain four bits so
that all 16 registers can be reached. The final change to the register is to replace the storage
elements for R0 in the file with open circuits on the lines that were their inputs and with
constant zero values on the lines that were their outputs.
The block diagram and symbol for a 16x16 Register file is showing in figure below:
6
ECE 522/COMPUTER ORGANIZATION
For the function unit, we can use the ALU and shift register designs you created before. The
block diagram of a function unit is showing below:
7
ECE 522/COMPUTER ORGANIZATION
-- 2 to 1 mux
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.STD_LOGIC_ARITH.ALL;
--use IEEE.STD_LOGIC_UNSIGNED.ALL;
end mux2;
begin
begin
if (s='0') then
y <= d0;
else
y <= d1;
end if;
end process;
end behavioral;
8
ECE 522/COMPUTER ORGANIZATION
-- register file
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
--use IEEE.STD_LOGIC_UNSIGNED.ALL;
end regfile;
9
ECE 522/COMPUTER ORGANIZATION
begin
begin
end if;
end if;
end process;
begin
else
end if;
end process;
10
ECE 522/COMPUTER ORGANIZATION
begin
else
end if;
end process;
end behavioral;
11
ECE 522/COMPUTER ORGANIZATION
-- alu
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
end alu;
begin
process(alusel, a , b)
begin
case alusel is
f <= a;
f <= a and b;
f <= a or b;
12
ECE 522/COMPUTER ORGANIZATION
f <= not a;
f <= a + b;
f <= a - b;
f <= a + 1;
f <= a - 1;
end case;
end process;
end behavior;
13
ECE 522/COMPUTER ORGANIZATION
--shifter
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.STD_LOGIC_ARITH.ALL;
--use IEEE.STD_LOGIC_UNSIGNED.ALL;
end shifter;
begin
process(shsel, input)
begin
case shsel is
14
ECE 522/COMPUTER ORGANIZATION
end case;
end process;
end behavior;
15
ECE 522/COMPUTER ORGANIZATION
-- tri-state buffer
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.STD_LOGIC_ARITH.ALL;
--use IEEE.STD_LOGIC_UNSIGNED.ALL;
e: in std_logic;
end tristatebuffer;
begin
process (e, d)
begin
y <= d;
else
end if;
end process;
end behavioral;
16
ECE 522/COMPUTER ORGANIZATION
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.STD_LOGIC_ARITH.ALL;
--use IEEE.STD_LOGIC_UNSIGNED.ALL;
clock: in std_logic;
rae: in std_logic;
rbe: in std_logic;
oe: in std_logic;
end datapath;
17
ECE 522/COMPUTER ORGANIZATION
end component;
end component;
end component;
18
ECE 522/COMPUTER ORGANIZATION
end component;
e: in std_logic;
end component;
begin
end structural;
19
ECE 522/COMPUTER ORGANIZATION
2.4.1 MUX
RTL Schematic
20
ECE 522/COMPUTER ORGANIZATION
Technology Schematic
21
ECE 522/COMPUTER ORGANIZATION
RTL Schematic
22
ECE 522/COMPUTER ORGANIZATION
Technology Schematic
23
ECE 522/COMPUTER ORGANIZATION
2.4.3 ALU
RTL Schematic
24
ECE 522/COMPUTER ORGANIZATION
Technology Schematic
25
ECE 522/COMPUTER ORGANIZATION
2.4.4 Shifter
RTL Schematic
26
ECE 522/COMPUTER ORGANIZATION
Technology Schematic
27
ECE 522/COMPUTER ORGANIZATION
RTL Schematic
28
ECE 522/COMPUTER ORGANIZATION
Technology Schematic
29
ECE 522/COMPUTER ORGANIZATION
RTL Schematic
30
ECE 522/COMPUTER ORGANIZATION
Technology Schematic
31
ECE 522/COMPUTER ORGANIZATION
Waveform
32
ECE 522/COMPUTER ORGANIZATION
waveform
33
ECE 522/COMPUTER ORGANIZATION
3.0 Discussion
The multiplexer circuit is typically used to combine two or more digital signals onto a
single line, by placing them there at different times. Technically, this is known as time-
division multiplexing.This is a digital circuit with multiple signal inputs, one of which is
selected by separate address inputs to be sent to the single output. It's not easy to describe
without the logic diagram, but is easy to understand when the diagram is available. Input A is
the addressing input, which controls which of the two data inputs, X0 or X1, will be
transmitted to the output. If the A input switches back and forth at a frequency more than
double the frequency of either digital signal, both signals will be accurately reproduced, and
can be separated again by a demultiplexer circuit synchronized to the multiplexer.
Multiplexers are not limited to two data inputs. If we use two addressing inputs, we can
multiplex up to four data signals. With three addressing inputs, we can multiplex eight
signals.
Arithmetic logic unit (ALU) is a digital circuit that performs arithmetic and logical
operations. Most ALUs can perform the following operations such as Integer arithmetic
operations (addition, subtraction, and sometimes multiplication and division, though this is
more expensive) , Bitwise logic operations (AND, NOT, OR, XOR) , Bit-shifting operations
(shifting or rotating a word by a specified number of bits to the left or right, with or without
sign extension). Shifts can be interpreted as multiplications by 2 and divisions by 2. An ALU
must process numbers using the same format as the rest of the digital circuit. The format of
modern processors is almost always the two's complement binary number representation.
Early computers used a wide variety of number systems, including one's complement, sign-
magnitude format, and even true decimal systems, with ten tubes per digit.ALUs for each one
of these numeric systems had different designs, and that influenced the current preference for
two's complement, as this is the representation that makes it easier for the ALUs to calculate
additions and subtractions. The two's-complement number system allows for subtraction to be
accomplished by adding the negative of a number in a very simple way which negates the
need for specialised circuits to do subtraction.
34
ECE 522/COMPUTER ORGANIZATION
aid" and "Z" as "no kool aid". A tri-state buffer is a useful device that allows us to control
when current passes through the device, and when it doesn't. A tri-state buffer has two inputs:
a data input x and a control input c. The control input acts like a valve. When the control input
is active, the output is the input. That is, it behaves just like a normal buffer. The "valve" is
open. When the control input is not active, the output is "Z". The "valve" is open, and no
electrical currentflows through. Thus, even if x is 0 or 1, that value does not flow through.
The behavior of a active-high tri-state buffer in this situation, when the output is Z, that
means it's high impedance, neither 0, nor 1, i.e., no current.
Shift register is a cascade of flip flops, sharing the same clock, which has the output of
any one but the last flip-flop connected to the "data" input of the next one in the chain,
resulting in a circuit that shifts by one position the one-dimensional "bit array" stored in it,
shifting in the data present at its input and shifting out the last bit in the array, when enabled
to do so by a transition of the clock input. More generally, a shift register may be
multidimensional, such that its "data in" input and stage outputs are themselves bit arrays: this
is implemented simply by running several shift registers of the same bit-length in
parallel.Shift registers can have both parallel and serial inputs and outputs. These are often
configured as serial-in, parallel-out (SIPO) or as parallel-in, serial-out (PISO). There are also
types that have both serial and parallel input and types with serial and parallel output. There
are also bi-directional shift registers which allow shifting in both directions: L→R or R→L.
The serial input and last output of a shift register can also be connected together to create a
circular shift register. One of the most common uses of a shift register is to convert between
serial and parallel interfaces. This is useful as many circuits work on groups of bits in parallel,
but serial interfaces are simpler to construct. Shift registers can be used as simple delay
circuits. Several bi-directional shift registers could also be connected in parallel for a
hardware implementation of a stack.
35
ECE 522/COMPUTER ORGANIZATION
4.0 CONCLUSION
In conclusion, we had done completed this miniproject succefully. We had learn about VHDL
code for modeling the complex general datapath circuit such as 2 to 1 multiplexer, register
file, arimetric logic unit, shifter, tri-state buffer and top model. VHDL software is also an
excellent software to simulate any logic devices, either by RTL circuit of I/O waveform
before implementing it. The language or coding is also very similiar to C language, making it
easier to learn, because C language is the basic language of progarmming language. With
VHDL software, the logic that was simulate is easy in making it because its internal logics
can be seen by this software. This software also can educate people of the datapath of an
ALU, register file and others. Any VHDL code can also be connected or combined to make
one logic unit act as one.
36