2008年12月8日 星期一

12/08---位準觸發



module top;

wire enable,data;

wire q_out;

system_clock #200 clock1(enable);

system_clock #100 clock2(data);

latch abc(q_out,enable,data);

endmoduleprimitive latch(q_out,enable,data);

output q_out;

input enable,data;

reg q_out;

table

.........

12/08 加分題



module aaa;
wire a,b,c,d;
wire c_out;
system_clock #800 clock(a);
system_clock #400 clock(b);
system_clock #200 clock(c);
system_clock #100 clock(d);
xxx t(c_out,a,b,c,d);
endmodule
module xxx(c_out,a,b,c,d);
input a,b,c,d;
output c_out;
wire w1,w2,w3,w4,w5,w6,a_bar,b_bar,c_bar,d_bar;
not(a_bar,a);
not(b_bar,b);
not(c_bar,c);
not(d_bar,d);
and(w1,a_bar,b_bar,c_bar,d);
and(w2,a,b,d);
and(w3,b,c,d);
and(w4,a,c,d);
and(w5,a_bar,c,d_bar);
and(w6,a,b_bar,c);
or(c_out,w1,w2,w3,w4,w5,w6);
endmodulemodule system_clock(clk);
parameter PERIOD=100;
output clk;
reg clk;
initialclk=0;
always
begin
#(PERIOD/2) clk=~clk;
#(PERIOD/2) clk=~clk;
end
always@(posedge clk)
if($time>1000)#(PERIOD-1)$stop;
endmodule

2008年11月24日 星期一

2.5.1 HAZARDS





















今天上的東西 大部分聽得懂


不懂的地方也請教了 其他的同學

下面是一些成果

module top;

wire f,c_bar,d,e,f0,f1;

reg a,b,c;

initial

begin

#10 a=1; b=1;

#10 c=1;

#10 c=0;

endinitial

#100 $finish;


AND_gate xxx(f0,a,c);

NOT xxx1(c_bar,c);

AND_gate xxx2(f1,b,c_bar);

or_data xx(f,f0,f1);


AND_gate xxx3(f3,a,b);

AND_gate xxx(f4,a,c);

AND_gate xxx2(f5,b,c_bar);

or_data2 xx1(f2,f3,f4,f5);

endmodule

............

2008年10月20日 星期一

10/20 上課結果


module top;
wire x_in1,x_in2,x_in3,x_in4;
wire y_out;

system_clock #200 clock1(x_in1);
system_clock #100 clock2(x_in2);
system_clock #50 clock3(x_in3);
system_clock #25 clock4(x_in4);

AOI_Unit m1(y_out,x_in1,x_in2,x_in3,x_in4);
endmodule

module AOI_Unit(y_out,x_in1,x_in2,x_in3,x_in4);
input x_in1,x_in2,x_in3,x_in4;
output y_out;
wire y1,y2;
and #1(y1,x_in1,x_in2);
and #1(y2,x_in3,x_in4);
nor #1(y_out,y1,y2);
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
if($time > 1000) #(PERIOD-1)$stop;
endmodule

2008年10月13日 星期一

10/13



module top;

wire a,b;

wire sum,c_out;


system_clock #100 clock1(a);

system_clock #50 clock2(b);



Add_half AH1(sum,c_out,a,b);



endmodule


module Add_half(sum,c_out, a, b);



input a,b;


output sum,c_out;

wire c_out_bar;


xor(sum, a, b);

nand(c_out_bar, a, b);

not(c_out,c_out_bar);

endmodule


module system_clock(clk);

parameter PERIOD = 100;

output clk;

reg clk;initialclk = 0;

always

begin

#(PERIOD/2) clk = ~clk;

#(PERIOD/2) clk = ~clk;

end

always@(posedge clk)

if($time > 1000) #(PERIOD-1)$stop;

endmodule

2008年10月12日 星期日

homework

Design a verilog model of a half adder and write a
testbench to verify the designed verilog model.


p9. 半加法器設計電路
module Add_half(sum,c_out,a,b);
input a,b;
output sum,c_out;
wire c_out_bar;

xor (sum,a,b);
nand (c_out_bar,a,b);
not(c_out,c_out_bar);
endmodule

2008年10月6日 星期一

第一次




















module top ;
wire a,b ;
reg c ;
system_clock #100 clock1 (a) ;
system_clock #50 clock1 (b) ;
always
#1 c=a & b ;
//延遲1個時間單位//
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