2007年11月1日 星期四

期中考~多腳位輸入

輸入訊號:
input output

a b c d f

0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
0 1 0 1 0
0 1 1 0 1
0 1 1 1 1
1 0 0 0 1
1 0 0 1 1
1 0 1 0 0
1 0 1 1 0
1 1 0 0 1
1 1 0 1 1
1 1 1 0 0
1 1 1 1 0

程式碼:
module top;
system_clock #200 clock1(a);
system_clock #100 clock2(b);
system_clock #50 clock3(c);
system_clock #25 clock3(d);
many abc(f,a,b,c);
endmodule

module many(f,a,b,c,d);
input a,b,c,d;
output f;
wire a_0,c_0,f_1,f_2;
not(c_0,c);
not(a_0,a);
and(f_1,a,c_0);
and(f_2,a_0,b,c);
or(f,f_1,f_2);
endmodule


module system_clock(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

沒有留言: