1

When I'm trying to simulating the code, getting the Error message

Error-[SE] Syntax error 
"test_jkflipflop.v", 10: token is '('

My source code:

( .J(J), .K(K), .Clk(Clk), .R(R), .S(S), .Q(Q), .Qbar(Qbar));

So please let me know my problem

here i had Written the JK_Flip FLop Structural code and Test bench code.

******Structural*******

`timescale 1ns/1ps
module JKflipflop(J,K,Clk,R,S,Q,Qbar);
    input J,K;
    input Clk;
    input R;
    input S;
    input Q;
    output Qbar;
    reg Qbar;

    always@ (posedge(Clk))
    begin
        if(R == 1)
            Qbar = 0;
        else
            if(S == 1)
                Qbar = 1;
            else
                if(Q == 1)
                    if(J == 0 && K == 0)
                        Qbar = Qbar;
                    else
                        if(J == 0 && K == 1)
                            Qbar = 0;
                        else 
                            if(J == 1 && K == 0)
                                Qbar = 1;
                            else
                                Qbar = ~Qbar;
                else
                    Qbar = Qbar;
    end
endmodule

*******testbench*****

`timescale 1ns/1ps
module test_JK_flipflop;
    reg J;
    reg K;
    reg Clk;
    reg R;
    reg S;
    reg Q;
    wire Qbar;

( .J(J), .K(K), .Clk(Clk), .R(R), .S(S), .Q(Q), .Qbar(Qbar));

    initial begin
        $monitor ("J=%b K=%b Clk=%b R=%b S=%b Q=%b Qbar=%b", J,K,Clk,R,S,Q,Qbar);
    end

    initial Clk = 0;
    always
    #10
    Clk = ~Clk;
    initial begin
        J = 0;
        K = 0;
        R = 0;
        S = 0;
        Q = 0;
        #30;
        R = 1;
        #50;
        R = 0;
        S = 1;
        #50;
        S = 0;
        J = 1;  K = 1;
        #50;
        Q= 1; #50;
        J = 0;  K = 0;
        #50;
        J = 0;  K = 1;
        #50;
        J = 1;  K = 0;
        #50;
        J = 1;  K = 1;
        #50;
        Q = 0;
    end
endmodule
Prune
  • 76,765
  • 14
  • 60
  • 81
  • When you get your problem solved, please remember to "accept" one of the answers. This will properly retire the question in the archives and make it more available for others to look up. – Prune Nov 16 '15 at 17:12

2 Answers2

0

There is no proper instantiation, use instance name and name the module to be instantiated. As follows:

JKflipflop jkf( .J(J), .K(K), .Clk(Clk), .R(R), .S(S), .Q(Q), .Qbar(Qbar));

Refer Module Instantiation link.

Community
  • 1
  • 1
sharvil111
  • 4,301
  • 1
  • 14
  • 29
0

The line in question is not a legal statement of any sort. Is this supposed to be an instance? You must give both the module name and the instance name when you create an instance. Something like this:

JKflipflop ff01(.J(J), .K(K), .Clk(Clk), .R(R), .S(S), .Q(Q), .Qbar(Qbar));

The parser got to the left parenthesis and had no idea what you wanted.

Qiu
  • 5,651
  • 10
  • 49
  • 56
Prune
  • 76,765
  • 14
  • 60
  • 81