VHDL Generic Bus I/O MUX

Moderator (Company: Titel) #6303958
Rate this post
• ▲ useful
▼ not useful
Alexander S. wrote:
> Attached ModelSim VHDL design of Generic Bus I/O MUX.
I don't understand what the whole thing is good for. A tristate buffer 
usually needs not more than two lines.

A few words to that code:
1
InOutProcess:
2
process (ClockIn,nEnableIn)
3
begin
4
 if nEnableIn = '0' then
5
  DataIO      <= DataIn;
6
 else
7
  DataIO     <= (others => 'Z');
8
 end if;
9
 if ClockIn'event and ClockIn = '1'then
10
  case nResetIn is
11
  when '0' => DataOutValid <= '0'; -- Data for trnsport from DataIO to FPGA valid
12
              DataOut <= (others => '0');
13
  when others =>
14
              DataOutValid <= nEnableIn; -- Data for trnsport from DataIO to FPGA valid
15
              DataOut   <= DataIO;
16
  end case;
17
 end if;
18
end process InOutProcess;
Never ever use combinatorial and synchronous descriptions in the same 
process!
Additionally the simulation will be wrong due to the missing "DataIn" in 
the sensitivity list.
OP (Company: Home) #6304082
Rate this post
• ▲ useful
▼ not useful
Lothar M. wrote:
> Never ever use combinatorial and synchronous descriptions in the same
> process!

 You are right :
1
library ieee;
2
use ieee.std_logic_1164.all;
3

4
entity InOutGen is
5
GENERIC (DataRange  : integer);
6
port
7
 (
8
  ClockIn,                                                                      -- General Clock
9
  nResetIn,                                                                     -- General Reset active low
10
  nEnableIn      : in    std_logic;                                              -- Active 0 for read from FPGA
11
  DataIn         : in    std_logic_vector(DataRange downto 0);                   -- Data for trnsport from FPGA to DataIO
12
  DataOutValid  : out   std_logic;                                               -- Data for trnsport from DataIO to FPGA valid
13
  DataOut        : out   std_logic_vector(DataRange downto 0);                   -- Data for trnsport from DataIO to FPGA
14
  DataIO         : inout std_logic_vector(DataRange downto 0)                    -- External Data Bus
15
 );
16
end InOutGen;
17

18
architecture ArchInOutGen of InOutGen is
19

20
begin
21

22
OutProcess:
23
process (nEnableIn)
24
begin
25
 if nEnableIn = '0' then
26
  DataIO      <= DataIn;
27
 else
28
  DataIO       <= (others => 'Z');
29
 end if;
30
end process OutProcess;
31

32
InProcess:
33
process (ClockIn)
34
begin
35
 if ClockIn'event and ClockIn = '1'then
36
  case nResetIn is
37
   when '0' =>
38
    DataOutValid <='0';                                                         -- Data for trnsport from DataIO to FPGA valid
39
    DataOut   <= (others => '0');
40
    when others =>
41
    DataOutValid   <= nEnableIn;                                                 -- Data for trnsport from DataIO to FPGA valid
42
    DataOut       <= DataIO;
43
  end case;
44
 end if;
45
end process InProcess;

 Thank you for good cooperation.

 Regards Alex.
Attached files:
Moderator (Company: Titel) #6304100
Rate this post
• ▲ useful
▼ not useful
Alexander S. wrote:
1
 OutProcess:
2
 process (nEnableIn)
3
 begin
4
  if nEnableIn = '0' then
5
   DataIO      <= DataIn;
6
  else
7
   DataIO       <= (others => 'Z');
8
  end if;
9
 end process OutProcess;
As already said: the simulation doesn't fit reality due to an incomplete 
sensitivity list. DataIn is missing.

All in all this process is just bloating code. It can be replaced by 1 
concurrent line of code:
1
 DataIO <= DataIn when nEnableIn='0' else (others => 'Z');
OP (Company: Home) #6304120
Rate this post
• ▲ useful
▼ not useful
Lothar M. wrote:

> As already said: the simulation doesn't fit reality due to an incomplete
> sensitivity list. DataIn is missing.

 Thanx.
1
 
2
OutProcess:
3
process (nEnableIn,DataIn)
4
begin
5
 if nEnableIn = '0' then
6
  DataIO      <= DataIn;
7
 else
8
  DataIO       <= (others => 'Z');
9
 end if;
10
end process OutProcess;

 Usually, I use synchronous only process which have only clock in the 
sensitivity list.

 Regards Alex.
Attached files:

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.