Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16682 Discussions

Need help with this vhdl code

Peter678
Beginner
614 Views

I have this code and the problem is that it says that G does not agree with his usage as a boolean operator when I try to give value to Z1 and I cant see the error. Please help and thank you. 

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
entity COM_SM_4 is
port(A, B: in std_logic_vector (3 downto 0);
Z: out std_logic_vector (3 downto 0));
end COM_SM_4;
architecture BH of COM_SM_4 is
component deco_sm_9
port(I: in std_logic_vector (3 downto 0);
VABS: out std_logic_vector (3 downto 0);
SIG: out std_logic);
end component;
signal VA, VB, Z3, Z2 ,Z1: std_logic_vector (3 downto 0);
signal SA, SB, G, E: std_logic;
begin
V1: deco_sm_9 port map (A, VA, SA);
V2: deco_sm_9 port map (B, VB, SB);
G <= '1' when unsigned(VA) > unsigned (VB) else '0';
E <= '1' when unsigned(VA) = unsigned (VB) else '0';
Z1 <= VB when G or B = '0' else VA;
Z2 <= A when G or B = '0' else B;
Z3 <= Z1 when SA = '0' and SB = '0' else
VA when SA = '0' and SB = '1' else
VB when SA = '1' and SB = '0' else
Z2;

Z <= "0000" when Z3= "1000" else Z3;

end BH;

0 Kudos
1 Solution
RichardTanSY_Intel
579 Views

B is std_logic_vector (3 downto 0) while G is std_logic.

The or operator needs operands of the same type, i.e all operands are boolean, or all of type std_logic.

Try this:

Z1 <= VB when (B = "0000") or (G = '0') else VA;


Best Regards,

Richard Tan

 

p/s: If any answer from the community or Intel Support are helpful, please feel free to give best answer or rate 9/10 survey.


View solution in original post

5 Replies
ak6dn
Valued Contributor III
593 Views

What 'it' is giving you this error? Quartus? A simulator?

0 Kudos
Peter678
Beginner
583 Views
0 Kudos
RichardTanSY_Intel
580 Views

B is std_logic_vector (3 downto 0) while G is std_logic.

The or operator needs operands of the same type, i.e all operands are boolean, or all of type std_logic.

Try this:

Z1 <= VB when (B = "0000") or (G = '0') else VA;


Best Regards,

Richard Tan

 

p/s: If any answer from the community or Intel Support are helpful, please feel free to give best answer or rate 9/10 survey.


RichardTanSY_Intel
559 Views

Thank you for acknowledge the solution provided. 

 I’m glad that your question has been addressed, I now transition this thread to community support. If you have a new question, Please login to ‘https://supporttickets.intel.com’, view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.


Thank you.


Best Regards,

Richard Tan


p/s: If any answer from the community or Intel Support are helpful, please feel free to give best answer or rate 9/10 survey.


0 Kudos
Reply