module syncounter(qa,qabar,qb,qbbar,overflow,ja,ka,jb,kb,clk,rst);
output qa,qabar,qb,qbbar,overflow;
input ja,ka,jb,kb,clk,rst;
reg qa,qb,qabar,qbbar,overflow;
//var1 = qa;
jkflip jk1(qa,qabar,ja,ka,clk,rst);
assign var1 = qa;
jkflip jk2(qb,qbbar,var1,var1,clk,rst);
always @ (ja,ka,jb,kb)
begin
if(qa & qb)
begin
overflow = 1;
end
end
endmodule
触发器的代码是
module jkflip(q,qbar,j,k,clk,rst);
input j,k,clk,rst;
output q,qbar;
wire j,k,clk,rst;
reg q,qbar;
always @(posedge clk)
begin
if(rst) q<=~q;
else
begin
case ({j,k})
2'b00 : q<=q;
2'b01 : q<=1'b0;
2'b10 : q<=1'b1;
2'b11 : q<=~q;
endcase
end
end
endmodule
计数器的测试台
module syncountw();
reg j0,k0,j1,k1,clk,rst;
wire q0,q0bar,q1,q1bar,overflow;
syncounter syn1(q0,q0bar,q1,q1bar,overflow,j0,k0,j1,k1,clk,rst);
always #1 clk = !clk;
//always #1 j0 =1 ;
//always #1 k0 = 1;
initial begin
clk = 1;
j0 = 1;
k0 = 1;
#2
j0 = 1;
k0 = 1;
#2
j0 = 1;
k0 = 1;
#2
j0 = 1;
k0 = 1;
#2
j0 = 1;
k0 = 1;
#2
j0 = 1;
k0 = 1;
#2
j0 = 1;
k0 = 1;
#2
j0 = 1;
k0 = 1;
end
endmodule
我收到一个名为:
的错误Error (suppressible): (vsim-3053) C:/Modeltech_pe_edu_10.4/examples/syncounter.v(7): Illegal output or inout port connection for port 'q'. # Time: 0 ns Iteration: 0 Instance: /syncountw/syn1/jk1 File: C:/Modeltech_pe_edu_10.4/examples/jkflip.v # ** Error (suppressible): (vsim-3053) C:/Modeltech_pe_edu_10.4/examples/syncounter.v(7): Illegal output or inout port connection for port 'qbar'. # Time: 0 ns Iteration: 0 Instance: /syncountw/syn1/jk1 File: C:/Modeltech_pe_edu_10.4/examples/jkflip.v # ** Error (suppressible): (vsim-3053) C:/Modeltech_pe_edu_10.4/examples/syncounter.v(9): Illegal output or inout port connection for port 'q'. # Time: 0 ns Iteration: 0 Instance: /syncountw/syn1/jk2 File: C:/Modeltech_pe_edu_10.4/examples/jkflip.v # ** Error (suppressible): (vsim-3053) C:/Modeltech_pe_edu_10.4/examples/syncounter.v(9): Illegal output or inout port connection for port 'qbar'. # Time: 0 ns Iteration: 0 Instance: /syncountw/syn1/jk2 File: C:/Modeltech_pe_edu_10.4/examples/jkflip.v
答案 0 :(得分:0)
qa
,qb
,qabar
,&amp; qbbar
被声明为reg
,它们应为wire
。 reg
类型用于在当前模块范围内由程序块(即:initial
&amp; always
)分配的信号。
var1
已分配,但从未声明。
变化:
reg qa,qb,qabar,qbbar,overflow;
//var1 = qa;
要:
reg overflow;
wire var1;
仅供参考:您忘记为qbar
分配值