12/8/2022 0 Comments Vhdl program for 2 bit aluIf you think about those other expressions for a while you will see that it uses the same logic that we use when comparing numbers by ourselfs. Simply check if all bits are the same for equality! So, thinking about A as A3A2A1A0 and B as B3B2B1B0 and the AND Operations for each Bit as X3, X2, X1, X0 we then have the following Expressions: To make it more interesting in the final implementation and also easier to code this Component, we will create a 4-bit comparator! We will simply use a Dataflow VHDL implementation using the Boolean Expressions that are represent in Wikipedia. The negative value -1 will actually be the greatest positive value that we can have and so 11111111111111111 or 11111111. The values that I will use will be 0 that means equal, 1 that means greater and -1 that means less. In the final implementation of the ALU we will than use this information and use help signals that will give specific output values depending on what the comparison result is. So, this way only one of the Outputs will be 1 and the other will be 0 every time. The Inputs will be the number a and b that we want to compare and each output will work like a boolean and will be 0 or 1 depending on if we are equal, less or greater. Let's say that we will have 2 inputs and 3 outputs in our Circuit. The comparator is a little more complicated and the output will depend on what we want to do! We already said last time that we want to know if a is equal, less or greater than b. So, our Code for the Multiplier will look like this: library ieee use ieee.std_logic_1164.all use ieee.numeric_std.all entity multiplier_numeric is port( src1, src2: in std_logic_vector(7 downto 0) result: out std_logic_vector(15 downto 0) ) end multiplier_numeric architecture arch of multiplier_numeric is begin result <= std_logic_vector(unsigned(src1) * unsigned(src2)) end arch Īs you can see we simply multiply the converted to unsigned inputs and then convert the output to an std_logic_vector! When multiplying two 8-bit numbers our result can be a max of 11111111 x 11111111 = 1111111000000001 that is a 16-bit number and so we will have a 16-bit result/output! A Multiplier as an Circuit contains many Adders, but for sake of simplicity I will just use the numeric_std package again, the same way we did it in the incrementor and decrementor components! The Multiplier is the Component that makes the ALU have a 16-bit result. So, without further do let's get started! This time we will get into the Multiplier and Comparator Circuits/Components. Hello it's a me again! Today we continue with part 2 of the VHDL Simple ALU Circuit Series.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |