|
发表于 2008-5-21 00:51:38
|
显示全部楼层
一个简单的例子,希望对你有所帮助。
//
module cnt(
mclk,
mrst,
data_from_input,
cnt_data
);
input mclk;
input mrst;
input [7:0] data_from_input;
output [7:0] cnt_data;
reg cnt_en;
reg [7:0] cnt_data;
always @(posedge mclk or posedge mrst)
begin
if(mrst==1'b1)
begin
cnt_en <= 1'b0;
end
else
begin
if( data_from_input==8'd47 )
begin
cnt_en <= 1'b1;
end
end
end
always @(posedge mclk or posedge mrst)
begin
if(mrst==1'b1)
begin
cnt_data <= {8{1'b0}};
end
else
begin
if( cap_en==1'b1 )
begin
cnt_data <= cnt_data+1'b1;
end
end
end
endmodule |
|