我在简单地调用 JK 触发器的模块时遇到了问题。我们的项目是做一个状态机,我的逻辑是正确的,但是我收到一个错误,上面写着“VHDL模块实例化错误:无法通过错误和名称连接实例端口”
错误在第 67 行,这是 JK_FF 的第一个实例化
编辑:我假设问题与寄存器有关,由 http://quartushelp.altera.com/11.1/mergedProjects/msgs/msgs/evrfx_veri_not_a_structural_net_expression.htm给出
但我真的不知道如何解决这个错误。
//Project 2 "main"
module Project2(q3, q2, q1, q0, w, z0, z1, CLK, RST, enable);
//honestly not too sure if I need the Q or not
reg q0,q1,q2,q3;
input enable, w, CLK, RST;
output q0,q1,q2,q3,z0,z1;
initial begin
//k3 <= 1'b1; // essentially k3 = 1
end
and(newClock, CLK, enable); // this is the ned clock
//now i do my assignments i'm guessing
not(wnot, w);
not(q3not, q3);
not(q2not, q2);
not(q1not, q1);
not(q0not, q0);
// j0 assignment
and(j0temp,w,q3not,q2not,q1not);
and(j0temp1,wnot,q2);
and(j0temp2,wnot,q1);
or(j0,j0temp, j0temp1, j0temp2);
// k0 assignment
and(k0temp,q3not,q2not);
or(k0,wnot,q1, k0temp);
//j1 assignment
and(j1temp, wnot,q3not,q2not,q1not,q0not);
and(j1temp1,w,q2);
and(j1temp2,w,q0);
or(j1,q3, j1temp, j1temp1, j1temp2);
//k1 assignments
and(k1temp,w,q1);
and(k1temp1,q2,q0);
and(k1temp2,q3not,q2not,q1,q0not);
or(k1,k1temp,k1temp1,k1temp2);
//j2 assignments
and(j2temp,wnot,q0);
and(j2temp1,w,q1);
and(j2temp2,wnot,q3);
or(j2, j2temp,j2temp1,j2temp2);
//k2 assignments
or(k2,wnot,q1);
//j3 assignments
and(j3,wnot,q2,q1,q0);
//z0 assignments
and(z0temp,wnot,q0not,q2);
and(z0temp1,wnot,q1,q2);
or(z0,z0temp,z0temp1);
//z1 assignments
and(z1temp, wnot,q2);
and(z1temp1,wnot,q1,q0not);
and(z1temp2,q2,q1);
or(z1, z1temp, z1temp1, z1temp2);
//instantiate the flip flops
JK_FF y0(.j(j0),.k(k0),.CLK(newClock), .RST(RST), .Q(q0), .Qnot(q0not));
JK_FF y1(.j(j1),.k(k1),.CLK(newClock), .RST(RST), .Q(q1), .Qnot(q1not));
JK_FF y2(j2,k2,newClock, RST, q2, q2not);
JK_FF y3(j3,k3,newClock, RST, q3, q3not);
endmodule
//asynchronous reset JK flip flop module
module JK_FF(j,k,CLK,RST,Q, Qnot);
input j,k,CLK,RST;
output Q; // not sure what this does or if used
output Qnot;
reg Q;
reg Qnot;
always @(negedge CLK or negedge RST)
if(RST)begin
Q <= 0;
Qnot <= 1;
end
else if(~j && k) begin
Q <= 0;
Qnot <= 1;
end
else if(~j && ~k) begin
Q <= Q;
Qnot <= Qnot;
end
else if(j && ~k) begin
Q <= 1;
Qnot <= 0;
end
else if(j && k) begin
Q <= Qnot;
Qnot <= Q;
end
endmodule