Showing posts with label to. Show all posts
Showing posts with label to. Show all posts

How to design an ALU in VHDL

| 0 comments |
Arithmetic Logic Unit is an important part of the CPU or processor. It performs logic operation such as or, and, nand etc and arithmetic functions such as addition, subtraction etc. These operations are performed depending upon the opcode code that is fed into it and produces output depending upon the opcode. Here we show how to design an ALU in VHDL and verify the output. The VHDL code is provided and the design can be simulated in any VHDL Software.

The design of ALU in VHDL is fairly simple. You have to decide what logic and arithmetic operation you wish to the ALU to perform. And you have to give each function an opcode which is some 4 bit code say.

Let x and y be 8 bit input, c be 1 bit carry in to the ALU and z be the output which is also 8 bits.

Then the VHDL code for the ALU is pretty straight forward. The code is below.

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity alu is
    port(x,y: in std_logic_vector(7 downto 0);
    c : in std_logic;
    opcode : in std_logic_vector(3 downto 0);
    z : out std_logic_vector(7 downto 0)   
    );
end alu;

architecture arch of alu is

begin

    with opcode select
   
    -- logic unit
    z <= x when "0000",
    not x when "0001",
    y when "0010",
    not y when "0011",
    x and y when "0100",
    x nand y when "0101",
    x or y when "0110",
    x nor y when "0111",
   
    -- arithmetic unit
   
    x+1 when "1000",
    y+1 when "1001",
    x+y when "1010",
    x-y when "1011",
    0-x+y when "1100",
    0-x-y when "1101",
    x+y-1 when "1110",
    x+y+c when others;
   
end arch;

In the above VHDL code, the when statements was used which is a concurrent statement. Notice that in the code, + and - operators were used in the arithmetic section. Because these operators were used the VHDL library std_logic_unsigned was used. If they were not used then the operator cannot act on the std_logic_vector inputs x and y.

The block diagram and the simulation results are now shown.

ALU VHDL block diagram

Now the simulation results are shown for each of the opcodes.

Logic operation:

logic operation

Arithmetic operation:

arithmetic operation

These simulator used was the active hdl vhdl software.
Read More..

Win to Flash Free Download

| 0 comments |

                                            WinToFlash


What is WinToFlash

There may come a day that optical drives are as hard to find as 5.25 floppy drives are today.
WinToFlash starts a wizard that will help pull over the contents of a windows installation CD or DVD and prep the USB drive to become a bootable replacement for the optical drive. It can also do this with your LiveCD.
You dont have to worry about scratches on the disc or misplacing your original media discs once you transfer their contents to the flash drive. The optical drive is quickly becoming a thing of the past, especially in office environments, as media is shifted to the cloud

Backup, create image of your bootable USB drive!

We recommend to try our new software, Bootable USB Replicator. With WinToFlash, this application will be very usefull! Its free of charge too.
Its not a problem for our Bootable USB Replicator to create an image of your USB drive. It works like any CD imager.
Also, your image supports all boot features of the original USB drive. Its easly than even a CD image because Bootable USB Replicator supports self-extraction, like WinRAR. All you need is to send only one .exe file to your friend and he can "burn" it instantly, with no other software, in one single click!




Read More..