Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Bidirectional SPI switch?

This is a complex problem which I am very unsure of, the basic idea is that I want code that switches between 3 SPIs.

I was startled when I noticed the statement that I was about to write

A_SCLK <= C_SCLK

C_SCLK <= A_SCLK

both are true, but this would induce registers, all I want is a wire connection.


-- The idea is that choose either A or B is exclusively
-- connected to C
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity bidir_SPI_switch is
    port(
        A_SCLK, B_SCLK, C_SCLK        :    INOUT STD_LOGIC;
        A_SOMI, B_SOMI, C_SOMI        :    INOUT STD_LOGIC;
        A_SIMO, B_SIMO, C_SIMO        :    INOUT STD_LOGIC;
        A_CSn, B_CSn, C_CSn    :    INOUT STD_LOGIC;
        en, S    : IN BIT
    ); 
end bidir_SPI_switch;
architecture behaviour of bidir_SPI_switch is
    process(en,S)
    begin
-- MASTER enable
        if en = '0' then
            A_SCLK                   HOW??
            C_SCLK
        else
-- SELECT either A or B
        end if;
    end process;

14 Replies