verilog 例程
【例 3.1】4 位全加器 module adder4(cout,sum,ina, output[3:0] sum; output cout; input[3:0] ina,inb; input cin; assign {cout,sum}=ina+inb+c endmodule 【例 3.2】4 位计数器 module count4(out,reset,clk output[3:0] out; input reset,clk; reg[3:0] out; always @(posedge clk) begin if (reset) out<=0; //同步复位 else out<=out+1; //计数 end endmodule