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

XOR operator doesnt work?

Altera_Forum
Honored Contributor II
3,335 Views

Im trying to code a 1bit CRA adder. here is my code. 

 

LIBRARY ieee;USE ieee.std_logic_1164.ALL; ENTITY CRA1BIT IS PORT(c0, x0, y0: IN std_logic; s0, c1: OUT std_logic); END CRA1BIT; ARCHITECTURE s0func OF CRA1BIT IS BEGIN s0 <= (c0 XOR x0 XOR y0); END s0func; ARCHITECTURE c1func OF CRA1BIT IS BEGIN c1 <= ((x0 AND y0) OR (c0 AND (x0 OR y0))); END c1func; 

 

I have used modelsim and the waveform editor in Quartus 2 to check this and in both c1 works as it should but s0 gives me 0 all across the board. iv tried playing with parenthesis and even tried just doing x0 XOR y0 and that doesnt even work. Whats the problem here? 

 

Thanks in advanced.
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
2,385 Views

 

--- Quote Start ---  

Im trying to code a 1bit CRA adder. here is my code. 

 

LIBRARY ieee;USE ieee.std_logic_1164.ALL; ENTITY CRA1BIT IS PORT(c0, x0, y0: IN std_logic; s0, c1: OUT std_logic); END CRA1BIT; ARCHITECTURE s0func OF CRA1BIT IS BEGIN s0 <= (c0 XOR x0 XOR y0); END s0func; ARCHITECTURE c1func OF CRA1BIT IS BEGIN c1 <= ((x0 AND y0) OR (c0 AND (x0 OR y0))); END c1func; 

 

I have used modelsim and the waveform editor in Quartus 2 to check this and in both c1 works as it should but s0 gives me 0 all across the board. iv tried playing with parenthesis and even tried just doing x0 XOR y0 and that doesnt even work. Whats the problem here? 

 

Thanks in advanced. 

--- Quote End ---  

 

 

 

and why two architectures???
0 Kudos
Altera_Forum
Honored Contributor II
2,385 Views

Im fairly new to VHDL so i wasnt really sure what an architecture was to be honest lol. but i combined them into one and it worked. Thank you!

0 Kudos
Altera_Forum
Honored Contributor II
2,385 Views

an entity can have several architectures but all my life I never needed to go multiple. 

In any case each architecture defines all outputs of entity. 

I believe you wanted just to make sure!!! two is better than one.
0 Kudos
Altera_Forum
Honored Contributor II
2,385 Views

You define two architectures for one entity. During simulation (or synthesis), only one will actually be used. 

Quartus will use the last one it encounters if none is selected (hierarchy, configuration). 

If you want both the statements to be executed (sim), or synthesized, put them in one architecture; 

 

ARCHITECTURE func OF CRA1BIT IS 

BEGIN 

s0 <= (c0 XOR x0 XOR y0); 

c1 <= ((x0 AND y0) OR (c0 AND (x0 OR y0))); 

END func; 

 

The use of multiple architecture is very handy if you want to describe behavior on different levels, such as RTL or logic. 

You can test both and see if they behave the same.
0 Kudos
Altera_Forum
Honored Contributor II
2,385 Views

 

--- Quote Start ---  

 

The use of multiple architecture is very handy if you want to describe behavior on different levels, such as RTL or logic. 

You can test both and see if they behave the same. 

--- Quote End ---  

 

 

what for? one can hardly finish one design to the managers deadlines. It may be ok for research purposes.
0 Kudos
Altera_Forum
Honored Contributor II
2,385 Views

 

--- Quote Start ---  

what for? one can hardly finish one design to the managers deadlines. It may be ok for research purposes. 

--- Quote End ---  

 

 

In the early days, when VHDL was created, there were no synthisizers available. At first, VHDL was only for simulating behavior. 

Hardware design were done using graphical editors were you could place polysilicon, diffusion and metal layers, basically transistors and gates at the logic level. 

So a designer would like to simulate on a high level but had to rewrite the design to a lower level and test if the behaviors are identical. VHDL supports this with multiple architectures. 

Nowadays, there are synthesizes available that can synthesize from RT-level, so the need for multiple architectures is probably no longer needed.
0 Kudos
Reply