module AOI_4_Unit(y_out,x_in1,x_in2,x_in3,x_in4);
input x_in1,x_in2,x_in3,x_in4;
output y_out;
reg y_out,y1,y2;//行為模式接線用reg
always
begin
#1 y1=x_in1 & x_in2;
#1 y2=x_in3 & x_in4;
#1 y_out=~(y1y2);
end
endmodule
/*
結構化模式:
module AOI_4_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);
end
endmodule
系統時脈:
module top;
wire x_in1,x_in2,x_in3,x_in4;//input
wire y_out;//output
system_clock #200 clock1(x_in1);
system_clock #150 clock2(x_in2);
system_clock #100 clock1(x_in3);
system_clock #50 clock2(x_in4);
//-------------------------------------------
module system_clock(clk);
parameter PERIOD = 100;
output clk;
reg clk;
initial
clk = 0;
always
begin
#(PERIOD/2) clk = ~clk;
#(PERIOD/2) clk = ~clk;
#(PERIOD/2) clk = ~clk;
#(PERIOD/2) clk = ~clk;
end
always@(posedge clk)
if($time > 1000) #(PERIOD-1)$stop;
endmodule
2008年10月20日 星期一
2008年10月13日 星期一
p.9 Add_half
module Add-half (sum,c_out,a,b);
input a,b;
output sum,c_out;//declaration of port modes
wire c_out_bar;//內部接線 declaration of internal signal
//結構化模式 strutural module
xor(sum,a,b);
nand(c_out,bar,a,b);
not(c_out,c_out_bar);//instatiation of primitive gates
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 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
input a,b;
output sum,c_out;//declaration of port modes
wire c_out_bar;//內部接線 declaration of internal signal
//結構化模式 strutural module
xor(sum,a,b);
nand(c_out,bar,a,b);
not(c_out,c_out_bar);//instatiation of primitive gates
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 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年10月6日 星期一
Design a verilog textbench
題目:
Design a verilog model
of a half adder and
write a testbench to
verify the designed
verilog model.
CODE:
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
Design a verilog model
of a half adder and
write a testbench to
verify the designed
verilog model.
CODE:
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
verilog code1
2008/10/6
Verilog code1


//code
module top;
wire a,b;
reg c;
system_clock #100 clock1(a);
system_clock#50 clock2(b);
always
#1 c=a&b;
endmodule
//text_bench
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
module top;
wire a,b;
reg c;
system_clock #100 clock1(a);
system_clock#50 clock2(b);
always
#1 c=a&b;
endmodule
//text_bench
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
code:
波形圖:
訂閱:
文章 (Atom)