2009年11月16日 星期一


module top;
wire [3:0]x_in;
system_clk #50 clk1(x_in[0]);
system_clk #100 clk2(x_in[1]);
system_clk #200 clk3(x_in[2]);
system_clk #400 clk4(x_in[3]);
and4_rtl c1 (y_out,x_in);
endmodule
module and4_rtl(y_out,x_in);
input [3:0]x_in;
output y_out;
reg y_out;
integer k;
always @ (x_in)
begin: and_loop
y_out=0;
for(k=0;k<=3;k=k+1)
if(x_in[k]==1)
begin y_out=1;
disable and_loop;
end
end
endmodule
module system_clk(clk);
parameter period=100;
output clk; reg clk; initial clk=0;
always #(period/2)clk=~clk;
always@(posedge clk)
if($time>1000)
#(period-1)
$stop;
endmodule




module top;
wire [3:0]x_in;
system_clk #50 clkl(x_in[0]);
system_clk #100 clkl(x_in[1]);
system_clk #200 clkl(x_in[2]);
system_clk #400 clkl(x_in[3]);
and4_algo c1 (y_out,x_in);
endmodule


module and4_algo(y_out,x_in);
input[3:0] x_in;
output y_out;
reg y_out;
integer k;
always@(x_in)
begin:and_loop
y_out=1;
for(k=0;k<=3;k=k+1)
if(x_in[k]==0)
begin
y_out=0;
disable and_loop;
end
end
endmodule

module system_clk(clk);
parameter period=100;
output clk;
reg clk;
initial
clk=0;
always
#(period/2)clk=~clk;
always@(posedge clk)
if($time>1000)
#(period-1)
$stop;
endmodule

2009年11月9日 星期一

7


module top;
wire [3:0] x_in;
wire y_out;
system_clk #50 clk1(x_in[0]);
system_clk #100 clk2(x_in[1]);
system_clk #200 clk3(x_in[2]);
system_clk #400 clk4(x_in[3]);
and4_rtl c1 (y_out, x_in);
endmodule


module and4_rtl(y_out, x_in);
input [0:3] x_in;
output y_out;
assign y_out = &x_in;
endmodule

module system_clk(clk);
parameter period=100;
output clk;
reg clk;
initial
clk=0;
always
#(period/2)clk=~clk;
always@(posedge clk)
if($time>1000)
#(period-1)
$stop;
endmodule


module top;
wire x_in1 ,x_in2 ,x_in3 ,x_in4;
system_clk #50 clk1(x_in4);
system_clk #100 clk2(x_in3);
system_clk #200 clk3(x_in2);
system_clk #400 clk4(x_in1);
and4_rtl cl (y_out ,x_in1 ,x_in2 , x_in3 , x_in4);
endmodule


module and4_rtl(y_out ,x_in1 ,x_in2 ,x_in3 ,x_in4 );
input x_in1 , x_in2 , x_in3 , x_in4;
output y_out;
assign y_out = x_in1 & x_in2 & x_in3 & x_in4;
endmodule

module system_clk(clk);
parameter period=100;
output clk;
reg clk;
initial
clk=0;
always
#(period/2)clk=~clk;
always@(posedge clk)
if($time>1000)
#(period-1)
$stop;
endmodule

2009年10月26日 星期一