2009年12月28日 星期一

4_in_1

module top;
system_clk #200 clk1(a);
system_clk #100 clk2(b);
system_clk #50 clk3(c);
system_clk #25 clk4(d);
4_in_1 n1(f,a,b,c,d);
endmodule

module 4_in_1(f,a,b,c,d);
input a,b,c,d;
output f;
wire a1,b1,c1,d1,x,y,z,k;
not(a1,a);
not(b1,b);
not(c1,c);
not(d1,d);
and(x,a1,b1,c);
and(y,a1,d);
and(z,b,c1,d);
and(k,a,c,d1);
or(f,x,y,z,k);
endmodule

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

沒有留言:

張貼留言