学习xilinx FPGA,自己学习编写一个计数器的verilog HDL的程序,在仿真激励上编写始终不过,总报语法错误,郁闷啊。下面贴出这个程序,以便自己今后记住:
module cnt_4bit(q, clear,clock
);
input clear,clock;
output[3:0] q;
reg[3:0] q;
always @(posedge clear or negedge clock)
begin
if(clear)
q = 4'd0;
else
q = (q + 1) % 16;
end
endmodule
test bench的激励程序:
`timescale 1ns / 1ps
// Company:
// Engineer:
//
// Create Date: 14:00:26 11/19/2015
// Design Name: cnt_4bit
// Module Name: E:/xilinx/study/project2/mux2_1/tb_