VHDL writing warning - vhdl

1.8-bit multiplier
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity M8 is
Port ( M1 : in STD_LOGIC_vector(7 downto 0);
M2 : in STD_LOGIC_vector(7 downto 0);
Mout : out STD_LOGIC_vector(15 downto 0)
);
end M8;
architecture Behavioral of M8 is
begin
process(M1,M2)
variable A1: std_logic_vector(17 downto 0);
begin
A1(17 downto 0) := "0000000000" & M1(7 downto 0);
for N in 1 to 9 loop
if A1(0)='1' then
A1(17 downto 9) := A1(17 downto 9) + '0'+ M2(7 downto 0);
end if;
A1(17 downto 0) := '0' & A1(17 downto 1);
end loop;
Mout<= A1(15 downto 0);
end process;
end Behavioral;
2.32-bit multiplier
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity M32 is
Port ( M1 : in STD_LOGIC_vector(31 downto 0);
M2 : in STD_LOGIC_vector(31 downto 0);
Mout : out STD_LOGIC_vector(63 downto 0)
);
end M32;
architecture Behavioral of M32 is
begin
process(M1,M2)
variable A1: std_logic_vector(65 downto 0);
begin
A1(65 downto 0) := "0000000000000000000000000000000000" & M1(31 downto 0);
for N in 1 to 33 loop
if A1(0)='1' then
A1(65 downto 33) := A1(65 downto 33) + '0'+ M2(31 downto 0);
end if;
A1(65 downto 0) := '0' & A1(65 downto 1);
end loop;
Mout<= A1(63 downto 0);
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity MM32All is
port( MMM1: in std_logic_vector(31 downto 0);
MMM2: in std_logic_vector(31 downto 0);
MMMout: out std_logic_vector(63 downto 0)
);
end MM32All;
architecture Behavioral of MM32All is
component M32 port(MM1 : in std_logic_vector(31 downto 0);
MM2 : in std_logic_vector(7 downto 0);
MMout:out std_logic_vector(39 downto 0)
);
end component;
signal MMb: std_logic_vector(31 downto 0);
signal MMa: std_logic_vector(31 downto 0);
signal MMo1: std_logic_vector(39 downto 0);
signal MMo2: std_logic_vector(39 downto 0);
signal MMo3: std_logic_vector(39 downto 0);
signal MMo4: std_logic_vector(39 downto 0);
signal MMout1: std_logic_vector(63 downto 0);
begin
Ma4: M32 port map (MM1=> MMb, MM2=> MMa(31 downto 24), MMout=> MMo4);
Ma3: M32 port map (MM1=> MMb, MM2=> MMa(23 downto 16), MMout=> MMo3);
Ma2: M32 port map (MM1=> MMb, MM2=> MMa(15 downto 8) , MMout=> MMo2);
Ma1: M32 port map (MM1=> MMb, MM2=> MMa(7 downto 0 ) , MMout=> MMo1);
MMout1 <= ("000000000000000000000000" & MMo1) + ("0000000000000000" & MMo2 & "00000000")
+ ("00000000" & MMo3 & "0000000000000000" ) + ( MMo4 & "000000000000000000000000" );
MMb <= MMM1;
MMa <= MMM2;
MMMout <= MMout1;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity M32 is
port(MM1 : in std_logic_vector(31 downto 0);
MM2 : in std_logic_vector(7 downto 0);
MMout:out std_logic_vector(39 downto 0)
);
end M32;
architecture Behavioral of M32 is
component M8 Port ( M1 : in STD_LOGIC_vector(7 downto 0);
M2 : in STD_LOGIC_vector(7 downto 0);
Mout : out STD_LOGIC_vector(15 downto 0)
);
end component;
component M8b Port ( M1 : in STD_LOGIC_vector(7 downto 0);
M2 : in STD_LOGIC_vector(7 downto 0);
Mout : out STD_LOGIC_vector(15 downto 0)
);
end component;
component M8c Port ( M1 : in STD_LOGIC_vector(7 downto 0);
M2 : in STD_LOGIC_vector(7 downto 0);
Mout : out STD_LOGIC_vector(15 downto 0)
);
end component;
component M8d Port ( M1 : in STD_LOGIC_vector(7 downto 0);
M2 : in STD_LOGIC_vector(7 downto 0);
Mout : out STD_LOGIC_vector(15 downto 0)
);
end component;
signal internalMM1: std_logic_vector(31 downto 0);
signal internalMM2: std_logic_vector(7 downto 0);
signal internalMMout: std_logic_vector(39 downto 0);
signal M8dout:std_logic_vector(15 downto 0);
signal M8cout:std_logic_vector(15 downto 0);
signal M8bout:std_logic_vector(15 downto 0);
signal M8out:std_logic_vector(15 downto 0);
begin
--addres: for N in 0 to 3 generate
FulMd32: M8d port map( M1=> internalMM1(31 downto 24), M2=> internalMM2, Mout=> M8dout);
FulMb32: M8b port map( M1=> internalMM1(23 downto 16), M2=> internalMM2, Mout=> M8cout);
FulMc32: M8c port map( M1=> internalMM1(15 downto 8), M2=> internalMM2, Mout=> M8bout);
FulM32: M8 port map( M1=> internalMM1(7 downto 0), M2=> internalMM2, Mout=> M8out);
internalMMout<=("000000000000000000000000" & M8out)
+ ("0000000000000000" & M8bout & "00000000") + ("00000000" & M8cout & "0000000000000000")
+ (M8dout & "000000000000000000000000");
internalMM1 <= MM1;
internalMM2 <= MM2;
MMout <= internalMMout;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity ALU is
port( A :in std_logic_vector(31 downto 0);
B :in std_logic_vector(31 downto 0);
SS:in std_logic_vector(2 downto 0);
C :out std_logic_vector(63 downto 0);
D :out std_logic_vector(31 downto 0);
La,Sm,Eq: out std_logic);
end ALU;
architecture Behavioral of ALU is
Component M32 is port (M1 : in STD_LOGIC_vector(31 downto 0);
M2 : in STD_LOGIC_vector(31 downto 0);
Mout : out STD_LOGIC_vector(63 downto 0));
end component;
Component SUB32 is port(A : in STD_LOGIC_vector(31 downto 0);
B : in STD_LOGIC_vector(31 downto 0);
OFL:out std_logic;
S : out STD_LOGIC_vector(31 downto 0));
end component;
Component adder32 is Port(A : in STD_LOGIC_vector(31 downto 0);
B : in STD_LOGIC_vector(31 downto 0);
Cin : in STD_LOGIC;
Cout : out STD_LOGIC;
S : out STD_LOGIC_vector(31 downto 0));
end component;
signal aM1,aM2,bM1,bM2,cM1,cM2,cMout,bMout : STD_LOGIC_vector(31 downto 0);
signal aMout: STD_LOGIC_vector(63 downto 0);
signal Overflow: std_logic;
begin
A1: M32 port map( M1=> aM1, M2=>aM2, Mout=>aMout);
A2: SUB32 port map(A=> bM1, B=> bM2, S=>bMout, OFL=>Overflow);
A3: adder32 port map(A=> cM1, B=> cM2, Cout=>open,S=>cMout,Cin=>'0');
process(SS,A,B,Overflow,aMout,bMout,CMout)
begin
Case SS is
When "000"=> aM1<=A;
aM2<=B;
C<=aMout;
When "001" => if Overflow='1' then
bM1<=A;
bM2<=B;
D<=bMout;
else
D<="00000000000000000000000000000000";
end if;
when "010" => cM1<=A;
cM2<=B;
D<= cMout;
when "011" => if (A > B) then
La<='1';
Sm<='0';
Eq<='0';
else if (A<B) then
La<='0';
Sm<='1';
Eq<='0';
else
La<='0';
Sm<='0';
Eq<='1';
end if;
end if;
when "100" =>
D <= (A and B);
when "101" =>
D <= (A or B);
when "110" =>
D <= (A xor B);
When others=> C<="ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
D<="ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
end case;
end process;
end Behavioral;
32-bit ALU
Based on the Device utilization summary, two designs of multiplier have very similar area utilization. 32-bit multiplier by 8-bit multiplier use about 5% more logic unit than single 32-bit multiplier. The number of used route thru used for 32-bit multiplier by 8-bit multiplier is 238% of single 32-bit multiplier. Even use different design, their performance are the same.

