Question

In: Electrical Engineering

Write a VHDL code for a 8x8 bit multiplier. use structural approach. write the design code...

Write a VHDL code for a 8x8 bit multiplier. use structural approach. write the design code and testbench. Use for-generate if possible

Solutions

Expert Solution

VHDL: Multiplier
library ieee;
use ieee.std_logic_1164.all;
--library synplify; -- required for synthesis
--use synplify.attributes.all; -- required for synthesis
entity Multiplier is
port (
A_in : in std_logic_vector(7 downto 0 );
B_in : in std_logic_vector(7 downto 0 );
clk : in std_logic;
reset : in std_logic;
START : in std_logic;
RC : out std_logic_vector(15 downto 0 );
STOP : out std_logic);
end Multiplier;
use work.all;
architecture rtl of Multiplier is
signal ADD_cmd : std_logic;
signal Add_out : std_logic_vector(7 downto 0 );
signal C_out : std_logic;
signal LOAD_cmd : std_logic;
signal LSB : std_logic;
signal RA : std_logic_vector(7 downto 0 );
signal RB : std_logic_vector(7 downto 0 );
signal SHIFT_cmd : std_logic;
component RCA
port (
RA : in std_logic_vector(7 downto 0 );
RB : in std_logic_vector(7 downto 0 );
C_out : out std_logic;
Add_out : out std_logic_vector(7 downto 0 )
);
end component;
component Controller
port (
reset : in std_logic;
clk : in std_logic;
START : in std_logic;
LSB : in std_logic;
ADD_cmd : out std_logic;
SHIFT_cmd : out std_logic;
LOAD_cmd : out std_logic;
STOP : out std_logic
);
end component;
component Multiplicand
port (
reset : in std_logic;
A_in : in std_logic_vector(7 downto 0 );
LOAD_cmd : in std_logic;
RA : out std_logic_vector(7 downto 0 )
);
end component;
component Multiplier_Result
port (
reset : in std_logic;
clk : in std_logic;
B_in : in std_logic_vector(7 downto 0 );
LOAD_cmd : in std_logic;
SHIFT_cmd : in std_logic;
ADD_cmd : in std_logic;
Add_out : in std_logic_vector(7 downto 0 );
C_out : in std_logic;
RC : out std_logic_vector(15 downto 0 );
LSB : out std_logic;
RB : out std_logic_vector(7 downto 0 )
);
end component;
begin
inst_RCA: RCA
port map (
RA => RA(7 downto 0),
RB => RB(7 downto 0),
C_out => C_out,
Add_out => Add_out(7 downto 0)
);
inst_Controller: Controller
port map (
reset => reset,
clk => clk,
START => START,
LSB => LSB,
ADD_cmd => ADD_cmd,
SHIFT_cmd => SHIFT_cmd,
LOAD_cmd => LOAD_cmd,
STOP => STOP
);
inst_Multiplicand: Multiplicand
port map (
reset => reset,
A_in => A_in(7 downto 0),
LOAD_cmd => LOAD_cmd,
RA => RA(7 downto 0)
);
inst_Multiplier_Result: Multiplier_Result
port map (
reset => reset,
clk => clk,
B_in => B_in(7 downto 0),
LOAD_cmd => LOAD_cmd,
SHIFT_cmd => SHIFT_cmd,
ADD_cmd => ADD_cmd,
Add_out => Add_out(7 downto 0),
C_out => C_out,
RC => RC(15 downto 0),
LSB => LSB,
RB => RB(7 downto 0)
);
end rtl;

