Advertisement

FPGA面试笔试 一些基础电路设计

阅读量:

1、全加器设计

以4位全加器为例,其设计需同时考虑进位输入信号与进位输出信号的处理方式:

复制代码
 module full_add(

    
 input rst_n,
    
 input clk,
    
 input [3:0]a,
    
 input [3:0]b,
    
 input cin,
    
 output reg [3:0]sum,
    
 output reg cout
    
 );
    
  
    
 always@(posedge clk or negedge rst_n)
    
 begin
    
     if(!rst_n)
    
     begin
    
         {cout,sum} <= 5'b0;
    
     end
    
     else
    
     begin
    
         {cout,sum} <= a+b+cin;
    
     end
    
 end
    
 endmodule
    
    
    

全部评论 (0)

还没有任何评论哟~