about "tri-states data bus" problem

C

captain

my module is as follows:

entity tri_state_bus is
Port ( data : inout STD_LOGIC_VECTOR (15 downto 0);
cs : in STD_LOGIC;
rd : in STD_LOGIC;
we : in STD_LOGIC;
clk: in STD_LOGIC;
din : in STD_LOGIC_VECTOR (15 downto 0);
dout : out STD_LOGIC_VECTOR (15 downto 0));
end tri_state_bus;

architecture dbus of tri_state_bus is
begin
process(clk)
begin
if(clk'event and clk='1') then
if(cs='1') then
data<=(others=>'Z');
elsif(rd='0') then
data<=din;
elsif(we='0') then
dout<=data;
end if;
end if;
end process;
end dbus;
 
M

Mike Treseler

captain said:
entity tri_state_bus is
Port ( data : inout STD_LOGIC_VECTOR (15 downto 0);
cs : in STD_LOGIC;
rd : in STD_LOGIC;
we : in STD_LOGIC;
clk: in STD_LOGIC;
din : in STD_LOGIC_VECTOR (15 downto 0);
dout : out STD_LOGIC_VECTOR (15 downto 0));
end tri_state_bus;
the problem is: i can synthesis by ISE/XST,but i can't obtain the
correct results when simulated using modelsim, can anyone tell me
where is the problem?

I don't know what results you expect.
Your bus has separate data in and data out
which does not require tri-state buffers.

-- Mike Treseler
 
G

Geno

captain said:
my module is as follows:

entity tri_state_bus is
Port ( data : inout STD_LOGIC_VECTOR (15 downto 0);
cs : in STD_LOGIC;
rd : in STD_LOGIC;
we : in STD_LOGIC;
clk: in STD_LOGIC;
din : in STD_LOGIC_VECTOR (15 downto 0);
dout : out STD_LOGIC_VECTOR (15 downto 0));
end tri_state_bus;

architecture dbus of tri_state_bus is
begin
process(clk)
begin
if(clk'event and clk='1') then
if(cs='1') then
data<=(others=>'Z');
elsif(rd='0') then
data<=din;
elsif(we='0') then
dout<=data;
end if;
end if;
end process;
end dbus;

It looks like you are trying to model some kind of D flip-flop, so here
is my try:

entity tri_state_bus is
Port (
cs : in STD_LOGIC;
rd : in STD_LOGIC;
we : in STD_LOGIC;
clk: in STD_LOGIC;
din : in STD_LOGIC_VECTOR (15 downto 0);
dout : out STD_LOGIC_VECTOR (15 downto 0));
end tri_state_bus;




architecture dbus of tri_state_bus is
begin
data: STD_LOGIC_VECTOR (15 downto 0); -- make data a local (not a port) signal.
process(clk)
begin
if(clk'event and clk='1') then
elsif(we ='0' and cs = '0') then -- clock enable?
data<=din;
end if;
end if;
if (rd='0' and cs = '0') then -- output enable?
dout<=data;
else
data<=(others=>'Z');
end if;
end process;
end dbus;


Regards,

Geno
 
A

Andy

It looks like you are trying to model some kind of D flip-flop, so here
is my try:

entity tri_state_bus is
Port (
cs : in STD_LOGIC;
rd : in STD_LOGIC;
we : in STD_LOGIC;
clk: in STD_LOGIC;
din : in STD_LOGIC_VECTOR (15 downto 0);
dout : out STD_LOGIC_VECTOR (15 downto 0));
end tri_state_bus;

architecture dbus of tri_state_bus is
begin
data: STD_LOGIC_VECTOR (15 downto 0); -- make data a local (not a port) signal.
process(clk)
begin
if(clk'event and clk='1') then
elsif(we ='0' and cs = '0') then -- clock enable?
data<=din;
end if;
end if;
if (rd='0' and cs = '0') then -- output enable?
dout<=data;
else
data<=(others=>'Z');
end if;
end process;
end dbus;

Regards,

Geno

I'm pretty sure synthesis tools will either not synthesize that, or if
they do, the HW will not behave like the RTL.

The only tools that I am aware of that will accept assignments after
the clocked if clause in a clocked process, all work only with signals
assigned from an expression of (or under conditions of) variables
assigned within the clocked clause, or with regards to an asynchronous
reset functionality (where maybe not all signals assigned in the
clocked clause are affected by reset), in which case the values
assigned must be static.

Many synthesis tools allow a synchronous assignment to 'Z', which
usually (depends on target arch) results in a register for the data, a
tri-state buffer and a register for the enable on that TS buffer.

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top