Standardized internal module bus

R

Richo

Hi All,

I'm trying to have a standardized internal bus for reading & writing
module registers. The external bus is more or less a standard SRAM type
bus (CLK, NCE, RDNWR, ADDRESS, DATA + NRESET), and I can implement the
read/write for a simple register ok. However, what I'm trying to do is
have a single data bus shared by all modules and have each module
implement their own registers (the code is below). This works fine
until I have more than one module on the bus - as soon as I do this, I
get an error (Xilinx ISE) of "Multi-source in Unit <Framework> on
signal <DATA_BUS_IN<15>>". I realize that both modules are connecting
to the same bus, but due to the chip selects, only one module is ever
driving data onto the bus at any given time. Obviously, I can just have
a huge bus (16 bits for every module) and run them through a
multiplexor, but this seems to be a very innefficient use of resources.
Any ideas how I can use a single bus to implement the register
interface for all modules? I've cut and paste the code below.

Thanks,

Glenn.

------------------------------------

Inside module:

process (CLK) is
begin
if CLK'event and CLK = '1' then
if (NRESET = '0') then
-- Initialize the registers
resetRegisters(kRegMax, registers, reg_init);
else
-- Do the register read/write
doReadWrite(kRegMax, registers, NCS, RDNWR, DATA_BUS_IN,
DATA_BUS_OUT, ADDRESS);
end if;
end if;
end process;


------------------------------------

Procedure definitions:

-- Procedure to reset registers
procedure resetRegisters(maxreg : in positive;
signal registers : out data_register(maxreg
downto 0);
reg_init : in data_register(maxreg
downto 0)
) is
begin
-- Loop through the registers and assign the initialization value
for i in 0 to maxreg loop
-- Assign register
registers(i) <= reg_init(i);
end loop;
end resetRegisters;

procedure doReadWrite(maxreg : in positive;
signal registers : inout
data_register(maxreg downto 0);
NCS, RDNWR : in std_logic;
signal DATA_BUS_IN : in std_logic_vector(15
downto 0);
signal DATA_BUS_OUT : out std_logic_vector(15
downto 0);
signal address : in STD_LOGIC_VECTOR (3
downto 0)
) is

begin
if (NCS = '0') then
-- Determine the address offset
if (RDNWR = '1') then
-- Read cycle, output the data
DATA_BUS_OUT <= registers(CONV_INTEGER(address));
else
-- Write cycle, write the data to the register
registers(CONV_INTEGER(address)) <= DATA_BUS_IN;
end if;
--else
-- Don't output data onto the bus
DATA_BUS_OUT <= "ZZZZZZZZZZZZZZZZ";
end if;
end doReadWrite;
 
M

Marcus Harnisch

Richo said:
Obviously, I can just have
a huge bus (16 bits for every module) and run them through a
multiplexor, but this seems to be a very innefficient use of resources.
Any ideas how I can use a single bus to implement the register

This is how it's normally done. Check if your device supports internal
tri-state signals.

Regards,
-- Marcus
 
R

Richo

Hi Marcus,

Thanks for the suggestion - it wasn't actually the problem, but it
turns out I was driving onto the bus in two different modules. Anyway,
the code I pasted above works fine, thanks :)

Glenn.
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top