Forum Discussion
9 Replies
- Altera_Forum
Honored Contributor
No we don't code in sleep but we get algorithms only. I won't do that for your homework but just give you some tips:
declare two 6n inputs as unsigned. declare outut as 12b then say: output <= in1*in2; even <= not output(0); -- if 0 it is even finally: done <= '1'; - Altera_Forum
Honored Contributor
library IEEE;
use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_UNSIGNED.all; entity UNSIGNED_MULTIPLIER6x6 is port ( inputA, inputB : in STD_LOGIC_VECTOR(5 downto 0); multResult: out STD_LOGIC_VECTOR(11 downto 0)); isEven: out STD_LOGIC_VECTOR(1 downto 0); end UNSIGNED_MULTIPLIER6x6; architecture DATA_FLOW of UNSIGNED_MULTIPLIER6x6 is multResult <= inputA*inputB; if multResult0=1, then isEven<='0' else isEven<= '1'; end if; end process; end DATA_FLOW ; - Altera_Forum
Honored Contributor
That's overkill (not sure it even works). Kaz already gave you the answer on a silver platter. VHDL and verilog you can multiply two signals together to get an output. The multiplier result width is the sum of the two input widths. For example if you multiply an 8-bit number by a 4-bit number you should ensure the wire/register that holds the result is 8+4 = 12 bits wide. Kaz also told you how to detect if a result is odd or even... if you don't believe him write some numbers in base 2 and look at the least significant bit.
- Altera_Forum
Honored Contributor
Just googled K.I.S.S and was impressed because I was looking for that concept all my life, thanks for the tip. I really feel feverish when I see any spaghetti logic and
long strings of code. I know it will go wrong. So keep it simple and use others well proven work called various names: functions, ip, cores, +, -, * ...etc. We all build blocks from other blocks and it is waste of time to rebuild what is right on your desk. - Altera_Forum
Honored Contributor
library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_UNSIGNED.all; entity UNSIGNED_MULTIPLIER6x6 is port ( inputA, inputB : in unsigned(5 downto 0); multResult: out unsigned(11 downto 0); isEven: out STD_LOGIC ); end entity; architecture rtl of UNSIGNED_MULTIPLIER6x6 is signal Result: unsigned(11 downto 0); begin Result <= inputA*inputB; multResult <= Result; isEven <= not Result(0); end RTL ; - Altera_Forum
Honored Contributor
excelent - you gave him some errors to find himself.
- Altera_Forum
Honored Contributor
Thanks Tricky, about the only error I realised so far is that I called the architecture rtl yet there isn't a single register.
- Altera_Forum
Honored Contributor
and the fact you forgot the numeric_std library.
- Altera_Forum
Honored Contributor
--- Quote Start --- and the fact you forgot the numeric_std library. --- Quote End --- Indeed I tried to put it but wasn't sure of syntax: [std_numeric Vs numeric_std] so I gave up to synopsis library.