Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

error- illegal reference to net

Status
Not open for further replies.

swat123

Newbie level 1
Joined
Aug 22, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
12
i am working in verilog coding. i am getting the following error
" illegal reference to net q "

my code is as follow:-

Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
----------------------------------------------------------------------------------------------------------------------
  T-flip flop
     
module tff(t,clk,reset,clear,q,qb);
  input t,clk,reset,clear;
  inout q,qb;
  reg q,qb;
 
  
  always@(negedge clk or reset or clear)
  begin
    if(reset==1)
      begin
      q = 0;
      qb = 1;
    end
      
    else if (clear==1)
      begin
        q=0;
        qb=1;
      end    
  else if(t==1 && clk==0)
      begin
      q =!q;
      qb =!qb;
    end
    else
      begin
      q=q;
      qb=qb;
    end
    
    
  end
  
endmodule
  -----------------------------------------------------------------------------------------------------------------------------------

plz help me
 
Last edited by a moderator:

q and qb must be out instead of inout type

I addition, if you intend to write synthesizable code, please refer to the templates for register modelled.

All events must be described edge sensitive. The condition clk = 0 is illegal for a clock.
 

You can't set q as an output port inside always loop as q is declared as of type inout. If you want to use an inout type as an output, then that must be written outside always loop(like assign q=0). If you want to use q as an output port inside always loop, then it must be declared as of type output.
And never declare inout type as reg.
 
  • Like
Reactions: ads-ee

    ads-ee

    Points: 2
    Helpful Answer Positive Rating
Besides what both FvM and arishsu have mentioned you are using blocking assignments instead of non-blocking assignments in what is supposed to be an edge triggered procedural block (clocked always block, i.e. flip-flop(s)).

Besides that the usage of the reset and clear as asynchronous inputs was discussed on another thread. https://www.edaboard.com/threads/321110/. My advice don't use asynchronous set/preset in the same flip-flop description for an FPGA (an ASIC may have that library element) as none of the latest generation of FPGAs from Altera and Xilinx (perhaps most of the other vendors too) can implement both a reset/preset on the same flop without resorting to an ugly circuit around the flop to emulate the functionality.

Either make both reset/preset synchronous or make the power up state the asynchronous one and the other synchronous.

- - - Updated - - -

Didn't notice at first...your reset and clear do exactly the same thing. Why would you have both?

Also a minor thing but I would use ~ (bitwise inversion) instead of ! (logical not). There is a subtle difference to the way the two behave...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top