module top;
wire a,b,c,d;
wire f;
system_clock #400 clock1(a);
system_clock #200 clock2(b);
system_clock #100 clock3(c);
system_clock #50 clock4(d);
AOI_Unit m1(f,a,b,c,d);
endmodule
module AOI_Unit(f,a,b,c,d);
input a,b,c,d;
output f;
wire f1,f2,f3,f4,f5,a_bar,c_bar,b_bar,d_bar;
not #1(a_bar,a);
not #1(b_bar,b);
not #1(c_bar,c);
not #1(d_bar,d);
and #1(f1,a_bar,b_bar,d);
and #1(f2,b_bar,c_bar,d);
and #1(f3,a_bar,b,d_bar);
and #1(f4,a,c_bar,d_bar);
and #1(f5,a,b,c,d);
or #1(f,f1,f2,f3,f4,f5);
endmodule
module system_clock(clk);
parameter PERIOD = 100;
output clk;
reg clk;
initial
clk = 0;
always begin#(PERIOD/2) clk = ~clk;
#(PERIOD/2) clk = ~clk;
end
always@(posedge clk)
if($time > 1000) #(PERIOD-1)$stop;
endmodule
2008年11月17日 星期一
2 byte compare
module compare_2_byte(A_lt_B,A_gt_B,A_eq_B,A0,A1,B0,B1);
input A0,A1,B0,B1;
output A_lt_B,A_gt_B,A_eq_B;
wire w1,w2,w3,w4,w5,w6,w7;
or(A_lt_B,w1,w2,w3);
nor(A_gt_B,A_lt_B,A_eq_B);and(A_eq_B,w4,w5);and(w1,w6,B1);
and(w2,w6,w7,B0);
and(w3,w7,B0,B1);
not(w6,A1);
not(w7,A0);
xnor(w4,A1,B1);
xnor(w5,A0,B0);
endmodule
-------------------------------------------------------------
module compare_2a(A_lt_B,A_gt_B,A_eq_B,A0,A1,B0,B1);
input A0,A1,B0,B1;
output A_lt_B,A_gt_B,A_eq_B;
asign A-lt_B=(~A1)&B1(-A1)&(~A0)&B0(~A0)&B1&B0;
asign A_gt_B=A1&(-B1)A0&(~B1)&(~B0)A1&A0&(~B0);
method 3
asign A_lt_B=({a1,a0}<{b1,b0});
return 1 if ture else 0
method 4
always@(A or B)if(A==B)A_eq_B=1;
input A0,A1,B0,B1;
output A_lt_B,A_gt_B,A_eq_B;
wire w1,w2,w3,w4,w5,w6,w7;
or(A_lt_B,w1,w2,w3);
nor(A_gt_B,A_lt_B,A_eq_B);and(A_eq_B,w4,w5);and(w1,w6,B1);
and(w2,w6,w7,B0);
and(w3,w7,B0,B1);
not(w6,A1);
not(w7,A0);
xnor(w4,A1,B1);
xnor(w5,A0,B0);
endmodule
-------------------------------------------------------------
module compare_2a(A_lt_B,A_gt_B,A_eq_B,A0,A1,B0,B1);
input A0,A1,B0,B1;
output A_lt_B,A_gt_B,A_eq_B;
asign A-lt_B=(~A1)&B1(-A1)&(~A0)&B0(~A0)&B1&B0;
asign A_gt_B=A1&(-B1)A0&(~B1)&(~B0)A1&A0&(~B0);
method 3
asign A_lt_B=({a1,a0}<{b1,b0});
return 1 if ture else 0
method 4
always@(A or B)if(A==B)A_eq_B=1;
2008年10月20日 星期一
2008年10月13日 星期一
2008年10月6日 星期一
練習一
module top ;
wire a,b ;
reg c ;
system_clock #100 clock1 (a) ;
system_clock #50 clock2 (b) ;
always
#1 c=a&b ;
endmodule
module system_clock (clk);
parameter PERIOD=100 ;
output clk ;
reg clk ;
initial
clk=0 ;
always
begin
#(PERIOD/2) clk=~clk ;
#(PERIOD/2) clk=~clk ;
end
always@(posedge clk)
if($time>1000)#(PERIOD-1)$stop ;
endmodule
wire a,b ;
reg c ;
system_clock #100 clock1 (a) ;
system_clock #50 clock2 (b) ;
always
#1 c=a&b ;
endmodule
module system_clock (clk);
parameter PERIOD=100 ;
output clk ;
reg clk ;
initial
clk=0 ;
always
begin
#(PERIOD/2) clk=~clk ;
#(PERIOD/2) clk=~clk ;
end
always@(posedge clk)
if($time>1000)#(PERIOD-1)$stop ;
endmodule
訂閱:
意見 (Atom)