VHDL: TestBench

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use std.textio.all; --required for file I/O
use ieee.std_logic_textio.all; --required for file I/O
entity TESTBENCH is
end TESTBENCH;
architecture BEHAVIORAL of TESTBENCH is
component Multiplier
port (
A_in : in std_logic_vector(7 downto 0 );
B_in : in std_logic_vector(7 downto 0 );
clk : in std_logic;
RC : out std_logic_vector(15 downto 0 );
reset : in std_logic;
START : in std_logic;
STOP : out std_logic
);
end component;
signal A_in_TB, B_in_TB : std_logic_vector(7 downto 0 );
signal clk_TB, reset_TB, START_TB : std_logic;
signal STOP_TB : std_logic;
signal RC_TB: std_logic_vector(15 downto 0);
begin
-- instantiate the Device Under Test
inst_DUT : Multiplier
port map (
A_in => A_in_TB,
B_in => B_in_TB,
clk => clk_TB,
reset => reset_TB,
RC => RC_TB,
START => START_TB,
STOP => STOP_TB);
-- Generate clock stimulus
STIMULUS_CLK : process
begin
clk_TB <= '0';
wait for 10 ns;
clk_TB <= '1';
wait for 10 ns;
end process STIMULUS_CLK;
-- Generate reset stimulus
STIMULUS_RST : process
begin
reset_TB <= '0';
wait for 50 ns;
reset_TB <= '1';
wait;
end process STIMULUS_RST;
-- Generate multiplication requests
STIMULUS_START : process
file logFile : text is out "bus_log.txt"; -- set output file name
variable L: line;
variable A_temp, B_temp, i : integer;
begin
write(L, string'("A B Result")); -- include heading in file
writeline(logFile,L);
A_temp := 0; -- start A at 0
B_temp := 255; -- start B at 255
i := 1;
for i in 1 to 256 loop
A_in_TB <= STD_LOGIC_VECTOR(to_unsigned(A_temp,8));
B_in_TB <= STD_LOGIC_VECTOR(to_unsigned(B_temp,8));
START_TB <= '0';
wait for 100 ns;
START_TB <= '1'; -- request the multiplier to start
wait for 100 ns;
START_TB <= '0';
wait until STOP_TB = '1'; -- wait for the multiplier to finish
hwrite(L, A_in_TB); -- insert hex value of A in file
write(L, string'(" "));
hwrite(L, B_in_TB); -- insert hex value of B in file
write(L, string'(" "));
hwrite(L, RC_TB); -- insert hex value of result in file
writeline(logFile,L);
A_temp := A_temp + 1; -- increment value of A (Multiplicand)
B_temp := B_temp - 1; -- decrement value of B (Multiplier)
end loop;
wait;
end process STIMULUS_START;
end BEHAVIORAL;


Related Solutions

Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
write the code for 16-bit ALU using vivado. Approach : A hierarchical design approach for 16-bit...
write the code for 16-bit ALU using vivado. Approach : A hierarchical design approach for 16-bit ALU using a Full Adders (16-bit), Multiplier (16-bit), Full Subtractor (16-bit), and shift left A register. include test bench. S0 S1 Alu-operation 0 0 addition 0 1 subtraction 1 0 multiplication 1 1 shift right
Write in verilog, code to implement a 6 bit multiplier. Cascade a 1 bit multiplier to...
Write in verilog, code to implement a 6 bit multiplier. Cascade a 1 bit multiplier to implement this.
4. Use generate statement to write VHDL code for a 16 bit adder assuming the only...
4. Use generate statement to write VHDL code for a 16 bit adder assuming the only available building block is a full adder. Thank
Write VHDL code (behavior model) to implement a 4-bit modulo-9 counter and simulate your VHDL code...
Write VHDL code (behavior model) to implement a 4-bit modulo-9 counter and simulate your VHDL code of 4-bit modulo-9 counter in ModelSim, and capture the screenshot of your simulated waveform. Assume clock period Tclk=100ns, initially, the counter is reset to Q3Q2Q1Q0=0000 you need to simulate a complete counting cycle plus one more additional clock period after it is reset to “0000” state.
using verilog to design a 8x8 unsigned multiplier(with testbench) utilizing a 2x8 multiplier as a building...
using verilog to design a 8x8 unsigned multiplier(with testbench) utilizing a 2x8 multiplier as a building block here is the testbench and code for 2x8: module cpp_mult(mplr,mcand, prod); input [1:0] mplr; input [7:0] mcand; output [9:0] prod; wire [9:0] mcand1; wire [9:0] mcand2; wire [9:0] mcand3; assign mcand0 = 10'b00000000; assign prod = (mplr==2'b00)?mcand0 :        ((mplr==2'b01)?{2'b00,mcand[7:0]}:        ((mplr==2'b10)?{1'b0,mcand[7:0],1'b0}:        ((mplr==2'b11)?{2'b00,mcand[7:0]}+{1'b0,mcand[7:0],1'b0}:8'hxx))); endmodule ____________________________________________________________________ module cpp_mult_tb(); reg [1:0] mplr; reg [7:0] mcand; wire [9:0] prod; // Instantiate the...
I am trying to write the code for an 8 bit adder in VHDL so that...
I am trying to write the code for an 8 bit adder in VHDL so that I can program it onto my Elbert V2 Spartan 3A FPGA Development Board, but I keep getting errors. Any ideas what I am doing wrong? library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity adder8bit is Port ( a : in STD_LOGIC_VECTOR(7 downto 0); b : in STD_LOGIC_VECTOR(7 downto 0); cin : in STD_LOGIC; o : out STD_LOGIC_VECTOR(7 downto 0); cout : out STD_LOGIC); end adder8bit; architecture Behavioral...
Write a VHDL code to implement a Finite State Machine that with an 8 bit sequence...
Write a VHDL code to implement a Finite State Machine that with an 8 bit sequence input (can be any sequence, but lets say it is 11001000), determine how many states there are as well; so if the input sequence is correct it will show the number 1 in a 7 segment display, otherwise it will be 0 in the same 7 segment display. If the input sequence is incorrect, start from the beginning.
Write a VHDL code for a 4-bit comparator which takes two 4-bit input values and (0.5)...
Write a VHDL code for a 4-bit comparator which takes two 4-bit input values and (0.5) determines whether the numbers are equal. 2. 2. Write a structural VHDL code to implement the circuit of Fig. 2, using the components (0.5) developed in 1.3 and 2.1. 2. 3. Write a VHDL test bench for the above and verify by simulation. (0.5) 2. 4. Implement the design in an FPGA (Note: You may need a `clock manager' to reduce (1.0) the clock...
Using Behavorial VHDL, design a 4-bit up/down counter.
Using Behavorial VHDL, design a 4-bit up/down counter.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT