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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:22:16+00:00 2026-06-17T21:22:16+00:00

The code is very simple, having bunch of ifs to put a certain value

  • 0

The code is very simple, having bunch of ifs to put a certain value in the variable BUS, the problem that on simulating, the BUS output equals : zzzzzzzzzzzzzzzz
while it’s supposed to have certain values corresponding to the if case.

module Bus (AR_OUT, IR_OUT, DR_OUT, PC_OUT, AC_OUT, MEM_OUT, read, S, BUS);

 input [11:0]AR_OUT ;
 input [11:0]PC_OUT ;
 input [15:0]IR_OUT ;
 input [15:0]DR_OUT ;
 input [15:0]AC_OUT ;
 input [15:0]MEM_OUT ;
 input read ;
 input [2:0]S ;

 output [15:0]BUS ;

 reg [15:0]BUS ;
 // inputs are implicitly defined as wire


always @*
   begin

 if(S == 3'b001)
   BUS = AR_OUT;

 else if(S == 3'b010)
   BUS = PC_OUT;  

 else if(S == 3'b011)
   BUS = DR_OUT;

 else if(S == 3'b100)
   BUS = AC_OUT;

 else if(S == 3'b101)
   BUS = IR_OUT;

 else if( (S == 3'b111)&&(read == 1'b1) )
   BUS = MEM_OUT;

 else 
   BUS = 16'b 0000000000000000; 
 end

endmodule

module Bus_tb();

 reg [11:0]AR_OUT ;
 reg [11:0]PC_OUT ;
 reg [15:0]IR_OUT ;
 reg [15:0]DR_OUT ;
 reg [15:0]AC_OUT ;
 reg [15:0]MEM_OUT ;
 reg read ;
 reg [2:0]S ;

 wire [15:0]BUS ;

 initial begin

 AR_OUT = 12'b 0000_0000_1111 ;  
 PC_OUT = 12'b 0000_1111_0000 ;
 IR_OUT = 16'b 0000_0000_1111_0000 ;
 DR_OUT = 16'b 0000_0000_1111_1111 ;
 AC_OUT = 16'b 0000_1111_1111_0000 ;
 MEM_OUT = 16'b 1111_0000_1111_0000 ;

 S = 3'b 001 ;
 #10 S = 3'b 011;
 #10 S = 3'b 010;
 #10 S = 3'b 000;   // 
 #10 S = 3'b 101;
 #10 S = 3'b 100;
 #10 S = 3'b 111;
 #5 read = 1'b1;


 end
 endmodule
  • 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-06-17T21:22:18+00:00Added an answer on June 17, 2026 at 9:22 pm

    Your Bus module is not instantiated in the Bus_tb testbench. You need to instantiate an instance of Bus and hookup the ports.

    E.g. :

    Bus u_bus( .BUS(BUS), ...);

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

Sidebar

Related Questions

The following code is a very simple ajax call to server that alerts back
This is a very simple code in place of a bigger problem, but I'm
I am writing a code that I am sure is very simple, but for
I'm having trouble with a seemingly very simple problem: I want to get a
I am having a problem with a very simple regular expression. I want to
I'm having a really annoying problem, the answer is probably very simple yet I
I'm working on a very simple flash but having problem compiling to the swf
I'm having an issue here that is blowing my mind. It's a very simple
I am having a strange issue. I have a very simple piece of code
I've created a very simple test page to replicate a problem I'm having within

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.