2008年12月29日 星期一

加分成功

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;

2008年10月20日 星期一

練習三

module nanf201 (0,A1,B1);
 input A1,B1;
 output 0;
  nand (0,A1,B1);
  specify
   specparam
    Tpd_0_1=1.13:3.09:7.75;
    Tpd_1_0=0.93:2.5:7.34;
    (A1=>0)=(Tpd_0_1,Tpd_1_0);
    (B1=>0)=(Tpd_0_1,Tpd_0_1);
   endspecify
endmodule

2008年10月13日 星期一

作業二之二

module Add_full(sum,c_out,a,b,c_in);
 input a,b,c_in;
 output sum_c_out;
 wire w1,w2,w3;
 Add_half M1(w1,w2,a,b);
 Add_half M2(sum,w3,w1,c_in);
 or(c_out,w2,w3);
endmodale

作業二

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 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

教科用書

Michael D. Ciletti ,"Modeling,Synthesis,and Rapid Prototyping with the Verilog HDL", Prentice-Hall,Inc.1999, ISBN 0-13-977398-3 國內代理:高立圖書