When I want to compile it is okay, but when I do simulate, there are these errors:
Error: (vsim-3033) C:/DS_2020/LAB06_/Ripple_counter.v(18): Instantiation of 'JK_flip_flop' failed. The design unit was not found.
Error: (vsim-3033) C:/DS_2020/LAB06_/Ripple_counter.v(19): Instantiation of 'JK_flip_flop' failed. The design unit was not found
Error: (vsim-3033) C:/DS_2020/LAB06_/Ripple_counter.v(20): Instantiation of 'JK_flip_flop' failed. The design unit was not found.
Error: (vsim-3033) C:/DS_2020/LAB06_/Ripple_counter.v(22): Instantiation of 'JK_flip_flop' failed. The design unit was not found.
When I use other module, it's okay, but like this use sequential circuit model, there is error like this.
If you know how to remove this error, please tell me.
module JK_filp_flop(clk, J, K, Q);
input clk;
input J,K;
output Q;
reg Q;
always @(negedge clk) begin
Q <= 1'b0;
if(J==0 && K==0) begin Q <= Q; end
else if(J==0 && K==1) begin Q <= 1'b0; end
else if(J==1 && K==0) begin Q <= 1'b1; end
else if(J==1 && K==1) begin Q <= ~Q; end
end
endmodule
module Ripple_counter(clk, logic_1, out );
input clk;
input logic_1;
output out;
wire w1;
wire Q8,Q4,Q2,Q1;
JK_flip_flop JK1 (clk,logic_1,logic_1,Q1);
JK_flip_flop JK2 (Q1,~Q8,logic_1,Q2);
JK_flip_flop JK3 (Q2,logic_1,logic_1,Q4);
assign w1 = Q2&Q4;
JK_flip_flop JK4 (Q1,w1,logic_1,Q8);
assign out = {Q8, Q4, Q2, Q1};
endmodule
This is testbench code:
`timescale 10ns/1ps
module Ripple_counter_TB;
reg clk;
reg logic_1;
wire w1;
wire Q8, Q4, Q2, Q1;
//clock
parameter FREQ = 50; //MHz
parameter CKP = 1000.0/FREQ;
Ripple_counter U1(clk, logic_1, Q8,Q4,Q2,Q1 );
initial forever #(CKP/2) clk = ~clk;
initial begin
clk = 1'b0;
logic_1 = 1'b1;
end
endmodule