YAVHDLT (VHDL Code)

CraKaJaX

Lifer
Dec 26, 2004
11,905
148
101
For this project, we are given that there is a Logic F with inputs (A, B, C, D) and the minterms (high outputs or "1's") for these given inputs are (0,4,5,6,7,8,12.) He wants a minimized SOP form for these inputs. The first thing I did was draw a K-map for this problem: Here

looked this K-map over plenty of times and see nothing wrong with it. I came up with the minimized SOP expression of (not C and not D) + (not A and B). I next drew a schematic for this specific logic: Here

From that, I wrote my VHDL code:

library ieee;
use ieee.std_logic_1164.all;

entity LogicF is
port (
A : in std_logic;
B : in std_logic;
C : in std_logic;
D : in std_logic;
Y : out std_logic
);
end LogicF;



architecture dataflow of LogicF is

signal wire1: std_logic;
signal wire2: std_logic;
signal wire3: std_logic;
signal wire4: std_logic;
signal wire5: std_logic;
signal wire6: std_logic;

begin

-- Y <= (not C and not D) or (not A and B); This line is commented out

wire1 <= not A;
wire2 <= B;
wire3 <= not C;
wire4 <= not D;
wire5 <= wire1 and wire2;
wire6 <= wire3 and wire4;
Y <= wire5 or wire6;

end dataflow;

From that VHDL I made Altera interpret it as a schematic and it gave me EXACTLY what I have drawn in my schematic previously. I compiled the code and it worked fine. I set the clock for input A to 10ms, B 20ms, C 40ms, and D 80ms to give me the binary counting order for all inputs and ended my simulation at 100ms. The problem occurs when my output is determined. It does not match my truth table (minterms given) at all. My output (Y) can be seen Here. It is the lower most waveform. It is reading a high from 0000 -> 1100 and for 0110. These are not my highs at all. The truth table that I made for what are supposed to be my outputs is here.

I am really at a loss. I went through this so many times and I still cannot figure out what I'm doing wrong. The prof couldn't make his office hours today again so I got no help today either. Hopefully someone here has some idea of what I'm trying to do. Any help would be appreciated.... Thanks.

 

duragezic

Lifer
Oct 11, 1999
11,234
4
81
Glancing it over quick, shouldn't it be

F(A,B,C,D) = not(C and D) or (not A and B)

? I think it's a DeMorgan's Law thing... not(C and D) is equivalent to (not C or not D)

I didn't check the final result though, and I don't remember this stuff too clearly ATM. :eek:
 

frostedflakes

Diamond Member
Mar 1, 2005
7,925
1
81
You have it set up backwards, in the waveform analysis D should be your LSB and A should be your MSB. So just set it so that D switches every 10ns, C every 20ns, etc. :)
 

CraKaJaX

Lifer
Dec 26, 2004
11,905
148
101
You're right, but they should be equivalent. I don't think it would vary the output at all.

BTW, Remember it clearly NOW! Dammit! :p
 

CraKaJaX

Lifer
Dec 26, 2004
11,905
148
101
Originally posted by: frostedflakes
You have it set up backwards, in the waveform analysis D should be your LSB and A should be your MSB. So just set it so that D switches every 10ns, C every 20ns, etc. :)

Oh my god.... it works. You don't know how much you just saved me. :heart:
 

duragezic

Lifer
Oct 11, 1999
11,234
4
81
Heh, oops. I think I'll blame it on my 4 hours of sleep (I normally sleep a lot) and ***** piece of ***** neighbor and his constant bassy music so I can't nap. :disgust:
 

frostedflakes

Diamond Member
Mar 1, 2005
7,925
1
81
Actually they are not equivalent. Trust me, just change the inputs, it should work out then. :)

EDIT: OK see you got it working, congrats. :)