Hello i've got a matter with my simulation, the result of the sub
operation is not the result expected.
My code :
I) The dataflow code to describe cell.
1
2
libraryieee;
3
useieee.std_logic_1164.all;
4
useieee.std_logic_unsigned.all;
5
useieee.numeric_std.all;
6
7
entitycellis
8
port(Ai,Bi,Ci:instd_logic;
9
S:instd_logic_vector(1downto0);
10
Co,Go:outstd_logic);
11
endcell;
12
13
architecturedflowofcellis
14
signaloper:std_logic_vector(1downto0);
15
signaltabc:std_logic_vector(2downto0);
16
begin
17
withtabcselectoper<=
18
'0'&Ai+Biwhen"001",
19
'0'&Ai+Biwhen"010",
20
'0'&Ai-'1'when"011",
21
'0'&Ai+'1'when"100",
22
'0'&Ai-Biwhen"101",
23
'0'&Ai+Bi+'1'when"110",
24
'0'&Aiwhenothers;
25
26
Co<=oper(1);
27
Go<=oper(0);
28
tabc<=Ci&S;
29
endarchitecture;
II) The structural code to link 4 cells to implement the arithmetic
operator
YouseKalack wrote:> the result of the sub operation is not the result expected.
What do you expect and wht do you get instead?
> My code
Pls use the [vhdl] tags further on to wrap your code!
See the "Formatting options" above each edit box...
> use ieee.std_logic_unsigned.all;> use ieee.numeric_std.all;
Never ever both together!
Otherwise you will encounter strange problems due to multiple type
definitions.
YouseKalack wrote:> as you can see in the simulation ....
So setup a second test bench for your "cell" and have a look wether its
working as desired.
> I) The dataflow code to describe cell.
By looking at the picture bottom left corner a thought pops up in my
mind: shouldn't that "cell" also be described as a logic/structural
expression instead as a functional data flow description? And shouldn't
the CI be used for any operation in the "cell"?
To clear the view: the top left hand table is not related to the "cell"
driectly. That table shows the expected behaviour of the top level
module "operator".
in your description of "cell" you never set the Carry-output. Oper(1) is
set to 0 for all possible combinations of input signals. Your arithmetic
won't work without correct Carry-Signals.
Yousekalack wrote:> Yes the test work for one cell but only sub is not working good.. i> think the problem is when A = '0' and A - 1 = ???
No, for a single cell your code is also not working correctly.
Perform a simulation for a single cell. What are the correct outputs for
A=0, Cin=0 and opeartion A-1? What does your simulation show instead?
Huynh J. wrote:> Oper(1) is the carry out from all operations, i put'0' & but the '0'> will be replace if there is a carry
ok you're right, my mistake. "&" and "-" have identical priority and are
evaluted from left to right. So
'0' & Ai - '1'
turns into
('0' & Ai) - '1'
and then the higer bit (i.e. the carry) can indeed be set after the
operation