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 3355598
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:24:52+00:00 2026-05-18T02:24:52+00:00

I am designing universal shift arithmetic operator. Is there a better way to achieve

  • 0

I am designing universal shift arithmetic operator.
Is there a better way to achieve it besides using the 32bit multiplexer (decoder) in a way presented bellow?

ENTITY isra IS 
PORT (
  clk:    in std_logic;
  rst:    in std_logic;
  di:     in std_logic_vector (31 downto 0);
  sel:    in std_logic_vector (31  downto 0);
  res:    out std_logic_vector (31 downto 0) := (others => '0')
);
END isra;


PROCESS
  BEGIN
    WAIT UNTIL clk'EVENT AND clk = '1';
    IF rst = '1' THEN
      res <= (others => '0');
    ELSE
    CASE sel IS
        when X"00000001"  => res <= to_stdlogicvector(to_bitvector(a) sra 1);
        when X"00000002"  => res <= to_stdlogicvector(to_bitvector(a) sra 2);
        ...
        when X"0000001F"  => res <= to_stdlogicvector(to_bitvector(a) sra 31);
        when others => res <= (others => '0');
    END CASE;
END IF;
END PROCESS;
  • 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-18T02:24:52+00:00Added an answer on May 18, 2026 at 2:24 am

    Use indexing?

    PROCESS
      VARIABLE shift_count : INTEGER RANGE 0 TO 31;
    BEGIN
      IF rst = '1' THEN
        res <= (others => '0');
      ELSIF RISING_EDGE(clk) THEN
        shift_count := to_integer(sel);
        FOR I IN 0 TO 31 LOOP
          IF I + shift_count < 32 THEN
            res(I) <= din(I + shift_count);
          ELSE
            res(I) <= din(31); -- for logical shift right, use '0' instead
          END IF;
        END LOOP;
      END IF;
    END PROCESS;
    

    This version is much easier to parameterize into a generic.

    Remember that VHDl is a behavioral description, it doesn’t specify a mux. The compiler can generate different designs depending on whether you optimize for size, speed, allow pipelining, etc.

    Note that 5 2:1 muxes can implement this in a far smaller area than a single 32:1 mux. If this isn’t the block that limits your clock rate, that might be preferable.

    Also note that your sel input is far too wide, it only needs to be 5 bits.

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

Sidebar

Related Questions

Im designing a dialerPad form using Windows form, there is a textbox which should
When designing an distributed application in Java there seem to be a few technologies
When designing a client/server architecture, is there any advantage to multiplexing multiple connections from
When designing an rdlc report using the VS 2010 report designer, report items such
When designing ASMX web services, there is some sort of restriction on the types
I designing an programming a website using Symfony2. I completed some parts and checked
When designing an application with a large number of remote services, is it better
In designing any desktop applications, are there any general rules on how much memory
Designing a new system from scratch. I'll be using the STL to store lists
When designing LINQ classes using the LINQ to SQL designer I've sometimes needed to

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.