You have very obscure way of doing multiplier as scary_jeff indicates. Most likely the synthesis tool gets confused about that.
Instead of
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
Please have
use ieee.numeric_std.all;
and instead of
std_logic_vector(n-1 downto 0)
use
signed(n-1 downto 0);
Then you can just multiply with *.
Off topic, but instead of
D<="00000000000000000000000000000000";
you can use
D <= (others => '0');

Related

Adding 12 vectors together only to have all inputs and outputs undefined in simulation

I am trying to add the amount of attendee's from 12 different sections (A-L) together to get an overall attendance. Each section's input is a 9-bit vector which all gets added to form a 14-bit vector. However when I try to implement a testbench, I have all inputs and outputs as undefined and no waveforms whatsoever. Any guidance would be appreciated!
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.all;
entity overall_attendance_data is
Port (OUTPUTDATA_A : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_B : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_C : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_D : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_E : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_F : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_G : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_H : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_I : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_J : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_K : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_L : in STD_LOGIC_VECTOR(8 downto 0);
OVERALL_ATTENDANCE_DATA_OUT : out STD_LOGIC_VECTOR(13 downto 0));
end overall_attendance_data;
architecture Behavioral of overall_attendance_data is
signal OVERALL_ATTENDANCE : unsigned(13 downto 0);
begin
-- '0' & prevents overflow
OVERALL_ATTENDANCE <= ('0' & unsigned(OUTPUTDATA_A)) + ('0' & unsigned(OUTPUTDATA_B)) + ('0' & unsigned(OUTPUTDATA_C)) + ('0' & unsigned(OUTPUTDATA_D)) + ('0' & unsigned(OUTPUTDATA_E)) + ('0' & unsigned(OUTPUTDATA_F)) + ('0' & unsigned(OUTPUTDATA_G)) + ('0' & unsigned(OUTPUTDATA_H)) + ('0' & unsigned(OUTPUTDATA_I)) + ('0' & unsigned(OUTPUTDATA_J)) + ('0' & unsigned(OUTPUTDATA_K)) + ('0' & unsigned(OUTPUTDATA_L));
OVERALL_ATTENDANCE_DATA_OUT <= std_logic_vector(OVERALL_ATTENDANCE);
end Behavioral;
Testbench viewed below, testing all inputs equal to 1.
library IEEE;
use IEEE.Std_logic_1164.all;
use IEEE.Numeric_Std.all;
entity OVERALL_ATTENDANCE_DATA_tb is
end;
architecture bench of OVERALL_ATTENDANCE_DATA_tb is
component overall_attendance_data
Port (OUTPUTDATA_A : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_B : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_C : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_D : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_E : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_F : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_G : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_H : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_I : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_J : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_K : in STD_LOGIC_VECTOR(8 downto 0);
OUTPUTDATA_L : in STD_LOGIC_VECTOR(8 downto 0);
OVERALL_ATTENDANCE_DATA_OUT : out STD_LOGIC_VECTOR(13 downto 0));
end component;
signal OUTPUTDATA_A: STD_LOGIC_VECTOR(8 downto 0);
signal OUTPUTDATA_B: STD_LOGIC_VECTOR(8 downto 0);
signal OUTPUTDATA_C: STD_LOGIC_VECTOR(8 downto 0);
signal OUTPUTDATA_D: STD_LOGIC_VECTOR(8 downto 0);
signal OUTPUTDATA_E: STD_LOGIC_VECTOR(8 downto 0);
signal OUTPUTDATA_F: STD_LOGIC_VECTOR(8 downto 0);
signal OUTPUTDATA_G: STD_LOGIC_VECTOR(8 downto 0);
signal OUTPUTDATA_H: STD_LOGIC_VECTOR(8 downto 0);
signal OUTPUTDATA_I: STD_LOGIC_VECTOR(8 downto 0);
signal OUTPUTDATA_J: STD_LOGIC_VECTOR(8 downto 0);
signal OUTPUTDATA_K: STD_LOGIC_VECTOR(8 downto 0);
signal OUTPUTDATA_L: STD_LOGIC_VECTOR(8 downto 0);
signal OVERALL_ATTENDANCE_DATA_OUT: STD_LOGIC_VECTOR(13 downto 0);
begin
stimulus: process
begin
OUTPUTDATA_A <= "000000001"; OUTPUTDATA_B <= "000000001"; OUTPUTDATA_C <= "000000001"; OUTPUTDATA_D <= "000000001"; OUTPUTDATA_E <= "000000001"; OUTPUTDATA_F <= "000000001"; OUTPUTDATA_G <= "000000001"; OUTPUTDATA_H <= "000000001"; OUTPUTDATA_I <= "000000001"; OUTPUTDATA_J <= "000000001"; OUTPUTDATA_K <= "000000001"; OUTPUTDATA_L <= "000000001"; wait for 100ns;
end process;
dut: overall_attendance_data port map ( OUTPUTDATA_A => OUTPUTDATA_A,
OUTPUTDATA_B => OUTPUTDATA_B,
OUTPUTDATA_C => OUTPUTDATA_C,
OUTPUTDATA_D => OUTPUTDATA_D,
OUTPUTDATA_E => OUTPUTDATA_E,
OUTPUTDATA_F => OUTPUTDATA_F,
OUTPUTDATA_G => OUTPUTDATA_G,
OUTPUTDATA_H => OUTPUTDATA_H,
OUTPUTDATA_I => OUTPUTDATA_I,
OUTPUTDATA_J => OUTPUTDATA_J,
OUTPUTDATA_K => OUTPUTDATA_K,
OUTPUTDATA_L => OUTPUTDATA_L,
OVERALL_ATTENDANCE_DATA_OUT => OVERALL_ATTENDANCE_DATA_OUT );
end;
Simulation results from testbench

