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

VHDL AND Logic working as OR logic

Danlar81
Beginner
1,225 Views

Hello,

I am fairly new to VHDL programming. 

I purchased a Udemy online course to begin learning along with a cheap Chinese development board which is used in the course, see link below. The dev board uses a Cyclone IV EP4CE6E22 FPGA.

I have installed Quartus Prime Lite 20.1 to write the VHDL code and program the device.

However, I am running into problems trying to implement simple AND gate logic. I have mapped two external switch inputs and one LED output, but if I press either one of the external switches the LED illuminates, so therefore the logic is behaving as an OR.

I have tried all the switch inputs and all LED outputs individually with no logic and the correct LED illuminates when the assigned switch is depressed.

So I am getting very confused as to why I would be seeing OR type logic when I have implemented an AND.

I have attached a screenshot of my VHDL code, so it can be confirmed that I have implemented the AND operation correctly.

Is there any further settings that I would need to be aware of in Quartus, that may explain the behavior I am experiencing?

I'm still no ruling out, that this could be related to the development board, however I would prefer some further feedback prior to trying to send it back to receive a refund.

Please advise.

 

<FPGA Dev Board> 

0 Kudos
6 Replies
FvM
Honored Contributor I
1,206 Views
Hi,
and turns into or when the signals are active low.
0 Kudos
Danlar81
Beginner
1,188 Views

Hi FvM,

Yes that is correct. When the switch is being depressed, it is grounding the the input, or active low.

Does this mean I would need to introduce some further conditions so the AND logic responds to active low signals?

0 Kudos
roeekalinsky
Valued Contributor I
1,164 Views

Hi @Danlar81 ,

 

If the switches are active low but the LED is active high, then to achieve your intended "and" logic you need to just negate the switch values:

(not sw1) and (not sw2)

which is equivalent to:

sw1 nor sw2

 

And if the LED is also active low, which is likely (check your hardware!), then you also need another negation on the above result. Which would be:

not ( (not sw1) and (not sw2) )

which is equivalent to:

not (sw1 nor sw2)

which is equivalent to:

sw1 or sw2

 

You didn't say what the intended scope was of your online course, but it sounds like you're unfamiliar with the basic properties of boolean algebra? If that's the case, you have homework to do.

https://en.wikipedia.org/wiki/Boolean_algebra

 

A common pitfall with these kinds of online courses is the false promise of instant gratification -- introducing you to advanced topics without requiring that you first learn the necessary foundational knowledge, telling you that you can run without first learning to crawl.  If it sounds too good to be true...  Buyer beware.

0 Kudos
Danlar81
Beginner
1,122 Views

Hi,

I have it all working now which is good news.

 

I am familiar with boolean, however I was trying a lot of new concepts for the first time. I was also performing the logic in Simulink and downloading to the FPGA. I think I was a little blinded by trying to ensure the many settings that were necessary between Quartus and Simulink were ok, I just didn't pay enough attention to the hardware side of things.

As soon as I looked at the schematic again after FvM's comments it was very obvious what what the problem was.

Thank you for your response.

0 Kudos
ShengN_Intel
Employee
1,150 Views

Hi,

 

I had tested the code in one of the device DE1-SOC Cyclone V and seems like the code working fine (check screenshot attached):

11: Led illuminate

10: Led no illuminate

01: Led no illuminate

00: Led no illuminate

May be led of Cyclone IV EP4CE6E22 FPGA a bit different which is active low.

 

Thanks,

Best Regards,

Sheng

 

0 Kudos
Danlar81
Beginner
1,122 Views

Hi,

Thank you for checking the code.

I had to add inverters to all the inputs and outputs to get it to work they way I wanted.

Appreciate you verifying.

0 Kudos
Reply