Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1074147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:05:02+00:00 2026-05-16T21:05:02+00:00

I want to describe an entity that can either function normally or be put

  • 0

I want to describe an entity that can either function normally or be put in a test mode. The general design I have is a top level entity that wraps the “real” entity and a test entity.

I am trying to figure out the best way to express this in VHDL, but I get the feeling I’m overcomplicating things.

Consider a small top-level entity (realistically, there are many more I/Os):

entity toplevelobject is
    port (
        in1 : inout std_logic;
        in2 : inout std_logic;
        out1 : out std_logic;
        out2 : out std_logic;
        testline : in std_logic;
        testclk : in std_logic;
    );

end toplevelobject;

This is supposed to switch between the real functionality and the test mode depending on the state of “testline” (high means test). Note that the test module actually uses everything but clk as an output, even in_*.

architecture test_passthrough of toplevelobject is
    -- This is the actual module
    component real_module
    port (
        in1 : in std_logic;
        in2 : in std_logic;
        out1 : out std_logic;
        out2 : out std_logic;
        clk : in std_logic;
        -- Note absence of "testline"
    );
    end component;

    -- This is the test module, which will just put the clk
    -- signal out on all pins, or play a tune, or something
    component test_module
    port (
        in1 : out std_logic;
        in2 : out std_logic;
        out1 : out std_logic;
        out2 : out std_logic;
        testclk : in std_logic;
        -- Note absence of "testline"
    );
    end component;

    signal real_in1, real_in2 : std_logic;
    signal real_out1, real_out2 : std_logic;

    signal test_in1, test_in2 : std_logic;
    signal test_out1, test_out2 : std_logic;

begin

    real_0 : real_module port map (
        in1 => real_in1,
        in2 => real_in2,
        out1 => real_out1,
        out2 => real_out2,
        clk => clk,
    );

    test_0 : test_module port map (
        in1 => test_in1,
        in2 => test_in2,
        out1 => test_out1,
        out2 => test_out2,
        testclk => clk,
    );

    -- Ports that are outputs on both don't need
    -- much special attention

    out1 <= real_out1 when testline = '0' else test_out1;
    out2 <= real_out2 when testline = '0' else test_out2;

end test_passthrough;

So I have a few questions:

  • For the inout ports, should I have one big process with a case ... when statement that switches on testline? Or a process for each I/O with an if statement? Theoretically I figure that many smaller processes are executed concurrently instead of sequentially, but will it actually make a difference to simulation or synthesis? For example:

    passthrough_in1 : process(testline, in1, test_in1) is
    begin
        if testline = '0' then
            real_in1 <= in1;
        else
            in1 <= test_in1;
        end if;
    end process passthrough_in1;
    

…vs…

    passthrough_all : process(in1, test_in1, in2, test_in2, testline) is

        case testline is
            when '0' =>
                real_in1 <= in1;
                real_in2 <= in2;
            when '1' =>
                in1 <= test_in1;
                in2 <= test_in2;
        end case;

    end process passthrough_all;
  • Is this a sane approach or is there something simpler?
  • I’m confused about sensitivity — do I need passthrough_in1 (or even passthrough_all to be sensitive to anything other than testline?
  • Do I need the real_in1/test_in1 to select between the two wrapped entities? Or is there another way to say “if testline is high, connect test_module output in_1 to the toplevelobject I/O in_1?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:05:02+00:00Added an answer on May 16, 2026 at 9:05 pm

    If I understand you correctly your testmodule drives the (badly named – I assume in the real code they make more sense 🙂 in1,2 ports?

    If so, you need to do something like this:

    real_in1 <= in1;
    in1 <= test_in1 when testline = '1' else 'Z';
    

    That way in non-test-mode the in1 signal will be driven by a ‘Z’, so the external proper in1 signal can override it.

    You can represent this in various other ways (like the processes that you described), all of which should come out being equal in the simulator. The downside of the “all in one process” option is that you’ll need to keep what might end up as an enormous sensitivity list up to date. Doing it one process per signal is just a long winded way of what I did above.

    To save some code and copy/paste effort, you could potentially push those two lines of code into an entity of their own and then instance it many times – in that case, I’d put the instance and port map all on one line, but that would offend some coding standards…

    This all assumes I’ve understood the problem correctly!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.