源文件和测试文件如下:请大家给出解决办法
module pipeline_add(a,b,cin,cout,sum,clk);
input[3:0] a,b;
input clk,cin;
output[3:0]sum;
output cout;
reg[3:0] tempa,tempb;
reg tempci;
reg cout;
reg firstco;
reg[1:0] firstsum;
reg[2:0] firsta,firstb; //??3?fista[2]?¢firstn[2]·?????
reg[3:0] sum;
always@(posedge clk)
begin
tempa="a"; //ê?è?êy?Y?o′?
tempb="b";
tempci="cin";
end
always@(posedge clk)
begin
{firstco,firstsum}=tempa[1:0]+tempb[1:0]+tempci; //μúò????ó£¨μí2??£?
firsta="tempa"[3:2]; //?′2??ó????μ?êy?Y?o′?
firstb="tempb"[3:2];
end
always@(posedge clk)
begin
{cout,sum}={firsta[2:0]+firstb[2:0]+firstco,firstsum}; //μú?t???ó£¨??2??£?
end
endmodule
`timescale 1ns/1ps
module pipeline_add_test;
reg [3:0] a = 4'b0000;
reg [3:0] b = 4'b0000;
reg cin = 1'b0;
wire cout;
wire [3:0] sum;
reg clk = 1'b0;
parameter PERIOD = 200;
parameter real DUTY_CYCLE = 0.5;
parameter OFFSET = 100;
initial // Clock process for clk
begin
#OFFSET;
forever
begin
clk = 1'b0;
#(PERIOD-(PERIOD*DUTY_CYCLE)) clk = 1'b1;
#(PERIOD*DUTY_CYCLE);
end
end
pipeline_add UUT (
.a(a),
.b(b),
.cin(cin),
.cout(cout),
.sum(sum),
.clk(clk));
initial begin
// ------------- Current Time: 100ns
#100;
cin = 1'b1;
// -------------------------------------
// ------------- Current Time: 185ns
#85;
a = 4'b0010;
b = 4'b0011;
// -------------------------------------
// ------------- Current Time: 385ns
#200;
a = 4'b0100;
b = 4'b0010;
// -------------------------------------
// ------------- Current Time: 585ns
#200;
cin = 1'b0;
a = 4'b1010;
b = 4'b0011;
// -------------------------------------
// ------------- Current Time: 785ns
#200;
a = 4'b1011;
b = 4'b1010;
// -------------------------------------
// ------------- Current Time: 985ns
#200;
a = 4'b1111;
b = 4'b1110;
// -------------------------------------
// ------------- Current Time: 1185ns
#200;
a = 4'b1101;
b = 4'b0100;
// -------------------------------------
// ------------- Current Time: 1585ns
#400;
a = 4'b0011;
// -------------------------------------
// ------------- Current Time: 1785ns
#200;
b = 4'b1101;
// -------------------------------------
// ------------- Current Time: 1985ns
#200;
cin = 1'b1;
a = 4'b0101;
b = 4'b1111;
// -------------------------------------
// ------------- Current Time: 2385ns
#400;
a = 4'b0100;
b = 4'b1101;
// -------------------------------------
end
endmodule
用户1756655 2014-5-8 09:19
用户377235 2013-11-10 18:31
用户377235 2013-8-30 10:50
用户104914 2012-10-29 15:54
用户387732 2012-5-8 11:07
用户1528895 2011-6-24 10:33
用户334378 2011-6-6 00:30
用户342159 2011-4-17 14:37
用户411214 2011-3-24 14:37
用户310116 2010-10-14 23:04