Sie sind auf Seite 1von 1

Describe

 a  module  called  adder which  can  


module  adder  #(parameter  W  =  8)  
(     be  used  to  generate  a  family  of  circuits  
   input  clk,     according  to    parameter  W  (default  value  is  8.)  
   input  [W-­‐1:0]  inA,  inB,     not  a  good  name,  since  it  is  more  than  an    
   output  [W:0]  out,     Input/   Adder.  
   output  isOdd   Output  Ports  
);        

reg  [W-­‐1:0]      regA,  regB;       Create  physical  wires  (Even  though  it  says  “reg”!)  
reg  [W:0]            regOut;        
reg                                  regOdd;         Generate  an  addiTon  circuit,  
wire  [W:0]      wireOut;              
Inputs  are  regA  and  regB  wires.  
assign  wireOut    =    regA  +  regB;        
Output  is  connected  to  wireOut.  

assign  out  =  regOut;         AVach  wire  out  to  wire  regOut;  


assign  isOdd  =  regOdd;               AVach  wire  isOdd  to  wire  regOdd;  

always@(posedge  clk)           Create  four  posiTve  edged-­‐clocked  


         begin                   registers,  aVacked  to  clock  clk.  
                   regA          <=      inA;                
                   regB          <=      inB;                     The  outputs  of  the  registers  should  
                   regOut  <=      wireOut;                   be  aVached  to  the  regA,regB,regOut,  regOdd  wires.  
                   regOdd  <=    out[0];            
         end  
Inputs  of  registers  should  be  aVached  to  
endmodule    inA,  inB,  wireOut,  out[0]  wires.  

Das könnte Ihnen auch gefallen