261
Unit 20 Solutions
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mult20_11 is
Port (CLK, S: in std_logic;
architecture Behavioral of mult20_11 is
signal State, NextState: integer range 0 to 4;
signal B: std_logic_vector (3 downto 0); — Multiplier counter
signal A: std_logic_vector (3 downto 0); — Multiplicand register
signal PU: std_logic_vector (3 downto 0); — Upper half of product register
begin
BZ <= ‘1’ when B = “0000” else ‘0’;
muxout <= PU when MS = ‘1’ else PL;
andarray <= A when EA = ‘1’ and IA = ‘0’ else
not A when EA = ‘1’ and IA = ‘1’ else
“1111″ when EA = ‘0’ and IA = ‘1’ else “0000”;
addout <= (‘0’ & muxout) + (‘0’ & andarray) + (“0000” & C); — adder output is 5 bits
Product <= PU & PL; — including carry
process (S, State, BZ)
begin
CP <= ‘0’; LA <= ‘0’; DB <= ‘0’; IB <= ‘0’; MS <= ‘0’; CC <= ‘0’; — control signals are ‘0’
SC <= ‘0’; EA <= ‘0’; IA <= ‘0’; LPU <= ‘0’; LPL <= ‘0’; D <= ‘0’; — by default
20.11 (a)