Friday, December 21, 2007

正緣觸發的UDP

module top();
wire data,clk,o;

system_clock #60 clock1(data);
system_clock #30 clock1(clk);

d_prim1 d1(o, clk, data);

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

primitive d_prim1(q_out, clock, data);
output q_out;
input clock, data;
reg q_out;
table
(01) 0 : ? : 0;
(01) 1 : ? : 1;
(0?) 1 : 1 : 1;
(?0) ? : ? : -;
? (??) : ? : -;
endtable
endprimitive

Friday, December 14, 2007

1位元半加法器設計 採用 UDP

module top();
wire a,b,c,s;

system_clock #100 clock1(a);
system_clock #50 clock1(b);

Adder_Sum S1(s, a, b);
Adder_Carry C1(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-PERIOD/2)clk=~clk;
end
always@(posedge clk)if($time>1000)#(PERIOD-1)$stop;
endmodule

primitive Adder_Sum(Sum, InA, InB);
output Sum;
input InA, InB;

table
// inputs : output
00 : 0;
01 : 1;
10 : 1;
11 : 0;
endtable
endprimitive

primitive Adder_Carry(Carry, InA, InB);
output Carry;
input InA, InB;
table
// inputs : output
00 : 0;
01 : 0;
10 : 0;
11 : 1;
endtable
endprimitive