VHDL: Using multiple If statement instead of for Loop in VHDL

The following code contains a vhdl file and a test bench for it.
Main file
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity lici is
port(PT_MSB : in std_logic_vector(31 downto 0);
PT_LSB: in std_logic_vector( 31 downto 0);
--key: in std_logic_vector(127 downto 0);
RK1: in std_logic_vector(31 downto 0);
RK2: in std_logic_vector(31 downto 0);
clk: in std_logic;
CT_LSB: out std_logic_vector(31 downto 0);
CT_MSB: out std_logic_vector(31 downto 0);
check: out std_logic_vector(31 downto 0)
);
end lici;
architecture beh of lici is
type S_BOX is array(15 downto 0)of std_logic_vector(3 downto 0);
signal sub: S_BOX:=(0=>x"3",1=>x"F",2=>x"E",3=>x"1",4=>x"0",5=>x"A",6=>x"5",7=>x"8",8=>x"c",9=>x"4",10=>x"B",11=>x"2",12=>x"9",13=>x"7",14=>x"6",15=>x"D");
begin
process(clk)
Variable var_PT_MSB : std_logic_vector(31 downto 0);
variable var_PT_LSB : std_logic_vector( 31 downto 0);
variable var_EN_PT_MSB: std_logic_vector(31 downto 0);
variable var_XOR_RK_SHR7: std_logic_vector(31 downto 0);
variable var_XOR_SHL3: std_logic_vector(31 downto 0);
variable var_CT_LSB: std_logic_vector(31 downto 0);
variable S_data: std_logic_vector(3 downto 0);
variable outside_counter: natural:= 0;
variable i: natural:= 1;
begin
var_PT_MSB:= PT_MSB;
var_PT_LSB:= PT_LSB;
if(outside_counter< 31) then
if(clk'event and clk='1' and i <= 8) then
S_data:= (var_PT_MSB(31 downto 28) and x"F");
case S_data is
when x"0"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(0);
when x"1"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(1);
when x"2"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(2);
when x"3"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(3);
when x"4"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(4);
when x"5"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(5);
when x"6"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(6);
when x"7"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(7);
when x"8"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(8);
when x"9"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(9);
when x"A"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(10);
when x"B"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(11);
when x"C"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(12);
when x"D"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(13);
when x"E"=> var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(14);
when others=>var_EN_PT_MSB(35-(i*4) downto 32-(i*4)):=sub(15);
end case;
var_PT_MSB:= std_logic_vector(shift_left(unsigned(var_PT_MSB),4));
i:=i+1;
end if;
var_XOR_SHL3:= var_EN_PT_MSB xor RK1 xor var_PT_LSB;
var_XOR_SHL3:= std_logic_vector(rotate_left(unsigned(var_XOR_SHL3),3));
var_XOR_RK_SHR7:= var_EN_PT_MSB xor RK2 xor var_XOR_SHL3;
CT_LSB<= std_logic_vector(rotate_right(unsigned(var_XOR_RK_SHR7),7));
var_CT_LSB:= std_logic_vector(rotate_right(unsigned(var_XOR_RK_SHR7),7));
CT_MSB<= var_XOR_SHL3;
var_PT_MSB:= var_XOR_SHL3;
var_PT_LSB:= var_CT_LSB;
check<= var_EN_PT_MSB;
outside_counter:= outside_counter+1;
end if;
end process;
end beh;
--------------------------------------------------------------------------
This is the test bench for it
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity lici_tb is
end lici_tb;
architecture behav of lici_tb is
component lici is
port(PT_MSB : in std_logic_vector(31 downto 0);
PT_LSB: in std_logic_vector( 31 downto 0);
RK1: in std_logic_vector(31 downto 0);
RK2: in std_logic_vector(31 downto 0);
clk: in std_logic;
CT_LSB: out std_logic_vector (31 downto 0);
CT_MSB: out std_logic_vector(31 downto 0);
check: out std_logic_vector(31 downto 0)
);
end component;
signal clk :std_logic := '0';
signal PT_MSB:std_logic_vector(31 downto 0):=x"ABCDEF01";
signal PT_LSB:std_logic_vector( 31 downto 0):=x"23456789";
signal RK1:std_logic_vector(31 downto 0):=x"00000010";
signal RK2:std_logic_vector(31 downto 0):= x"00000001";
signal CT_LSB:std_logic_vector(31 downto 0);
signal CT_MSB: std_logic_vector(31 downto 0);
signal check: std_logic_vector(31 downto 0);
constant CLK_PERIOD : time := 10 ns;
begin
uut : lici port map (
PT_MSB => PT_MSB,
PT_LSB=>PT_LSB,
RK1=>RK1,
RK2=> RK2,
clk => clk,
CT_LSB=>CT_LSB,
CT_MSB => CT_MSB,
check=>check
);
Clk_process :process
begin
clk <= '0';
wait for CLK_PERIOD/2; --for half of clock period clk stays at '0'.
clk <= '1';
wait for CLK_PERIOD/2; --for next half of clock period clk stays at '1'.
end process;
end;
At the end I need to have 31 values in CT_LSB and CT_MSB.
In each cycle I wish to have different encrypted values in CT_LSB and CT_MSB,
In one cycle one iteration of outside_counter needs to happen in which 8 NIBBLE has to encrypted.
This entire code needs to work without using a For Loops.
Can someone help me with this?

Modelsim "Entity '...' has no architecture." error

I'm trying to simulate a VHDL project but modelsim gives me the following error message:
Error: (vsim-3173) Entity 'C:/Users/chose/Documents/CTD/teste/SELETORES/simulation/modelsim/rtl_work.seletores' has no architecture.
I tryed creatindg another project and it gives me the same error. I was able to sim other projects before, doing the same thing.
I'm running Quartus Prime Lite Edition 16.0 and Modelsim 10.5b. The code i'm trying to simulate is:
library IEEE;
use IEEE.Std_Logic_1164.all;
entity SELETORES is
port( IN_POT: in std_logic;
OUT_POT, REG_ALARM, REG_OPEN, CONTA, SW
: in std_logic_vector(9 downto 0);
MODE : in std_logic_vector(39 downto 0);
SEL_DISP, SEL_LED
: in std_logic_vector(1 downto 0);
LED_OUT, SEL_TIME, SEL_POT
: out std_logic_vector(9 downto 0);
REG : out std_logic_vector(19 downto 0)
);
end SELETORES;
architecture SELETORES_bhv of SELETORES is
signal decod_mux : std_logic_vector(19 downto 0);
component mux_4x1_20
port (W,X,Y,Z: in std_logic_vector(19 downto 0);
S: in std_logic_vector(1 downto 0);
F: out std_logic_vector(19 downto 0)
);
end component;
component mux_4x1_10
port (W,X,Y,Z: in std_logic_vector(9 downto 0);
S: in std_logic_vector(1 downto 0);
F: out std_logic_vector(9 downto 0)
);
end component;
component mux_2x1
port (W,X: in std_logic_vector(9 downto 0);
S: in std_logic;
F: out std_logic_vector(9 downto 0)
);
end component;
component decod_time
port( ENTRADA : in std_logic_vector(9 downto 0);
SAIDA: out std_logic_vector(19 downto 0)
);
end component;
begin
L1 : mux_4x1_10 port map ("0000000000", REG_OPEN, OUT_POT, REG_ALARM, SEL_LED, LED_OUT);
L2 : mux_2x1 port map (SW, MODE(19 downto 10), SEL_DISP(0) and not(SEL_DISP(1)), SEL_TIME);
L3 : decod_time port map (CONTA, decod_mux);
L4 : mux_4x1_20 port map ("00000110010111101111", MODE(39 downto 20), decod_mux, "11111100011100111101", SEL_DISP, REG);
L5 : mux_2x1 port map (SW, MODE(9 downto 0), IN_POT, SEL_POT);
end SELETORES_bhv;
First of all you have some syntax errors in your L2 component instantiation. Secondly, in my opinion this is the right way to do it (operators are not permitted in port maps):
library IEEE;
use IEEE.std_logic_1164.all;
entity SELETORES is
port( IN_POT: in std_logic;
OUT_POT, REG_ALARM, REG_OPEN, CONTA, SW
: in std_logic_vector(9 downto 0);
MODE : in std_logic_vector(39 downto 0);
SEL_DISP, SEL_LED
: in std_logic_vector(1 downto 0);
LED_OUT, SEL_TIME, SEL_POT
: out std_logic_vector(9 downto 0);
REG : out std_logic_vector(19 downto 0)
);
end SELETORES;
architecture SELETORES_bhv of SELETORES is
-- Component declarations
component mux_4x1_20
port (W,X,Y,Z: in std_logic_vector(19 downto 0);
S1: in std_logic_vector(1 downto 0);
F: out std_logic_vector(19 downto 0)
);
end component;
component mux_4x1_10
port (W,X,Y,Z: in std_logic_vector(9 downto 0);
S2: in std_logic_vector(1 downto 0);
F: out std_logic_vector(9 downto 0)
);
end component;
component mux_2x1
port (W,X: in std_logic_vector(9 downto 0);
S3: in std_logic;
F: out std_logic_vector(9 downto 0)
);
end component;
component decod_time
port(ENTRADA : in std_logic_vector(9 downto 0);
SAIDA: out std_logic_vector(19 downto 0)
);
end component;
--End component declarations
-- Internal signals
signal decod_mux : std_logic_vector(19 downto 0);
signal foobar: std_logic;
--End Internal Signals
begin
foobar <= SEL_DISP(0) AND NOT SEL_DISP(1);
L1 : mux_4x1_10 port map ("0000000000", REG_OPEN, OUT_POT, REG_ALARM, SEL_LED, LED_OUT);
L2 : mux_2x1 port map (SW, MODE(19 downto 10), foobar, SEL_TIME);
L3 : decod_time port map (CONTA, decod_mux);
L4 : mux_4x1_20 port map ("00000110010111101111", MODE(39 downto 20), decod_mux, "11111100011100111101", SEL_DISP, REG);
L5 : mux_2x1 port map (SW, MODE(9 downto 0), IN_POT, SEL_POT);
end SELETORES_bhv;
I've tested on ModelSim 10.1c with no problems.

vhdl how make signal choice on structual code

I want make menu choice
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY aluall IS
PORT(
A:IN STD_LOGIC_VECTOR(7 DOWNTO 0);
B:IN STD_LOGIC_VECTOR(7 DOWNTO 0);
CLK:IN STD_LOGIC;
LOAD: in std_logic;
RESET: IN STD_LOGIC;
D:OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
END aluall;
ARCHITECTURE structual OF aluall IS
SIGNAL finor,Rsub2,Rsub,Radd,Radd2,Radd1 : STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL rAnd : STD_LOGIC_VECTOR(7 DOWNTO 0);
signal rePiso : std_logic;
SIGNAL fmulti : STD_LOGIC_VECTOR(15 DOWNTO 0);
SIGNAL compare: STD_LOGIC_VECTOR(1 DOWNTO 0);
signal repo: std_logic_vector(7 downto 0);
signal choice: integer range 0 to 10;
COMPONENT orGate
PORT( A:IN STD_LOGIC_VECTOR(7 DOWNTO 0);
B:IN STD_LOGIC_VECTOR(7 DOWNTO 0);
F:OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
END COMPONENT;
COMPONENT andGate
PORT( A:IN STD_LOGIC_VECTOR(7 DOWNTO 0);
B:IN STD_LOGIC_VECTOR(7 DOWNTO 0);
F:OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
END COMPONENT;
COMPONENT add1
PORT(
A : in std_logic_vector(7 downto 0);
C : out std_logic_vector(7 downto 0));
END COMPONENT;
COMPONENT add2
port(
B : in std_logic_vector(7 downto 0);
C : out std_logic_vector(7 downto 0));
END COMPONENT;
COMPONENT add
port(
A : in std_logic_vector(7 downto 0);
B : in std_logic_vector(7 downto 0);
C : out std_logic_vector(7 downto 0));
END COMPONENT;
BEGIN --i want make choice menu for what go to output
process(A,B,choice)
begin
if(choice = 0) then
label0: andGate PORT MAP (A,B,rAnd);
else
label1: orGate PORT MAP (A,B,finor);
end if;
label2: add PORT MAP (A,B,Radd);
label3: sub PORT MAP (A,B,Rsub);
label4: sub2 PORT MAP (A,B,Rsub2);
end structual;
I have error Illegal sequential statement.
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY aluall IS
PORT(
A:IN STD_LOGIC_VECTOR(7 DOWNTO 0);
B:IN STD_LOGIC_VECTOR(7 DOWNTO 0);
code : std_logic_vector(3 downto 0);
CLK:IN STD_LOGIC;
D:OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
END aluall;
ARCHITECTURE structual OF aluall IS
SIGNAL finor,Rsub2,Rsub,Radd,Radd2,Radd1 : STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL rAnd : STD_LOGIC_VECTOR(7 DOWNTO 0);
signal rePiso : std_logic;
SIGNAL fmulti : STD_LOGIC_VECTOR(15 DOWNTO 0);
SIGNAL compare: STD_LOGIC_VECTOR(7 DOWNTO 0);
signal repo: std_logic_vector(7 downto 0);
COMPONENT orGate
PORT( A:IN STD_LOGIC_VECTOR(7 DOWNTO 0);
B:IN STD_LOGIC_VECTOR(7 DOWNTO 0);
F:OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
END COMPONENT;
COMPONENT andGate
PORT( A:IN STD_LOGIC_VECTOR(7 DOWNTO 0);
B:IN STD_LOGIC_VECTOR(7 DOWNTO 0);
F:OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
END COMPONENT;
COMPONENT add1
PORT(
A : in std_logic_vector(7 downto 0);
C : out std_logic_vector(7 downto 0));
END COMPONENT;
COMPONENT add2
port(
B : in std_logic_vector(7 downto 0);
C : out std_logic_vector(7 downto 0));
END COMPONENT;
COMPONENT multi
port(
A : in std_logic_vector(7 downto 0);
B : in std_logic_vector(7 downto 0);
C : out std_logic_vector(15 downto 0));
END COMPONENT;
COMPONENT add
port(
A : in std_logic_vector(7 downto 0);
B : in std_logic_vector(7 downto 0);
C : out std_logic_vector(7 downto 0));
END COMPONENT;
COMPONENT sub
port(
A : in std_logic_vector(7 downto 0);
B : in std_logic_vector(7 downto 0);
C : out std_logic_vector(7 downto 0));
END COMPONENT;
COMPONENT sub2
port(
A : in std_logic_vector(7 downto 0);
B : in std_logic_vector(7 downto 0);
C : out std_logic_vector(7 downto 0));
END COMPONENT;
COMPONENT comparing
port(
A : in std_logic_vector(7 downto 0);
B : in std_logic_vector(7 downto 0);
C : out std_logic_vector(7 downto 0)
);
END COMPONENT;
COMPONENT piso
port(
CLK,LOAD : in std_logic;
PI : in std_logic_vector(7 downto 0);
SO : out std_logic
);
END COMPONENT;
COMPONENT pipo
port(
clk:in std_logic;
pi: in std_logic_vector(7 downto 0);
po:out std_logic_vector(7 downto 0)
);
end COMPONENT;
begin
label0: andGate PORT MAP (A,B,rAnd);
label1: orGate PORT MAP (A,B,finor);
label2: add PORT MAP (A,B,Radd);
label3: sub PORT MAP (A,B,Rsub);
label4: sub2 PORT MAP (A,B,Rsub2);
label5: add1 PORT MAP (A,Radd1);
label6: add2 PORT MAP (B,Radd2);
label7: multi PORT MAP (A,B,fmulti);
label8: comparing PORT MAP (A,B,compare);
process(A,B,CLK,code)
begin
if (code = "0000") then
D<= rAnd;
elsif(code ="0001") then
D<= finor;
elsif(code ="0010") then
D<=Rsub;
elsif(code = "0011") then
D<=Radd;
elsif(code = "0100") then
D<=Rsub;
elsif(code = "0101") then
D<=Rsub2;
elsif(code = "0110") then
D<=Radd1;
elsif(code = "0111") then
D<=Radd2;
elsif(code = "1000") then
D<=fmulti;
else
D<=compare;
end if;
end process;
end structual;
i run this code and always run first if and last...why?
enter image description here

Why am I not seeing an output when I synthesize?

I have been working on a lab assignment that is practically complete, but am running into an issue where I am not seeing an output when synthesizing. I have 7 blocks, that when tested individually display the correct output. How is it that I wouldn't get any output at all when using the top module and test bench files? Below is my top module, followed by my test bench as I suspect the problem may be there. I've looked it over and can't pinpoint anything I may have done wrong. Any help would be appreciated.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity top_module is port(
x,y : in std_logic_vector(7 downto 0);
opcode : in std_logic_vector(2 downto 0);
z : out std_logic_vector(7 downto 0)
);
end top_module;
architecture behavior of top_module is
signal bwAnd, bwOr, bwXor, add, subtract, bwComplement, mux_in1, mux_in2, mux_in3, mux_in4, mux_in5, mux_in6 : std_logic_vector(7 downto 0);
component BW_And is port(
x,y : in std_logic_vector(7 downto 0);
z1 : out std_logic_vector(7 downto 0)
);
end component;
component BW_Rr is port(
x,y : in std_logic_vector(7 downto 0);
z2 : out std_logic_vector(7 downto 0)
);
end component;
component BW_Xor is port(
x,y : in std_logic_vector(7 downto 0);
z3 : out std_logic_vector(7 downto 0)
);
end component;
component full_adder_8 is port(
x,y : in std_logic_vector(7 downto 0);
cin : in std_logic_vector(7 downto 0) := "00000000";
sum, cout: out std_logic_vector(7 downto 0)
);
end component;
component full_subtractor_8 is port(
x,y : in std_logic_vector(7 downto 0);
cin : in std_logic_vector(7 downto 0) := "11111111";
difference, cout: out std_logic_vector(7 downto 0)
);
end component;
component Complement is port(
x : in std_logic_vector(7 downto 0);
z4 : out std_logic_vector(7 downto 0)
);
end component;
component mux is port(
z1,z2,z3,sum,difference,z4 : in std_logic_vector(7 downto 0);
opcode : in std_logic_vector(2 downto 0);
mux_out : out std_logic_vector(7 downto 0)
);
end component;
begin
--instantiating components and mapping ports
c0: BW_And port map(x => x, y => y, z1 => bwAnd);
c1: BW_Or port map(x => x, y => y, z2 => bwOr);
c2: BW_Xor port map(x => x, y => y, z3 => bwXor);
c3: full_adder_8 port map(x => x, y => y, sum => add);
c4: full_subtractor_8 port map(x => x, y => y, difference => subtract);
c5: Complement port map(x => x, z4 => bwComplement);
c6: mux port map(z1 => mux_in1, z2 => mux_in2, z3 => mux_in3, sum => mux_in4, difference => mux_in5, z4 =>mux_in6, opcode => opcode, mux_out => z);
end behavior;
Test Bench:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Lab4 is
end Lab4;
architecture behavior of Lab4 is
component top_module is port(
x,y : in std_logic_vector(7 downto 0);
opcode : in std_logic_vector(2 downto 0);
z : out std_logic_vector(7 downto 0)
);
end component;
signal test_x : std_logic_vector(7 downto 0);
signal test_y : std_logic_vector(7 downto 0);
signal test_opcode : std_logic_vector(2 downto 0) := "000";
signal test_z : std_logic_vector(7 downto 0);
begin
uut: top_module port map (x => test_x, y => test_y, opcode => test_opcode, z => test_z);
sim_proc : process
begin
test_x <= "00010100"; test_y <= "11001111"; test_opcode <= "000";
wait for 100 ns;
test_x <= "00010100"; test_y <= "11001111"; test_opcode <= "001";
wait for 100 ns;
test_x <= "00010100"; test_y <= "11001111"; test_opcode <= "010";
wait for 100 ns;
test_x <= "00010100"; test_y <= "11001111"; test_opcode <= "011";
wait for 100 ns;
test_x <= "00010100"; test_y <= "11001111"; test_opcode <= "100";
wait for 100 ns;
test_x <= "00010100"; test_y <= "11001111"; test_opcode <= "101";
end process;
end behavior;
Entities for each component:
entity BW_And is port(
x,y : in std_logic_vector(7 downto 0);
z1 : out std_logic_vector(7 downto 0)
);
end BW_And;
entity BW_Or is port(
x,y : in std_logic_vector(7 downto 0);
z2 : out std_logic_vector(7 downto 0)
);
end BW_Or;
entity BW_Xor is port(
x,y : in std_logic_vector(7 downto 0);
z3 : out std_logic_vector(7 downto 0)
);
end BW_Xor;
entity full_adder_8 is port(
x,y : in std_logic_vector(7 downto 0);
cin : in std_logic_vector(7 downto 0) := "00000000";
sum, cout: out std_logic_vector(7 downto 0)
);
end full_adder_8;
entity full_subtractor_8 is port(
x,y : in std_logic_vector(7 downto 0);
cin : in std_logic_vector(7 downto 0) := "11111111";
difference, cout: out std_logic_vector(7 downto 0)
);
end full_subtractor_8;
entity Complement is port(
x : in std_logic_vector(7 downto 0);
z4 : out std_logic_vector(7 downto 0)
);
end Complement;
entity mux is port(
z1,z2,z3,sum,difference,z4 : in std_logic_vector(7 downto 0);
opcode : in std_logic_vector(2 downto 0);
mux_out : out std_logic_vector(7 downto 0)
);
end mux;
I realized where my problem was after all. The issue was with my mux file. In my process, I only passed "opcode" neglecting to pass in all of the inputs.
Before:
process (opcode)
.
.
.
end process;
After:
process (z1,z2,z3,sum,difference,z4,opcode)
.
.
.
end process;

Resources