Verilog

Friday, March 24, 2006

Flip_flop

這週老師所給予的作業,依究不太清楚,還是參考上禮拜而做出來的,不過相信,到後面會越來越熟悉這門課。
=========================================================
module top;
reg data_in,clk,rst;
wire q;
Flip_flop m1(q,data_in,clk,rst);
initial
begin
data_in=0;
clk=0;
rst=0;
#2000 $finish;
end
always#20
data_in=~data_in;
always#30
clk=~clk;
always#100
rst=~rst;
endmodule
module Flip_flop(q,data_in,clk,rst);
input data_in,clk,rst;
output q;
reg q;
always @ (posedge clk)
begin
if (rst==1) q=0;
else q=data_in;
endendmodule



0 Comments:

Post a Comment

<< Home