Using Structural Modeling in VHDL write the code for:
An Arithmetic Logic Unit (ALU) shown in the figure below. A (16-bit), B (16-bit), Opcode (3-bit), and Mode (1-bit) are the inputs; and ALUOut (16-bit) and Cout (1-bit) are the outputs of the design. A and B hold the values of the operands. Mode and Opcode together indicate the type of the operation performed by ALU.
The ALU components ARE:
-Arithmetic Unit that consists of one 16-bit adder, 16-bit subtractor, 16-bit incrementer, and 8-bit multiplier
-16-bit Logic Unit which performs the following operations: A and B, A or B, A nand B, A nor B, A xor B, A xnor B, Not A and Not B
-16-bit Shifter unit with A, B, Type and Direction as inputs and ShiftOut as output. The value of A should be shifted by the value specified in B. The “Direction” bit is used to determine whether to shift left (0) or right (1) and the “Type” bit is used to determine whether to Shift (0) or Rotate (1) the data
-16-bit 2-to-1 Multiplexer. The MUXes are utilized in order to route the outputs of functional units to ALU output
-Controller that is responsible for generating the required control signals for all functional blocks in your design. Select is used to select the functional unit for the corresponding operation in Arithmetic Unit. Sel1 and Sel2 are utilized as select signals of MUXes. Sel_Cout is used to control the cout of ALU, its value is “1” when ALU doing arithmetical operations; otherwise, it is “0”. Direction bit determines the direction of shift operation and Type bit determines the way of shifting. Opcode is used to select the type of operation and could be used as input to all three functional units.
Please Provide WAVEFORMS
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use ieee.NUMERIC_STD.all;
-----------------------------------------------
---------- ALU 8-bit VHDL ---------------------
-----------------------------------------------
entity ALU is
generic (
constant N: natural := 1 -- number of shifted or rotated bits
);
Port (
A, B : in STD_LOGIC_VECTOR(15 downto 0); -- 2 inputs 16-bit
ALU_Sel : in STD_LOGIC_VECTOR(2 downto 0); -- 1 input 3-bit for selecting function
ALU_SEL1 : in STD_LOGIC
X : out STD_LOGIC_VECTOR (15 downto 0));
ALU_type: in STD_LOGIC
ALU_Dir: in STD_LOGIC
ALU_Mode :in STD_LOGIC_VECTOR(1);
ALU_Type : in STD_LOGIC_VECTOR(
ALU_Out : out STD_LOGIC_VECTOR(15 downto 0); -- 1 output 16-bit
Cout : out std_logic -- Cout flag
);
end ALU;
architecture Behavioral of ALU is
signal ALU_Result : std_logic_vector (15 downto 0);
signal tmp: std_logic_vector (15 downto 0);
X <= A when (ALU_SEL1 = '1') else B; --mux
if ALU_Mode=1 then
begin
process(A,B,ALU_Sel)
begin
case(ALU_Sel) is
when "001" => -- Multiplication
ALU_Result <= std_logic_vector(to_unsigned((to_integer(unsigned(A)) * to_integer(unsigned(B))),8)) ;
when "001" => -- Addition
ALU_Result <= A + B ;
when "010" => -- Subtraction
ALU_Result <= A - B ;
when "011" => -- INCREMENT
ALU_Result <= A + 1;
when "100" => -- Logical shift left
ALU_Result <= std_logic_vector(unsigned(A) sll N);
when "101" => -- Logical shift right
ALU_Result <= std_logic_vector(unsigned(A) srl N);
when "110" => -- Rotate left
ALU_Result <= std_logic_vector(unsigned(A) rol N);
when "111" => -- Rotate right
ALU_Result <= std_logic_vector(unsigned(A) ror N);
else
begin
process(A,B,ALU_Sel)
begin
case(ALU_Sel) is
when "000" => -- Logical and
ALU_Result <= A nor B;
when "001" => -- Logical or
ALU_Result <= A nand B;
when "010" => -- Logical xor
ALU_Result <= A or B;
when "011" => -- Logical nor
ALU_Result <= A and B;
when "100" => -- Logical nand
ALU_Result <= A xor B;
when "101" => -- Logical xnor
ALU_Result <= A xnor B;
when "110" => -- Not A
ALU_Result <= NOT A;
when "111" => -- Not B
ALU_Result <= NOT B;
when others => ALU_Result <= A + B ;
end case;
end if;
end process;
ALU_Out <= ALU_Result; -- ALU out
if mode=0 then
Cout=0;
else
Cout=1;
end if;
if Dir=0 then
-- Left Shift
r_Unsigned_L <= shift_left(unsigned(r_Shift1), 1);
r_Signed_L <= shift_left(signed(r_Shift1), 1);
else
-- Right Shift
r_Unsigned_R <= shift_right(unsigned(r_Shift1), 2);
r_Signed_R <= shift_right(signed(r_Shift1), 2);
end if;
end architecture behave;
Testbench VHDL code for ALU:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use IEEE.std_logic_unsigned.all;
ENTITY tb_ALU IS
END tb_ALU;
ARCHITECTURE behavior OF tb_ALU IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT ALU
PORT(
A, B : in STD_LOGIC_VECTOR(15 downto 0); -- 2 inputs 16-bit
ALU_Sel : in STD_LOGIC_VECTOR(2 downto 0); -- 1 input 3-bit for selecting function
ALU_SEL1 : in STD_LOGIC
ALU_X : out STD_LOGIC_VECTOR (15 downto 0));
ALU_type: in STD_LOGIC
ALU_Dir: in STD_LOGIC
ALU_Mode :in STD_LOGIC_VECTOR(1);
ALU_Type : in STD_LOGIC_VECTOR(
ALU_Out : out STD_LOGIC_VECTOR(15 downto 0); -- 1 output 16-bit
Cout : out std_logic -- Cout flag
);
END COMPONENT;
--Inputs
signal A : std_logic_vector(7 downto 0) := (others => '0');
signal B : std_logic_vector(7 downto 0) := (others => '0');
signal ALU_Sel : std_logic_vector(2 downto 0) := (others => '0');
signal ALU_Sel1 : std_logic_vector := (others => '0');
signal ALU_Type:std_logic_vector:= others => '0');
signal ALU_Mode:std_logic_vector := others => '0');
signal ALU_dir:std_logic_vector(1)L others => '0');
--Outputs
signal ALU_Out : std_logic_vector(15 downto 0);
signal Cout : std_logic;
signal i:integer;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: ALU PORT MAP (
A => A,
B => B,
ALU_Sel => ALU_Sel,
ALU_Out => ALU_Out,
Cout => Cout,
ALU_Sel1 => ALU_Sel1,
ALU_type=ALU_type;
ALU_dir=ALU_dir;
ALU_Mode=ALU_Mode;
);
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
A <= x"0AAA";
B <= x"0235";
ALU_Sel <= x"0”;
ALU_Sel1 <=1;
ALU_dir<=1;
ALU_Mode<=1;
for i in 0 to 15 loop
ALU_Sel <= ALU_Sel + x"1";
wait for 100 ns;
end loop;
A <= x"05CA";
B <= x"0143";
ALU_Sel <= x"3”;
ALU_Sel1 <=0;
ALU_dir<=0;
ALU_Mode<=0;
wait;
end process;
END;
Using Structural Modeling in VHDL write the code for: An Arithmetic Logic Unit (ALU) shown in...
The Arithmetic Logic Unit The first topic for the project is to create an Arithmetic Logic Unit, using a structured approached with a Virtual Hardware Design Language such as Verilog. Mainly, the program is very close to a simulator for a programming calculator. An ALU typically has the following operations Math Functions: Add, Subtract, Multiply, Divide, Modulus Logic Functions: And, Or, XOR, Not, Nand, Nor, XNOR Error Modes: Divide by Zero, Overflow Support Functions: No Operation, Shift Left, Shift Right,...
Q2. Design a 8-bit ALU (Arithmetic Logic Unit) supporting the following instructions, Z and C values should be re-evaluated (updated) ifY changes Instruction type code[2:0] operations Logical Status update 001 010 011 100 101 110 ( Bitwise AND) Y = A & B: | Z (C is always 0) (bitwise OR) Y- A B; (bitwise XOR) Y-A B Z (Cis always 0) (negation) Y =-A; (Addition) Y A + B: (subtraction) Y = A-B: (Increment) Y-A+1 (decrement) Y-A-1 Z (C...
1. Implement this ALU in VHDL: a (7:0) b (7:0) Logic Unit Mux y (7:0) Arithmetic Unit sel (3) cin sel (3:0) Function Transfera Increment a Decrement a Transfer b Increment b Decrement b Add a and b Add a and b with carr Complement a Complement b AND OR NAND NOR XOR Se eration Unit 0001 0010 0011 0100 0101 01 10 | y <= a+b 0111 1000 | y<= 1001| y<= NOT b 1010 | y<= a AND...
This section gives you freedom to come up with your own solutions. An Arithmetic and Logic Unit (ALU) is a combinational circuit that performs logic and arithmetic micro-operations on a pair of 4-bit operands. The operations performed by an ALU are controlled by a set of function-select inputs. In this lab you will design a 4-bit ALU with 3 function-select inputs: Mode M, Select S1 and S0 inputs. The mode input M selects between a Logic (M=0) and Arithmetic (M=1)...
Derive the logic gates for a 2-bit Arithmetic Logic Unit (ALU) with four micro-operations: 1) Complete the table below by showing the select input bits and the necessary groupings. (5 points) Select Inputs Micro-Operation Description F = A-B-1 F = A + B +1 F = AVB F = ashl A Subtraction with borrow Addition with carry Logic OR Arithmetic shift left 2) Draw a detailed logic circuit of the ALU's arithmetic unit. (10 points) 3) Draw a detailed logic...
FIRST ACTIVITY: (100/100) . SIMPLE 4-BIT ARITHMETIC LOGIC UNIT (ALU): This circuit selects between arithmetic (absolute value, addition) and logical (XOR, AND) operations. Only one result (hexadecimal value) can be shown on the 7-segment display This is selected by the input sel (1..0) B A-BI A+B A xnor B A nand B Input EN: If EN-1result appears on the 7 segment display. If EN=0 → all LEDs in the 7 segment display are off Arithmetic operations: The 4-bit inputs A...
in VHDL Show synthesizable VHDL code for a register unit that performs operations shown below. The unit has a 3-bit mode (md) input, an asynchronous reset (rs) input, a 1-bit output control (oc) input, and an 8-bit bi-directional io bus. The internal register drives the io bus when oc is ‘I, and md is not “11 1". Use std-logic. md-000: does nothing md-001: right shift the register md-010: left shift the register md 011: up count, binary md-100: down count,...
Implement an arithmetic logic unit (ALU) using Verilog. Consider signed number arithmetic operation. The outputs of the ALU should be 1) Addition of two 8-bit numbers 2) A Zero Flag. It is set (it is 1 if the condition is met and 0 otherwise) if the result is zero. 3) A Negative Flag. It is set (it is 1 if the condition is met and 0 otherwise) if the result is less than 0. 4) An Overflow Flag. It is...
A 1-bit ALU is shown as in Figure 3. The circuit performs both arithmetic and logic operations. Determine the operations of the ALU for each combination of the two (2) operation bits , OP1 and OP2, and Binvert bit by completing Table 1. When do 1’s complement and 2’s complement operations are performed. (Please explain each step) Binvert carry in operation a 10 1 Result b 12 3 carry out Figure 3 Binvert Operation Operation- bit OP1 OP2 0...
WITHOUT using VHDL coding, Design the arithmetic unit by showing the truth tables, expressions and the logic circuits! How would I also implement the status flags (Z,C,V) in my circuit? S2 0 1 1. Design a 4-bit Arithmetic Logic Unit (ALU) according to the following specification. Follow the design shown during the lecture. Notice this table is different, though. A(0:3) B(0:3) S1 So Function (F) 0 0 A+B 0 0 A-B Z ALU 0 0 A-1 0 A +1 0...