Supervisor: Dr. Asim J. Alkhalili
Department of Electrical and Computer Engineering
1- Introduction ................................................................................................................................ 2
2- Setting up the environment to run the Synopsys VHDL simulation tools .................................. 2
3- VHDL: Basic Language Organization ....................................................................................... 3
4- Examples .................................................................................................................................... 4
4.1- Full Adder ............................................................................................................................ 4
4.1.1- Structural Description ................................................................................................ 4
4.1.2- Behavioral Descriptions ........................................................................................... 15
4.1.3- Stimulator ................................................................................................................. 17
4.1.4- Test Bench for Full Adder ........................................................................................ 19
4.2- Register .............................................................................................................................. 21
4.2.1- Structural Description .............................................................................................. 21
4.2.2- Mixed Description .................................................................................................... 27
4.2.3- Behavioral Description ............................................................................................. 29
4.3- Counter ............................................................................................................................. 31
4.3.1- BCD Counter ............................................................................................................ 31
4.3.2- 3 Digit Counter ......................................................................................................... 38
4.4- Multiplier ........................................................................................................................... 43
4.4.1- Unsigned 4x4 Bit Multiplier .................................................................................... 43
4.4.2- Unsigned 8x8 Bit Multiplier .................................................................................... 44
4.4.3- Signed 8x8 Bit Multiplier ......................................................................................... 45
This tutorial deals with the basic structure of VHDL code, analysis of VHDL source files and VHDL simulation using the Synopsys VHDL System Simulator (VSS).
Section 2 will help you in setting up the environment , to run the Synopsys VHDL simulation tools. Section 3 gives some idea of VHDL basic language organization. Section 4 contains some examples of VHDL coding, starting with a simple combinational circuit, Full Adder, which has been constructed using different VHDL modeling styles. Next some advance aspects of VHDL have been introduced by constructing different VHDL descriptions of an 8 bit Register. In the next example, codes for a BCD Counter have been generated; which are upgraded to a 3 digit counter. In the end, signed and unsigned Multipliers are designed by using dataflow and algorithmic implementation styles.
To set up your environment refer to the following Tutorial :
"Digital Logic Synthesis Using Synopsys and Xilinx
A Tutorial By Ted Obuchowicz"
It can found in http://www.ece.concordia.ca -->documentation-->Other
Tutorials-->Tutorials
A basic working knowledge of the UNIX operating system (using text editors, creating directories, copying files, printing, etc.) is needed to work on the tutorial.
Once your environment is set up you may follow the tutorial for for the analysis, simulation and elaboration of your VHDL code.
Design entity is the basic construct in VHDL for modeling a digital system. A design entity can represent an arbitrarily complex digital system, ranging from a logic gate to an entire network of computers.
Design entity is composed of two parts: Interface and Body
Interface is denoted by the keyword entity.
Body is denoted by the keyword architecture
Interface defines the boundary between the design entity and the environment, such as signals that flow into and out of design entity. Body describes how the design operates (how the outputs respond to inputs). Body is separated from design entity Interface to allow different implementations of the same design entity. Different implementations are possible for the same design using different modeling styles.
There are two basic VHDL modeling styles: Structural and Behavioral.
Structural modeling (Structural Architectures) implicitly defines the input/output functions by describing components and their interconnections.
Behavioral modeling (Behavioral Architectures) explicitly defines the input/output functions by describing signal transformations.
There are two general kinds of Behavioral modeling: Dataflow modeling and Algorithmic modeling.
Dataflow modeling uses concurrent statements whereas Algorithmic modeling uses sequential statements. Algorithmic architecture is composed of one or more concurrent processes. The statements inside each process executes sequentially.
VHDL code for full adder is generated using three different modeling styles i.e Structural, Data-flow and Algorithmic. Thus three different architectures are written for the same design entity FULL_ADDER.
In Structural description, Structural architecture of the design entity describes it in terms of interconnected components. Each component may be in turn described as interconnected subcomponents or behavioral in terms of built-in functions.
The first step in writing VHDL code for structural architectures is to write the codes for components in separate design entities and analyze them. Analysis creates simulation files in WORK directory. Using those files in the configuration commands of the design code of parent circuit, allows us to use those design entities as components in our parent circuit.
In the generation of the structural code for Full adder, we will generate VHDL code of all three components i.e XOR, AND and OR gates as shown in the figure 1, in the separate design entities.
Using any text editor (xedit, emacs, etc.), write the VHDL code of XOR gate as given below and save it in file XOR2.vhd
architecture DATA_FLOW of XOR_2 is
architecture ALGORITHM of XOR_2 is
Two different architectures ALGORITHM & DATA_FLOW, of the same design entity XOR_2 are given.
Analysis is done to check the design for errors and to create simulation files, that will be saved in the WORK directory. Analysis may be performed by using gvan (Graphical VHDL ANalyzer). While you are in your VHDL directory, at UNIX prompt type:
Synopsys VHDL Analyzer Error Browser (Gvan) window will appear as shown in figure 2. Any error contained in the source code will be displayed in the central part of the window. Errors can be corrected by opening your original file (XOR2.vhd) by using any text editor. After correcting the errors, re-analyze the file by using above command. If no error reported, exit the window by clicking Cancel button in the Synopsys VHDL Analyzer Error Browser (Gvan) window.
Simulation is done to check the dynamic behavior of the design entity. Simulation is done by vhdldbx command. While you are in your VHDL directory, at UNIX prompt type:
Vhdldbx - Select Simulator Arguments window will appear, as shown in figure 3.
Fig 3: Vhdldbx - Select Simulator Arguments
Check that the selected library is DEFAULT. Select any of the two entity-architecture pairs: XOR_2__ALGORITHM or XOR_2__DATA_FLOW from the Design window. Click OK.
Synopsys VHDL Debugger (Vhdldbx) window will appear as shown in figure 4, with your VHDL source code in the upper half of the window. Click on the line, at the most bottom part of the window, to invoke the Command line prompt (#).
To trace the signals, enter at the Command line:
After some time, Synopsys Waveform Viewer window will appear, as shown in figure 5. The next step is to assign values to the inputs. At the Command line in Synopsys VHDL Debugger window, enter
To run the simulation for 10 ns, enter
Make sure that the number of runs is specified (10 in this case), otherwise your simulation cycle will enter into an infinite loop and you will have to kill that simulation job.
Fig 4: Synopsys VHDL Debugger (Vhdldbx)
The waveform for selected signals will appear in the Synopsys Waveform Viewer window. To see the complete waveform, select View -> Full Fit from the top menu bar. Give new values and run the simulator for another time period. Figure 6 shows the result of the simulation.
You can print the results by selecting File -> Print. Click on Print to File in the Print Options window and then enter a name for the file with extension .ps, say XOR_SIM.ps. Click OK.
Fig 5: Synopsys Waveform Viewer
Fig 6: Simulation Result of XOR_2
Now exit the Synopsys VHDL Debugger (Vhdldbx) window by clicking on Execute -> Quit.
Elaborate command is used to build a design from a VHDL entity and architecture or a VHDL configuration. To elaborate a design, enter the following command from your UNIX prompt:
Synopsys Design Analyzer window will open as shown in figure 7.
Fig 7: Synopsys Design Analyzer
Click on File -> Analyze. Analyze File window will appear. Select XOR2.vhd and click OK. Analyze window will appear. After some time if you receive a 1 at the end of analysis, its mean your analysis is successful. If you do not receive a 1, then there are some errors in your VHDL code. Go back and correct them.
From Synopsys Design Analyzer window, click on File -> Elaborate. Elaborate design window will appear as shown in figure 8. Select library WORK. Two designs will be displayed: XOR_2(ALGORITHM) and XOR_2(DATA_FLOW). Select XOR_2(ALGORITHM) and click OK. You will see entity name (XOR_2) with a box in the center of Synopsys Design Analyzer window. Double click on it. You will see XOR_2 gate with its input/output ports. Double click on it and you will see schematic diagram of XOR gate as shown in figure 9. Follow the same steps for XOR_2(DATA_FLOW). The gate level schematic diagram is shown in Figure 10. It can be seen that the DATA_FLOW architecture is implemented by a built-in XOR gate.
Generate and save the VHDL code of AND gate, as given below, in file AND2.vhd
architecture DATA_FLOW of AND_2 is
architecture ALGORITHM of AND_2 is
Again two different architectures ALGORITHM & DATA_FLOW of the same design entity AND_2 are given.
Generate and save the VHDL code of OR gate, as given below, in file OR2.vhd.
architecture DATA_FLOW of OR_2 is
Now you have generated and analyzed all three components of full adder. The last step is to connenect the component together. VHDL code of structural Full Adder is given below. Save it in file FULL_ADDER_STRUC.vhd.
architecture STRUCTURE of FULL_ADDER is
-- Configuration specifications
for all : XOR_2 use entity WORK.XOR_2(ALGORITHM);
for all : AND_2 use entity WORK.AND_2(ALGORITHM);
for O1 : OR_2 use entity WORK.OR_2(ALGORITHM);
-- Component Instantiations using named association
X1 : XOR_2 port map (A => A_IN, B => B_IN, Z => S1);
X2 : XOR_2 port map (A => S1, B => C_IN, Z => SUM);
A1 : AND_2 port map (A => S1, B => C_IN, Z => S2);
A2 : AND_2 port map (A => A_IN, B => B_IN, Z => S3);
O1 : OR_2 port map (A => S2, B => S3, Z => C_OUT);
Components are first declared and then connected together by using port map command. Only ALGORITHM architectures of XOR_2, AND_2 and OR_2 entities are used in configuration specifications. You can also select DATA_FLOW architectures by just replacing DATA_FLOW with ALGORITHM in the configuration specification commands. Analyze the code and then elaborate it. You will see the design as shown in figure 11.
Two more VHDL descriptions (Data-flow and Algorithmic) of Full Adder are shown below. Save it in file FULL_ADDER_BEHAV.vhd.
architecture DATA_FLOW of FULL_ADDER is
architecture ALGORITHM of FULL_ADDER is
variable S : BIT_VECTOR(1 to 3);
variable NUM : INTEGER range 0 to 3 := 0;
when 0 => C_OUT <='0'; SUM <= '0';
when 1 => C_OUT <='0'; SUM <= '1';
when 2 => C_OUT <='1'; SUM <= '0';
when 3 => C_OUT <='1'; SUM <= '1';
Analyze the code and then elaborate both Dataflow and Algorithmic designs. The results are shown in figures 12 and 13.
Fig 12: Dataflow Design of Full Adder
To generate 3 inputs for full adder, write the code of 3 bit Stimulator as below and save it in file
STIMULATOR.vhd. Port specifications of Stimulator are given in figure 14.
Fig 14: Port Specifications of Stimulator
In the end connect STIMULATOR and FULL_ADDER together (figure 15), by port mapping to get the test bench for the simulation of Full Adder, as given below. Save it in file BENCH_FA.vhd.
Fig 15: Test Bench of Full Adder
architecture STRUCTURE of BENCH_FA is
-- Configuration specifications
for ST : STIMULATOR use entity WORK.STIMULATOR(ALGORITHM);
for FA : FULL_ADDER use entity WORK.FULL_ADDER(STRUCTURE);
signal S1, S2, S3, SUM_OUT, CARRY_OUT : BIT;
-- Component Instantiations using positional association
ST : STIMULATOR port map (S1, S2, S3);
FA : FULL_ADDER port map (S1, S2, S3, SUM_OUT, CARRY_OUT);
Structural architecture of Full Adder has been used in this bench. You can use any one of 3 architectures by changing STRUCTURE to DATA_FLOW or ALGORITHM in the configuration specification command of Full Adder.
Analyze the bench and then simulate it. In the Command line of Synopsys VHDL Debugger (Vhdldbx) window, type:
Design entity of Register is described using two architectures i.e. Structural and Behavioral.
In the generation of the structural code for 8 bit Register, we will generate VHDL code of all three components i.e DFF, AND and NOT gates, as shown in the figure 17, in the separate design entities.
Fig 17: 8 bit Register citcuit
Using any text editor, write the VHDL code of DFF as given below and save it in file DFF1.vhd.
architecture BEHAVIOUR of DFF1 is
wait until (CP = '1'and CP'event);
-- Wait for the rizing edge of clock
Variable is used inside the architecture instead of signal whose value will change instantaneously. The values assigned to signals does not change immediately. `:=' is variable assignment operator. Note that variables are declared inside the process statements.
In CP'event, event is a predefined attribute. It has a value of type BOOLEAN. If an event will occur on CP, CP'event will become TRUE; otherwise it is false.
Another code of DFF is given below. (Save it in file DFF2.vhd).
architecture BEHAVIOUR of DFF2 is
Note that in the interface part, mode of the ports Q and QNOT is buffer instead of out.
in: Information flows only into the design entity.
out: Information flows only out of the design entity.
input: Information flows into and out of the design entity. A value can be read and assigned. The value read is that of the port's incoming value, not the assigned value (if any).
buffer: Information flows into and out of the design entity. It is similar to out, but it can be read. The value read is the assigned value.
linkage: Information flows into and out of the design entity.
In DFF2, the mode of the ports Q and QNOT is buffer, so we don't need an internal variable.
Analyze DFF1.vhd and DFF2.vhd and simulate to see that they have same dynamic behavior. Then elaborate the two entities, you will get the results as shown in figure 18 and 19.
AND_2 design entity (already saved in AND2.vhd file) will be used in Structural Register.
Generate and save the VHDL code of inverter, as given below, in file NOT1.vhd
architecture DATA_FLOW of NOT_1 is
architecture ALGORITHM of NOT_1 is
Structural description of 8 bit register, using components DFF, AND gate and Inverter, is given below. Save it in file REGISTER8_STRUC.vhd.
DATA_IN : in BIT_VECTOR(7 downto 0);
DATA_OUT : buffer BIT_VECTOR(7 downto 0));
architecture STRUCTURE of REGISTER8_1 is
signal D : BIT_VECTOR(7 downto 0);
for FF1 : DFF2 use entity WORK.DFF2(BEHAVIOUR);
for A1,A2 : AND_2 use entity WORK.AND_2(ALGORITHM);
for N1 : NOT_1 use entity WORK.NOT_1(ALGORITHM);
N1 : NOT_1 port map(CLEAR, N_CLEAR);
A1 : AND_2 port map(DATA_IN(0), N_CLEAR, D(0));
A2 : AND_2 port map(LOAD, CP, CLK);
FF1 : DFF2 port map(CLK, D(0), DATA_OUT(0), open);
for FF2 : DFF2 use entity WORK.DFF2(BEHAVIOUR);
for A3 : AND_2 use entity WORK.AND_2(ALGORITHM);
A3 : AND_2 port map(DATA_IN(I), N_CLEAR, D(I));
FF2 : DFF2 port map (CLK, D(I), DATA_OUT(I), open);
Instead of declaring components in architecture, they are declared in package, PACKAGE1 as shown below. Save it in file PACKAGE1.vhd.
VHDL structural descriptions of logic schematics often use the same set of components and rewriting component declarations for every logic schematic can be tedious; this problem can addressed by packages. Package declaration can contain component declarations, signal declarations, type & subtype declarations, function declarations, procedure declarations, etc.
First analyze PACKAGE1.vhd and then analyze REGISTER8_STRUC.vhd. Simulate the Structural description of Register and then Elaborate it. You will get logic schematic as shown in figure 20.
We can mix different implementation styles together. In the following example an 8 bit Register has been implemented using a mixed description, containing both structural and dataflow implementation styles. Save it in file REGISTER8_MIXED.vhd.
DATA_IN : in BIT_VECTOR(7 downto 0);
DATA_OUT : buffer BIT_VECTOR(7 downto 0));
architecture MIXED_IMPLEMENTATION of REGISTER8_1 is
signal D : BIT_VECTOR(7 downto 0);
for FF1 : DFF2 use entity WORK.DFF2(BEHAVIOUR);
D(0) <= DATA_IN(0) and N_CLEAR;
FF1 : DFF2 port map(CLK, D(0), DATA_OUT(0), open);
for FF2 : DFF2 use entity WORK.DFF2(BEHAVIOUR);
D(I) <= DATA_IN(I) and N_CLEAR;
FF2 : DFF2 port map (CLK, D(I), DATA_OUT(I), open);
Analyze the file, simulate it to check the dynamic behavior and then elaborate it, you will see the logic schematic as shown in figure 21.
Fig 21: Mixed Implementation of 8 bit Register
4.2.3- Behavioral Description:
Behavioral description of Register is described below. Save it in file REGISTER8_BEHAV.vhd.
type VECTOR8 is array (7 downto 0) of BIT;
architecture BEHAVIOUR of REGISTER8_2 is
if (CP = '1'and CP'event) then
DATA_OUT <= VECTOR8'(others => '0');
A user defined Type VECTOR8 is declared inside package PACK which is also saved in the same file. others command is used to make all the bits of VECTOR8 zeroes. Analyze the file, simulate it to check the dynamic behavior and then elaborate it, you will see the logic schematic as shown in figure 22.
In this part two descriptions of BCD Counter are given and then BCD Counter is upgraded to 3 digit Counter. Test benches for both counters are also given.
Algorithmic description of BCD counter is given below. Save it in file BCD_COUNTER1.vhd.
COUNT : buffer STD_LOGIC_VECTOR(3 downto 0));
architecture ALGORITHM1 of COUNTER is
type STATE_TYPE is range 0 to 9;
signal CURRENT_STATE : STATE_TYPE;
COMBINATIONAL : process(CURRENT_STATE)
wait until (CP = '1') and CP'event;
if (RESET = '0') and (CURRENT_STATE /= 9) then
CURRENT_STATE <= CURRENT_STATE + 1;
In earlier examples, we were using type of information as BIT or BIT_VECTOR. The declaration of predefined type BIT and BIT_VECTOR is provided in the package STANDARD, which is linked to our VHDL files by default. In the above VHDL code, the type of information is STD_LOGIC, which is used to represent values in standard 9-valued logic systems. It is declared in package STD_LOGIC_1164 as
type STD_LOGIC is (`U','X','0','1','Z','W','L','H','-');
This package is located in library IEEE. We can use this package by first using the library command and then using use command.
The architecture ALGORITHUM1, contains two concurrent processes, COMBINATIONAL and SEQUENTIAL. A user defined type STATE_TYPE is declared inside architecture. case statement is used to select the value of COUNT depending on the value of CURRENT_STATE.
Analyze the design and then Elaborate it. You will get a design as shown in figure 23.
Another Algorithmic description of BCD Counter is given below. Save it in file BCD_COUNTER2.vhd.
use IEEE.STD_LOGIC_UNSIGNED.all;
COUNT : buffer STD_LOGIC_VECTOR(3 downto 0));
architecture ALGORITHM2 of COUNTER is
constant ZERO : STD_LOGIC_VECTOR(3 downto 0) := "0000";
constant NINE : STD_LOGIC_VECTOR(3 downto 0) := "1001";
Fig 23: BCD Counter(Algorithum1)
elsif ((CP = '1') AND CP'event) then
The use of `+' is an example of Operator Overloading, which is described in STD_LOGIC_UNSIGNED package of IEEE library.
Analyze the design and then Elaborate it. You will get a design as shown in figure 24.
To generate the test bench for the simulation of BCD Counter, we need a clock, whose VHDL code is given below. Save it in file CLOCK.vhd. Port specifications for Clock are shown in figure
Fig 25: Port Specifications of Clock
architecture BEHAVIOR of CLOCK is
generic is used in the interface part of entity CLOCK. Using generics allows us to pass values to the entity when that entity is instantiated.
In order to do the simulation of BCD Counter, a test bench has been generated by connecting CLOCK and COUNTER together (figure 26), as given below. Save it in file BENCH_COUNTER.vhd.
Fig 26: Test bench of BCD Counter
architecture STRUCTURE of BENCH_COUNTER is
COUNT : buffer STD_LOGIC_VECTOR(3 downto 0));
-- Configuration specifications
for CLK1 : CLOCK use entity WORK.CLOCK(BEHAVIOR);
for CUNTR : COUNTER use entity WORK.COUNTER(ALGORITHM2);
signal COUNT : STD_LOGIC_VECTOR(3 downto 0);
-- Component Instantiations using positional association
CLK1 : CLOCK generic map(HALF_PERIOD)
CUNTR : COUNTER port map(CP, RESET, COUNT);
ALGORITHM2 of COUNTER entity is used. You can use ALGORITHM1 by simply replacing ALGORITHM1 with ALGORITHM2 in the configuration specification command of COUNTER.
A concurrent process RESETTING is given for the asynchronous resetting.
Analyze the bench and then simulate it. In the Command line of Synopsys VHDL Debugger (Vhdldbx) window, type:
You will get simulation result as shown in figure 27.
Fig 27: Simulation result of test bench of BCD Counter
ALGORITHM2 architecture of BCD Counter has been upgraded to construct a 3 digit Counter that will permit counting from 0 to 999. Save it in file BCD_COUNTER_3DIGIT.vhd.
use IEEE.STD_LOGIC_UNSIGNED.all;
COUNT : buffer STD_LOGIC_VECTOR(11 downto 0));
architecture ALGORITHM of COUNTER_3DIGIT is
signal MSD, LSD2, LSD : STD_LOGIC_VECTOR(3 downto 0);
constant ZERO : STD_LOGIC_VECTOR(3 downto 0) := "0000";
constant NINE : STD_LOGIC_VECTOR(3 downto 0) := "1001";
elsif ((CP = '1') AND CP'event) then
The technique used in this design is to check the value of the LSD and if it equals 9, set it back to 0 (on the next clock cycle) and check the LSD2. If it equals 9, do the same, otherwise let the LSD2 count up, and so on for the MSD.
Analyze the design and then Elaborate it. You will get a design as shown in figure 28.
For the simulation of 3 digit Counter, a test bench has been generated by connecting CLOCK and COUNTER_3DIGIT together (figure 29), as given below. Save it in file BENCH_COUNTER_3DIGIT.vhd.
Fig 29: Test bench of 3 digit BCD Counter
entity BENCH_COUNTER_3DIGIT is
architecture STRUCTURE of BENCH_COUNTER_3DIGIT is
COUNT : buffer STD_LOGIC_VECTOR(11 downto 0));
-- Configuration specifications
for CLK1 : CLOCK use entity WORK.CLOCK(BEHAVIOR);
for CUNTR3 : COUNTER_3DIGIT use entity
WORK.COUNTER_3DIGIT(ALGORITHM);
signal COUNT : STD_LOGIC_VECTOR(11 downto 0);
-- Component Instantiations using positional association
CLK1 : CLOCK generic map(HALF_PERIOD)
CUNTR3 : COUNTER_3DIGIT port map(CP, RESET, COUNT);
Analyze the bench and then simulate it. In the Command line of Synopsys VHDL Debugger (Vhdldbx) window, type:
You will get simulation result as shown in figure 30.
In this part, first a Dataflow model of an unsigned 4x4 bit Multiplier is given. Then an unsigned 8x8 bit Multiplier is designed using Algorithmic modeling style. In the end, a signed 8x8 bit Multiplier is designed.
A Dataflow description of an unsigned 4x4 bit Multiplier, using conditional concurrent signal assignment statements, is given below. Save it in file UNSIGNED_MULT4x4.vhd.
use IEEE.STD_LOGIC_UNSIGNED.all;
entity UNSIGNED_MULTIPLIER4x4 is
IN1, IN2 : in STD_LOGIC_VECTOR(3 downto 0);
PRODUCT : out STD_LOGIC_VECTOR(7 downto 0));
architecture DATA_FLOW of UNSIGNED_MULTIPLIER4x4 is
signal PP0, PP1, PP2, PP3 : STD_LOGIC_VECTOR(7 downto 0);
-- These will hold shifted partial products
constant ZERO : STD_LOGIC_VECTOR := "00000000";
PP0 <= ("0000" & IN1) when IN2(0) = '1' else
PP1 <= ("000" & IN1 & '0') when IN2(1) = '1' else
PP2 <= ("00" & IN1 & "00") when IN2(2) = '1' else
PP3 <= ('0' & IN1 & "000") when IN2(3) = '1' else
PRODUCT <= (PP3 + PP2) + (PP1 + PP0);
Analyze the code and then simulate it. After elaboration, you will get a design as shown in figure 31.
An Algorithmic description of an unsigned 8x8 bit Multiplier is given below. Save it in file UNSIGNED_MULT8x8.vhd.
use IEEE.STD_LOGIC_UNSIGNED.all;
entity UNSIGNED_MULTIPLIER8x8 is
IN1, IN2 : in STD_LOGIC_VECTOR(7 downto 0);
PRODUCT : out STD_LOGIC_VECTOR(15 downto 0));
architecture ALGORITHM of UNSIGNED_MULTIPLIER8x8 is
MULT_PROCESS : process(IN1, IN2)
variable SUM : STD_LOGIC_VECTOR(15 downto 0);
SHIFT_ADD_LOOP : for I in 7 downto 0 loop
SUM := SUM + ("00000000" & IN1);
-- Computation of partial products
SUM := SUM(14 downto 0) & '0';
Analyze the code and then simulate it. After elaboration, you will get a design as shown in figure 32.
An Algorithmic description of a signed 8x8 bit Multiplier is given below. Save it in file SIGNED_MULT8x8.vhd.
subtype INPUT_TYPE is INTEGER range -128 to 127;
Fig 32: Unsigned 8x8 bit Multiplier
subtype OUTPUT_TYPE is INTEGER range -32768 to 32767;
architecture ALGORITHM of MULTIPLIER8x8 is
wait until ( CP = '1' and CP'event);
wait until ( CP = '1' and CP'event);
Two subtypes INPUT_TYPE and OUTPUT_TYPE of predefined type INTEGER are declared in package PACK, which is declared and used in the above file.
Analyze the code and then elaborate it, you will get a design as shown in figure 33.
For the simulation of Signed 8x8 bit Multiplier, a test vector is given below save it in file
Fig 33: Signed 8x8 bit Multiplier
trace CP RESET IN1 IN2 PRODUCT
assign '0' /MULTIPLIER8x8/RESET
assign (-10) /MULTIPLIER8x8/IN2
assign '1' /MULTIPLIER8x8/RESET
assign '0' /MULTIPLIER8x8/RESET
assign '1' /MULTIPLIER8x8/RESET
assign (-128) /MULTIPLIER8x8/IN1
assign (-128) /MULTIPLIER8x8/IN2
assign '0' /MULTIPLIER8x8/RESET
assign '1' /MULTIPLIER8x8/RESET
assign '0' /MULTIPLIER8x8/RESET
assign '1' /MULTIPLIER8x8/RESET
Now simulate the Signed 8x8 Multiplier. Command line of Synopsys VHDL Debugger (Vhdldbx) window, type: