I have a problem with my VHDL code, I use mypackage.VHD which contains all my components.
So here I have added USE WORK.mypackage.ALL; to use the necessary components for this part. This part uses 2 components, one of them gives me an error when I try to compile the file. If I include the 2 components exactly in the same format, I copy pasted the components from mypackage.VHD to this one and It worked, but once I delete them to use them from mypackage.VHD it gives me error.
I cant figure out what is the problem thank you very much in advanced for helping.
In short: I have 2 VHD file, mypackage.VHD,with my all my components and the second one (alu.VHD) that uses mypackage.VHD components with (USE WORK.mypackage.ALL;), looks like it cant identify the alu_1 components from mypackage.VHD. But dont know why.
Here is the error:
** Error (suppressible): C:/../alu_32.vhd(47): (vcom-1141) Identifier "alu_1" does not identify a component declaration.
The 2 components that my code uses:
alu_32 has no error, but alu_1 has an error when it tries to use it from mypackage.VHD.
COMPONENT alu_1
PORT (
a, b, c_in, less : IN STD_LOGIC;
ALUControl : IN STD_LOGIC_VECTOR (3 DOWNTO 0);
c_out, result, set : OUT STD_LOGIC
);
END COMPONENT;
COMPONENT alu_32
GENERIC (ALU_SIZE : INTEGER := 31); -- Il suffit de chager la valeur 31 a celle de la taille de lALU desiree!
PORT (
SrcA, SrcB : IN std_logic_vector(ALU_SIZE DOWNTO 0);
ALUControl : IN std_logic_vector (3 DOWNTO 0);
c_out : OUT std_logic;
Result : OUT std_logic_vector (ALU_SIZE DOWNTO 0);
zero : OUT std_logic
);
END COMPONENT;
My code:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
USE WORK.mypackage.ALL;
ENTITY alu_32_generic IS
GENERIC (ALU_SIZE : INTEGER := 31); -- Il suffit de chager la valeur 31 a celle de la taille de lALU desiree!
PORT (
SrcA, SrcB : IN STD_LOGIC_VECTOR (ALU_SIZE DOWNTO 0);
ALUControl : IN STD_LOGIC_VECTOR (3 DOWNTO 0);
c_out : OUT STD_LOGIC;
result : OUT STD_LOGIC_VECTOR (ALU_SIZE DOWNTO 0);
zero : OUT std_logic
);
END alu_32_generic;
ARCHITECTURE alu_32 OF alu_32 IS
SIGNAL less_i : std_logic_vector (ALU_SIZE DOWNTO 0);
SIGNAL result_i : std_logic_vector (ALU_SIZE DOWNTO 0);
SIGNAL c_in_i : std_logic_vector (ALU_SIZE + 1 DOWNTO 0);
SIGNAL set : std_logic_vector (ALU_SIZE DOWNTO 0);
BEGIN
zero <= result_i(31) OR result_i(30);
GEN_REG : FOR i IN ALU_SIZE DOWNTO 0 GENERATE
alu_32 : alu_1
PORT MAP(
a => SrcA(i),
b => SrcB(i),
c_in => C_in_i(i),
ALUControl => ALUControl,
c_out => C_in_i(i + 1),
less => less_i(i),
set => set(i),
result => result_i(i)
);
END GENERATE GEN_REG;
c_in_i(0) <= ALUControl(2);
c_out <= C_in_i(ALU_SIZE + 1);
less_i(0) <= set(31);
less_i(ALU_SIZE DOWNTO 1) <= (OTHERS => '0');
result(ALU_SIZE DOWNTO 0) <= result_i;
END alu_32;
Without identifying which is line 47 (your example line counts don't match) you could note that for the entity alu_32_generic declaration:
ENTITY alu_32_generic IS
The architecture entity name:
ARCHITECTURE alu_32 OF alu_32 IS
doesn't match.
After correcting the entity name in the architecture declaration and commenting out the three use clauses not needed:
-- USE ieee.std_logic_arith.ALL;
-- USE ieee.std_logic_unsigned.ALL;
-- USE WORK.mypackage.ALL;
Your code then analyzes (which is what vcom does).
Note that if you enable the use clause more mypackage a declaration found as an architecture declarative item will supplant the one in the package. The use clause is not affecting your problem.
From verror:
vcom Message # 1141:
The syntax requires a component name. The name given does not denote a
component declaration.
You could note the two usages of alu_1 in your code appear valid. The closest to line 47 of your example appears on line 40 (second line below):
GEN_REG : FOR i IN ALU_SIZE DOWNTO 0 GENERATE
alu_32 : alu_1
You could also note the first occurrence is in the component declaration immediately within the architecture declaration:
ARCHITECTURE alu_32 OF alu_32 IS
COMPONENT alu_1
PORT (
Which raises the question as to whether or not you also have an entity declaration for alu_32 lurking around.
The moral of the story here is don't re-declare things you don't need to and get the entity name right in an architecture declaration.
Related
I am working in VHDL, trying to connect three components M88, A8, A16, but once I synthesize the circuit and look at the RTL Schematic none of the components are connected. For example, I want to connect the output of M88 'out_high' to the input A16 of component A16. I do this by defining a signal OUT_H. Below is the structural of the main circuit and the entities of M88 and A16. The library 'Mult8x8.Components' is where I've defined the components. None of the connections between the components I've defined work, but I believe that I'm doing the same mistake that I can't figure out.
Thanks
entity Structure is
Port (
Clock, RST, Start : in BIT;
IN1, IN2 : in BIT_VECTOR (7 downto 0);
RESULT8x8 : out BIT_VECTOR (15 downto 0);
Done : out BIT_VECTOR(3 downto 0)
);
end Structure;
architecture Structural of Structure is use work.Mult8x8_Components.all;
signal OUT_M1, OUT_M2: BIT_VECTOR(7 downto 0);
signal OUT_H, OUT_L, ADD_MIXout, result16: BIT_VECTOR(15 downto 0);
signal Zero, Init, Shift, Add, Low: BIT := '0';
signal High: BIT := '1';
signal F, OFL, REGclr: BIT;
signal DD : BIT_VECTOR(3 downto 0);
begin
-- REGclr <= Init or RST;
RESULT8x8 <= result16;
Done <= DD;
M88 : Mult8x8 port map
(CLK => Clock, RESET => RST, Start => Start, input1 => IN1, input2 => IN2, out_high => OUT_H, out_low => OUT_L, out_mix1 => OUT_M1, out_mix2 => OUT_M2, DONE => DD );
A8 : Adder8 port map (A=>OUT_M1, B=>OUT_M2, Cin=>Low, Cout=>OFL, Sum=>ADD_MIXout(11 downto 4));
A16 : Adder16 port map (A16=> OUT_H, B16 => OUT_L, E16 => ADD_MIXout, Cin16 => low, Cout16 => OFL, Sum16 => result16 );
end Structural;
entity Mult8x8 is
Port(
CLK, RESET, Start : in BIT;
input1 : in BIT_VECTOR (7 downto 0);
input2 : in BIT_VECTOR (7 downto 0);
out_high : out BIT_VECTOR (15 downto 0) := (others =>'0');
out_low : out BIT_VECTOR (15 downto 0) := (others =>'0');
out_mix1 : out BIT_VECTOR (7 downto 0) := (others =>'0');
out_mix2 : out BIT_VECTOR (7 downto 0) := (others =>'0');
DONE : out BIT_VECTOR (3 downto 0)
);
end Mult8x8;
entity Adder16 is
Port ( A16, B16, E16 : in BIT_VECTOR (15 downto 0);
Cin16 : in BIT;
Cout16 : out BIT;
Sum16 : out BIT_VECTOR (15 downto 0));
end Adder16;
When you want to map several entities between them in an upper entity like you're doing there, you need to first define these entities in a separate file (what I supposed you did). Then, I recommend that, in the "top level" (your entity Structure) you need to instantiate them before the begin term of your architecture with a different terminology: component.
NB: This, obviously, only works if the sub entities are compiled in the same work library.
This is an example of how you should change your code. Note that you're missing the component Adder8 that you need to define like the two others.
use work.Mult8x8_Components.all;
entity Structure is
Port (
Clock, RST, Start : in BIT;
IN1, IN2 : in BIT_VECTOR (7 downto 0);
RESULT8x8 : out BIT_VECTOR (15 downto 0);
Done : out BIT_VECTOR(3 downto 0)
);
end Structure;
architecture Structural of Structure is
signal OUT_M1, OUT_M2: BIT_VECTOR(7 downto 0);
signal OUT_H, OUT_L, ADD_MIXout, result16: BIT_VECTOR(15 downto 0);
signal Zero, Init, Shift, Add, Low: BIT := '0';
signal High: BIT := '1';
signal F, OFL, REGclr: BIT;
signal DD : BIT_VECTOR(3 downto 0);
component Mult8x8 is
Port(
CLK, RESET, Start : in BIT;
input1 : in BIT_VECTOR (7 downto 0);
input2 : in BIT_VECTOR (7 downto 0);
out_high : out BIT_VECTOR (15 downto 0) := (others =>'0');
out_low : out BIT_VECTOR (15 downto 0) := (others =>'0');
out_mix1 : out BIT_VECTOR (7 downto 0) := (others =>'0');
out_mix2 : out BIT_VECTOR (7 downto 0) := (others =>'0');
DONE : out BIT_VECTOR (3 downto 0)
);
end component ;
component Adder16 is
Port (
A16, B16, E16 : in BIT_VECTOR (15 downto 0);
Cin16 : in BIT;
Cout16 : out BIT;
Sum16 : out BIT_VECTOR (15 downto 0)
);
end component ;
begin
-- REGclr <= Init or RST;
RESULT8x8 <= result16;
Done <= DD;
M88 : Mult8x8 port map
(CLK => Clock,
RESET => RST,
Start => Start,
input1 => IN1,
input2 => IN2,
out_high => OUT_H,
out_low => OUT_L,
out_mix1 => OUT_M1,
out_mix2 => OUT_M2,
DONE => DD );
A8 : Adder8 port map
(A=>OUT_M1,
B=>OUT_M2,
Cin=>Low,
Cout=>OFL,
Sum=>ADD_MIXout(11 downto 4));
A16 : Adder16 port map
(A16=> OUT_H,
B16 => OUT_L,
E16 => ADD_MIXout,
Cin16 => low,
Cout16 => OFL,
Sum16 => result16 );
end Structural;
Another way to instantiate your entities without calling the component before is the following:
A8: entity work.adder8 port map (OUT_M1, OUT_M2, Low, OFL, ADD_MIXout(11 downto 4));
In this case, you don't need to specify the ports, they are taken in the order defined in the entity.
I've create a new project on Quartus II with VHDL, but after I run it give me the errors shown below. Do you have any idea why?
Error (10481): VHDL Use Clause error at test_VHDL.vhd(5): design library "work" does not contain primary unit "std_arith"
Error (10800): VHDL error at test_VHDL.vhd(5): selected name in use clause is not an expanded name
Error: Quartus II 64-Bit Analysis & Synthesis was unsuccessful. 2 errors, 1 warning
Error: Peak virtual memory: 1003 megabytes
Error: Processing ended: Sat Dec 5 19:50:39 2015
Error: Elapsed time: 00:00:13
Error: Total CPU time (on all processors): 00:00:38
Error (293001): Quartus II Full Compilation was unsuccessful. 4 errors, 1 warning
Here is my code:
library ieee;
use ieee.std_logic_1164.all;
library work;
use work.std_arith.all; --extinde operatorul ” + “ la opera]ii \ntre semnale
--[i numere \ntregi
entity SUM is
port (a : in std_logic_vector(3 downto 0);
b : in std_logic;
ini,start,clk,a_disponibil,b_disponibil : in std_logic;
sum : out std_logic_vector(4 downto 0);
q : inout std_logic_vector(4 downto 0));
end SUM;
architecture arch_SUM of SUM is
signal load_a,load_b,reset,load_s : std_logic;
signal z : std_logic_vector(0 to 3);
type STARE is (S0,S1,S2,S3,S4); --st`rile automatului
signal S : STARE;
begin
--NUMARATOR
---------------------------------------------------------------
NUM : process(b)
begin
if rising_edge(b) then
if reset='1' then q<=(others=>'0');
elsif load_a='1' then
for i in 3 downto 0 loop --\ncarc` operandul a
q(i) <= a(i); --\n ultimii 3 bistabili
end loop; --ai num`r`torului
elsif load_b='1' then
q <= q+1; --adun` b la a
end if;
end if;
end process NUM;
--REGISTRU
--------------------------------------------------------------------
REG: process(clk)
begin
if rising_edge(clk) then
if reset='1' then sum<=(others=>'0');
elsif load_s='1' then
sum<=q;
end if;
end if;
end process REG;
--AUTOMAT
-----------------------------------------------------------------------------------
AUTOMAT : process(ini,clk)
begin
if INI='1' then s<=S0; --ini]ializeaz` automatul
elsif rising_edge(clk) then
case S is --descrie diagrama st`rilor
when S0 =>
if start='1' then S<=S1;
else S<=S0;
end if;
when S1 =>
if a_disponibil='1' then S<=S2;
else S<=S1;
end if;
when S2 =>
if b_disponibil='1' then S<=S3;
else S<=S2;
end if;
when S3 =>
if b_disponibil='0' then S<=S4;
else S<=S3;
end if;
when S4 => S<=S0;
end case;
end if;
end process AUTOMAT;
with S select
z<= "0000" when S0, --genereaz` ie[irea
"0010" when S1,
"1000" when S2,
"0100" when S3,
"0001" when others;
load_a <= z(0);
load_b <= z(1); --conexiuni interne
reset <= z(2);
load_s <= z(3);
end arch_SUM;
Have anyone idea why and how can solve it?
The statement use work.std_arith.all; introduces the sysnthesis compiler to look for a package std_arith in the same library as of the VHDL file. If you didn't specify one in the Quartus project settings, that it will be the default library. In this case, you have to provide your own implementation of the package and to add this file to the Quartus project as well.
If you are looking for the non-standard package from Synopsys, then you must change the line to use ieee.std_logic_arith.all;. But, this library does not define an operator + for the type std_logic_vector. EDIT The required operator is defined in the package std_logic_unsigned, if you want to treat your std_logic_vectors as unsigned numbers. The package is included with use ieee.std_logic_unsigned.all;. If you want signed arithmetic instead, then include use ieee.std_logic_signed.all;.
But, I recommend to use the standard IEEE library ieee.numeric_std instead, which defines arithmetic operators on the vector-types unsigned and signed.
For example, declare in the entity
sum : out unsigned(4 downto 0);
q : inout unsigned(4 downto 0);
I wrote a vhdl code for divider that has 16 components in it and with nested loop but when synthesize it , it contains a specific errors in many lines .....
Any help is appreciated.
The following codes gives
ERROR:HDLParsers:851 -.vhd" Line 68. Formal cin of CAS with no default
value must be associated with an actual value
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.std_logic_unsigned.all;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity blockasli is
port ( divisor :std_logic_vector(3 downto 0);
dividend :in std_logic_vector(6 downto 0);
quotient :out std_logic_vector(3 downto 0);
remainder :out std_logic_vector(3 downto 0));
end blockasli;
architecture behavioral of blockasli is
-- component declaration ,specifies component interface
component CAS port( cin : in std_logic;
remainder_in : in std_logic;
T : in std_logic;
remainder_out : out std_logic;
cout : out std_logic;
divisor : in std_logic);
end component;
-- two arrays of four 4 bit vectors - the c and s and r linking signal between CAS
type reg_array is array (3 downto 0) of std_logic_vector(3 downto 0);
signal c, s: reg_array;
signal r : std_logic_vector (3 downto 0);
begin
GEN_CAS:
for row in 3 downto 0 generate
begin
GEN_CAS0:
for col in 3 downto 0 generate
begin
CAS_X : CAS port map(
cout => c(row)(col),divisor => divisor(col) , T => not r(row) );
define_remainder:if row=0 generate
begin
CAS_X : CAS port map(remainder_out=> remainder(col));
end generate define_remainder;
linkage_cin_with_c : if col>0 generate
begin
CAS_X : CAS port map( cin=> c(row)(col-1));
end generate linkage_cin_with_c ;
linkage_r_signal_with_cin: if col=0 generate
begin
CAS_X : CAS port map( cin => not r(row));
end generate linkage_r_signal_with_cin;
dividend_0_to_3 : if col=0 generate
begin
CAS_X : CAS port map( remainder_in => dividend(row));
end generate dividend_0_to_3 ;
dividend_4_to_6 : if row=3 generate
begin
CAS_X : CAS port map( remainder_in => dividend(col+3));
end generate dividend_4_to_6 ;
linkage_s_signal_with_remainder_in : if row<3 generate
begin
CAS_X : CAS port map( remainder_in => s(row)(col));
end generate linkage_s_signal_with_remainder_in;
linkage_s_signal_with_remainder_out: if col<3 and row>0 generate
begin
CAS_X : CAS port map( remainder_out => s(row-1)(col));
end generate linkage_s_signal_with_remainder_out;
linkage_r_signal_with_T: if row>0 and col=3 generate
begin
CAS_X : CAS port map( remainder_out => r(row-1));
end generate linkage_r_signal_with_T;
end generate GEN_CAS0;
quotient(row)<= not r(row);
end generate GEN_CAS;
end Behavioral;
You need to connect the cin port of the CAS module. It is defined in the component declaration, but is missing from some of your port maps.
im pretty new in VHDL, and I have a simple question. I have a MAC (Multiply-And-Accumulate) entity which has 2 components in it: 'multiplier' and 'add_sub_n'. i want the MAC to get two inputs a,b, multiply them and add them to an older result when I used the Mac before. here is my code:
-- libraries decleration
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity MAC is
port (a : in std_logic_vector(N-1 downto 0);
b : in std_logic_vector(N-1 downto 0);
mac : in std_logic_vector(N-1 downto 0);
s : out std_logic_vector(N-1 downto 0);
end MAC;
architecture MAC_Logic of MAC is
component Multiplier is
port(
a,b : in std_logic_vector(N-1 downto 0);
c : out std_logic_vector(N-1 downto 0));
end component;
component Add_Sub_N is
port(
a,b : in std_logic_vector(N-1 downto 0);
sub : in std_logic;
cout : out std_logic;
s : out std_logic_vector(N-1 downto 0));
end component;
signal temp1 : std_logic;
begin
mul : Multiplier
port map(a=>a, b=>b, c=>temp1);
addsub : Add_Sub_N
port map(a=>temp1, b=>mac, sub=>0, cout=>cout, s=>s);
end MAC_Logic;
Im pretty stuck. if someone can please help I would appreciate it. thanks!
You have the following operations to perform:
m = a * b
acc' = m + acc
acc = acc'
Where acc' is the new value to store in the accumulator. Your code has entities for the multiply and add but nothing to describe the register that implements the accumulator. The accumulator register provides the second input to the adder. A control input will also be needed to enable writing to the accumulator only when a new product is available.
I am near to end in my project but stuck at some point. I can not resolve the problem
After deciding VHDL is having a hard time shifting indexes of arrays, I decided to change my shifter module. Now it is properly compiling and the RTL schematic seems true, but unfortunately I used a rather non-innovative way to shift the scancodes.
I defined an 64bit std_logic_vector that can hold up to 8 scancodes, and then parsed the 4 MSBmost bytes of this vector, and directed them to seven segment controller, that muxes the inputs and decides which seven segment will be enabled. I am thinking that I have problems with clock, but seeing nothing on the display makes me think some part of the device is malfunctioning. I am sure my keyboard controller works fine, as I tried it outindividually, shifter looks fine as well( I also tried this one on FPGA but without slowing the clock down, but nevertheless I was able to see the last scancode I entered), I haven't thought of any way/method to try out 7 segment controller, but that seems fine too. I don't know what the problem is, the text is not scrolling :(
Shifter.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.numeric_std.all;
entity my_shifter is
port(clk : in std_logic;
Scan_Dav : in std_logic;
Data_in : in std_logic_vector (7 downto 0);
O1 : out std_logic_vector(7 downto 0);
O2 : out std_logic_vector(7 downto 0);
O3 : out std_logic_vector(7 downto 0);
O4 : out std_logic_vector(7 downto 0)
);
end my_shifter;
architecture bhv of my_shifter is
signal bytes : std_logic_vector(63 downto 0);
begin
process (clk) begin
if rising_edge(clk) then
if Scan_Dav = '1' then
bytes <= bytes (bytes'high-8 downto 0) & Data_in;
end if;
end if;
end process;
O1 <= bytes(63 downto 56);
O2 <= bytes(55 downto 48);
O3 <= bytes(47 downto 40);
O4 <= bytes(39 downto 32);
end bhv;
clkdivide.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity clkdivide is
Port (clkin: in std_logic;
clkout:out std_logic );
end clkdivide;
architecture Behavioral of clkdivide is
signal int_clock:std_logic;
begin
clkout<=int_clock;
process(clkin)
variable var:integer range 0 to 12500 :=0;
begin
if (clkin'event and clkin = '1') then
if var = 12500 then
int_clock <= not int_clock;
var:=0;
else
var:=var+1;
end if;
end if;
end process;
end Behavioral;
SevenSegmentControl.vhd:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity SevenSegmentController is
port (
CLK: in std_logic;
DEC1, DEC2, DEC3, DEC4: in std_logic_vector(7 downto 0);
SEGMENTS: out std_logic_vector(6 downto 0);
ANODES: out std_logic_vector(3 downto 0)
);
end SevenSegmentController;
architecture Behavioral of SevenSegmentController is
signal DecoderInput: std_logic_vector(7 downto 0);
signal CurrentDisplay: std_logic_vector(1 downto 0) := "00";
signal Prescaler: std_logic_vector(15 downto 0) := (others => '0');
begin
Multiplex: process(CLK)
begin
if rising_edge(CLK) then
if Prescaler(15) = '0' then
Prescaler <= Prescaler + 1;
else
CurrentDisplay <= CurrentDisplay + 1;
Prescaler <= (others => '0');
end if;
end if;
end process Multiplex;
SevenSegmentDecoder: entity work.SevenSegment_Decoder(Behavioral)
generic map ( INVERT_OUTPUT => '1' )
port map ( number => DecoderInput, segment => SEGMENTS );
DecoderInput <= DEC1 when CurrentDisplay = "00" else
DEC2 when CurrentDisplay = "01" else
DEC3 when CurrentDisplay = "10" else
DEC4 when CurrentDisplay = "11";
ANODES <= "0111" when CurrentDisplay = "00" else
"1011" when CurrentDisplay = "01" else
"1101" when CurrentDisplay = "10" else
"1110" when CurrentDisplay = "11";
end Behavioral;
We have no idea of the interface protocol of SevenSegment_Decoder, but it does look funny that you only have two inputs, but no clock. How does the decoder know when to interpret the signals?
"I haven't thought of any way/method to try out 7 segment controller"
Unless you are using a VERY old version of ISE, certainly older than ISE10, it has a fairly decent simulator (ISIM) built in. (ISIM goes back further than ISE10, but it wasn't really usable and even ISIM 10 had its problems...)
You would save a lot of time if you wrote a simple testbench and unit-tested these modules as you went along.