2
votes

I am having trouble creating an entity using inout ports. I tried writing the following code where A is an input and B is an output and it works fine. But as soon as I change A to an inout port, it implements but it won't simulate. Can anyone tell me what the problem is?

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity Problem2 is
Port ( A : inout  integer;
       B : out  integer
          );
end Problem2;

architecture Behavioral of Problem2 is

procedure change (signal A: inout integer; signal B: out integer) is 
begin
B<=A after 20 ns;
end change;

begin

change(A=>A, B=>B);

end Behavioral;
3
Don't these kind of questions belong on electronics.stackexchange?blueshift
@blueshift VHDL is can be argued to be a programming language. Should be fine her.Philippe
"..but it won't simulate" doesn't help us much - won't it elaborate? Or does it run, but not do what you expect, in which case, tell us what it does and what you expected?Martin Thompson

3 Answers

2
votes

The procedure "change" is a driver on A, but doesn't explicitly drive anything, so A will be driven to 'U'. Try this change which should do what you seem to expect:

procedure change (signal A: inout integer; signal B: out integer) is 
begin
  A <= 'Z';
  B <= A after 20 ns;
end change;
1
votes

Usually, you don't need inout ports. Especially if you are just starting to use VHDL, stick with in or out. Inout is used for modeling tri-state busses. As @wjl points out, you need to assign 'Z' to the signal if you want to be able to read what the other side is writing.

Also, if you are writing procedures for your later reuse, you should not wrap them in an entity and then test the entity. This just causes extra problems (as you are experiencing right now). Instead, call the procedure directly from your test bench, like you would test a procedure (or function) in software.

0
votes

Are you using Synopsys VCS ? There is a known limitation in VCS that inout(s) in the entity do not simulate (show up as red)