Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I have been a grateful member of this site for several years. I love this site and refer everyone to it!..."

Geography

Where in the world do Tek-Tips members come from?

How Do I resource Share ?

ganen (Programmer)
2 Dec 06 12:41
In my code I am calling module (STAGE_i) 3 times.
However, I want to instanciate the module only once and multiplex the inputs at different time. How can I achieve this?
I know first I need to  feed the input to a multiplexer then to the module Stage_i. The problem I am having is when I tried to feed the out put from the first stage to the second stage? Also, how do I controll the inputs with time?  Hear is my code

module array_mult(clk, reset,load, x_in,y_in,p,done);

     
    assign row0[2] = x[2] & y[0];  
    assign row0[1] = x[1] & y[0];
    assign row0[0] = x[0] & y[0];
    assign c0 = 3'b000;

    STAGE_i stage0(row0,x,y_bit_i_plus1,y_i,c0,row1,c1);  
         //flop the output from stage0
         always @ (posedge clk)
            begin
              flop_row1 <=row1;
              flop_c1 <= c1;
            end

    STAGE_i stage1 (flop_row1,x,y[2],y[1],flop_c1,row2,c2);
         //flop the output from stage1
         always @ (posedge clk)
            begin
              flop_row2 <= row2;
              flop_c2   <= c2;
           end
 

    STAGE_i stage2 (flop_row2,x,y[3],y[2],flop_c2,row3,c3);
        //flop the output from stae2
        always @ (posedge clk)
           begin
             flop_row3 <= row3;
             flop_c3   <= c3;
           end


    STAGE_n stage3({x[3] & y[3],flop_row3[2:1]},flop_c3,row4[2:0],row4[3]);
       //flop the output from stage3
       always @ (posedge clk)
          begin
            flop_row4 <= row4;
          end

  
always @ (posedge clk)
      if (reset) CurrentState = ST_Ready;
      else       CurrentState = NextState;

always @ (load or CurrentState) begin
      NextState = ST_Ready;
      case (CurrentState)
          ST_Ready : begin
             if (load) NextState = ST_Load;
             else      NextState = ST_Ready;
          end

          ST_Load   :  NextState = ST_Stage1 ;

          ST_Stage1 :  NextState = ST_Stage2 ;

          ST_Stage2 :  NextState = ST_Stage3 ;

          ST_Stage3 :  NextState = ST_Stage4 ;

          ST_Stage4 :  NextState = ST_Done ;

          ST_Done   :  NextState = ST_Ready;
     endcase                
    end

    assign lock = (NextState == ST_Load);
    assign done = (CurrentState == ST_Done);
    assign pre_product = {flop_row4,flop_row3[0],flop_row2[0],flop_row1[0],row0[0]};

always @ (posedge clk)
    if(reset) begin // reset all the registers
              x <= 0;
              y <= 0;
    end
    else if (lock) begin // load all the registers
             x <= x_in;
             y <= y_in;
    end

always @ (posedge clk)
    if(reset)  p <= 0;
    else if (done) p <= pre_product;

endmodule

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close