Difference between revisions of "Black box, empty box, and unknown box"

From Verific Design Automation FAQ
Jump to: navigation, search
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
In Verific Netlist Database, a Netlist can be a black box, an empty box, or an unknown box.
+
In Verific Netlist Database, a Netlist can be a black box, an empty box, or an unknown box (and of course, a "normal" box).
 
# An unknown box is a Netlist that is:
 
# An unknown box is a Netlist that is:
 
#* from an instantiation of an undefined Verilog module
 
#* from an instantiation of an undefined Verilog module
Line 17: Line 17:
  
 
  <nowiki>
 
  <nowiki>
  1 #include "Set.h"
+
#include "Set.h"
  2 #include "Message.h"
+
#include "Message.h"
  3 #include "Strings.h"
+
#include "Strings.h"
  4 #include "veri_file.h"
+
#include "veri_file.h"
  5 #include "vhdl_file.h"
+
#include "vhdl_file.h"
  6 #include "VeriModule.h"
+
#include "VeriModule.h"
  7 #include "VeriWrite.h"
+
#include "VeriWrite.h"
  8 #include "DataBase.h"
+
#include "DataBase.h"
  9
+
 
10 #ifdef VERIFIC_NAMESPACE
+
#ifdef VERIFIC_NAMESPACE
11 using namespace Verific ;
+
using namespace Verific ;
12 #endif
+
#endif
13
+
 
14 void Accumulate(Netlist *netlist, Set &done) ;
+
void Accumulate(Netlist *netlist, Set &done) ;
15
+
 
16 int main()
+
int main() {
17 {
+
     vhdl_file::SetDefaultLibraryPath("../vdbs");
18     vhdl_file::SetDefaultLibraryPath("../vdbs");
+
 
19
+
     if (!vhdl_file::Analyze("fromvhdl.vhd")) return 1 ;
20     if (!vhdl_file::Analyze("fromvhdl.vhd")) return 1 ;
+
     if (!veri_file::Analyze("test.v", veri_file::VERILOG_2K)) return 1 ;
21     if (!veri_file::Analyze("test.v", veri_file::VERILOG_2K)) return 1 ;
+
 
22
+
     // blackboxing module "willbebackboxed"
23     // blackboxing module "willbebackboxed"
+
     VeriModule *tobeblackboxed = veri_file::GetModule("willbebackboxed");
24     VeriModule *tobeblackboxed = veri_file::GetModule("willbebackboxed");
+
     tobeblackboxed->SetCompileAsBlackbox();
25     tobeblackboxed->SetCompileAsBlackbox();
+
 
26
+
     veri_file::Elaborate("top");
27     veri_file::Elaborate("top");
+
 
28
+
     Netlist *top = Netlist::PresentDesign() ;
29     Netlist *top = Netlist::PresentDesign() ;
+
     if (!top) {
30     if (!top) {
+
         Message::PrintLine("cannot find any handle to the top-level netlist") ;
31         Message::PrintLine("cannot find any handle to the top-level netlist") ;
+
         return 1 ;
32         return 1 ;
+
     }
33     }
+
 
34
+
     Message::Msg(VERIFIC_INFO, 0, top->Linefile(), "top level design is '%s(%s)'",
35     Message::Msg(VERIFIC_INFO, 0, top->Linefile(), "top level design is %s(%s)",
+
                 top->Owner()->Name(), top->Name()) ;
36                 top->Owner()->Name(), top->Name()) ;
+
 
37
+
     // Lets accumulate all netlist
38     // Lets accumulate all netlist
+
     Set netlists(POINTER_HASH) ;
39     Set netlists(POINTER_HASH) ;
+
     Accumulate(top, netlists) ;
40     Accumulate(top, netlists) ;
+
 
41
+
     // Iterate over all Netlists in the design
42     // For each netlist, print out its data
+
     Netlist *netlist ;
43     Netlist *netlist ;
+
     SetIter si ;
44     SetIter si ;
+
     FOREACH_SET_ITEM(&netlists, si, &netlist) {
45     FOREACH_SET_ITEM(&netlists, si, &netlist) {
+
         Message::Msg(VERIFIC_INFO, 0, 0, "*** netlist '%s' of cell '%s'", netlist->Name(), netlist->Owner()->Name()) ;
46         Message::Msg(VERIFIC_INFO, 0, 0, "*** netlist of cell %s", netlist->Owner()->Name()) ;
+
        // What language does it come from?
47         if (netlist->IsPrimitive() || netlist->IsOperator()) {
+
        if (netlist->GetAttValue(" language")) {
48             Message::Msg(VERIFIC_INFO, 0, 0, "      a primitive/operator");
+
            Message::Msg(VERIFIC_INFO, 0, 0, "      from %s", netlist->GetAttValue(" language"));
49         }
+
        } else {
50         const Att *attr = netlist->GetAtt(" unknown_design"); // note the leading space character
+
            Message::Msg(VERIFIC_INFO, 0, 0, "      no language");
51         if (attr) {
+
        }
52             if (Strings::compare (attr->Value(),"1")) {
+
        // Is it a Verific primitive or operator?
53                 Message::Msg(VERIFIC_INFO, 0, 0, "      an unknown box instantiated in a Verilog module");
+
         if (netlist->IsPrimitive() || netlist->IsOperator()) {
54             }
+
             Message::Msg(VERIFIC_INFO, 0, 0, "      a primitive/operator");
55             else if (Strings::compare (attr->Value(),"2")) {
+
         }
56                 Message::Msg(VERIFIC_INFO, 0, 0, "      an unknown box instantiated in a VHDL architecture");
+
        // Check attribute for unknown box
57             }
+
         const Att *attr = netlist->GetAtt(" unknown_design"); // note the leading space character
58         }
+
         if (attr) {
59         if (netlist->IsBlackBox()) {
+
             if (Strings::compare (attr->Value(),"1")) {
60             Message::Msg(VERIFIC_INFO, 0, 0, "      a black box");
+
                // attribute value = "1" : instantiated in a Verilog module
61         }
+
                 Message::Msg(VERIFIC_INFO, 0, 0, "      an unknown box instantiated in a Verilog module");
62         if (netlist->IsEmptyBox()) {
+
             }
63             Message::Msg(VERIFIC_INFO, 0, 0, "      an empty box");
+
             else if (Strings::compare (attr->Value(),"2")) {
64         }
+
                // attribute value = "2" : instantiated in a VHDL architecture
65
+
                 Message::Msg(VERIFIC_INFO, 0, 0, "      an unknown box instantiated in a VHDL architecture");
66     }
+
             }
67     VeriWrite veriWriter;
+
         }
68     veriWriter.WriteFile("netlistout.v", top) ;
+
         if (netlist->IsBlackBox()) {
69
+
             Message::Msg(VERIFIC_INFO, 0, 0, "      a black box");
70     return 0 ;
+
         }
71 }
+
         if (netlist->IsEmptyBox()) {
72
+
             Message::Msg(VERIFIC_INFO, 0, 0, "      an empty box");
73 // This function is recursive in nature, and collects all other
+
         }
74 // netlists that the incoming netlist depends on in a container.
+
 
75
+
     }
76 void Accumulate(Netlist *netlist, Set &done)
+
     VeriWrite veriWriter;
77 {
+
     veriWriter.WriteFile("netlistout.v", top) ;
78     if (!netlist) return ; // Ignore NULL netlists
+
 
79
+
     return 0 ;
80     SetItem *item = done.GetItem(netlist) ;
+
}
81     if (item) {
+
 
82         return ; // We've already been here
+
// This function is recursive in nature, and collects all other
83     }
+
// netlists that the incoming netlist depends on in a container.
84
+
 
85     Instance *inst ;
+
void Accumulate(Netlist *netlist, Set &done)
86     MapIter mi ;
+
{
87     FOREACH_INSTANCE_OF_NETLIST(netlist, mi, inst) {
+
     if (!netlist) return ; // Ignore NULL netlists
88         // Now go into the netlist associated with the instance
+
 
89         Accumulate(inst->View(), done) ;
+
     SetItem *item = done.GetItem(netlist) ;
90     }
+
     if (item) {
91
+
         return ; // We've already been here
92     done.Insert(netlist) ;
+
     }
93 }
+
 
 +
     Instance *inst ;
 +
     MapIter mi ;
 +
     FOREACH_INSTANCE_OF_NETLIST(netlist, mi, inst) {
 +
         // Now go into the netlist associated with the instance
 +
         Accumulate(inst->View(), done) ;
 +
     }
 +
 
 +
     done.Insert(netlist) ;
 +
}
 
   </nowiki>
 
   </nowiki>
 
test.v
 
test.v
Line 183: Line 192:
 
test.v(29): INFO: back to Verilog to continue elaboration (VERI-1232)
 
test.v(29): INFO: back to Verilog to continue elaboration (VERI-1232)
 
test.v(21): INFO: top level design is top()
 
test.v(21): INFO: top level design is top()
INFO: *** netlist of cell nocontents
+
INFO: *** netlist '' of cell 'nocontents'
 +
INFO:        from verilog
 
INFO:        an empty box
 
INFO:        an empty box
INFO: *** netlist of cell willbebackboxed
+
INFO: *** netlist '' of cell 'willbebackboxed'
 +
INFO:        from verilog
 
INFO:        a black box
 
INFO:        a black box
 
INFO:        an empty box
 
INFO:        an empty box
INFO: *** netlist of cell containserror
+
INFO: *** netlist '' of cell 'containserror'
 +
INFO:        from verilog
 
INFO:        a black box
 
INFO:        a black box
 
INFO:        an empty box
 
INFO:        an empty box
INFO: *** netlist of cell emptybox
+
INFO: *** netlist 'INTERFACE' of cell 'VERIFIC_BUF'
 +
INFO:        no language
 +
INFO:        a primitive/operator
 +
INFO:        a black box
 
INFO:        an empty box
 
INFO:        an empty box
INFO: *** netlist of cell unknownverilog
+
INFO: *** netlist '' of cell 'emptybox'
 +
INFO:        from verilog
 +
INFO: *** netlist 'OrderedPorts' of cell 'unknownverilog'
 +
INFO:        no language
 
INFO:        an unknown box instantiated in a Verilog module
 
INFO:        an unknown box instantiated in a Verilog module
 
INFO:        a black box
 
INFO:        a black box
 
INFO:        an empty box
 
INFO:        an empty box
INFO: *** netlist of cell VERIFIC_AND
+
INFO: *** netlist 'INTERFACE' of cell 'VERIFIC_AND'
 +
INFO:        no language
 
INFO:        a primitive/operator
 
INFO:        a primitive/operator
 
INFO:        a black box
 
INFO:        a black box
 
INFO:        an empty box
 
INFO:        an empty box
INFO: *** netlist of cell normal
+
INFO: *** netlist '' of cell 'normal'
INFO: *** netlist of cell unknownvhdl
+
INFO:        from verilog
 +
INFO: *** netlist '' of cell 'unknownvhdl'
 +
INFO:        from vhdl
 
INFO:        an unknown box instantiated in a VHDL architecture
 
INFO:        an unknown box instantiated in a VHDL architecture
 
INFO:        a black box
 
INFO:        a black box
 
INFO:        an empty box
 
INFO:        an empty box
INFO: *** netlist of cell fromvhdl
+
INFO: *** netlist 'test' of cell 'fromvhdl'
INFO: *** netlist of cell top
+
INFO:        from vhdl
 +
INFO: *** netlist '' of cell 'top'
 +
INFO:        from verilog
 
-- Writing netlist 'top' to Verilog file 'netlistout.v' (VDB-1030)
 
-- Writing netlist 'top' to Verilog file 'netlistout.v' (VDB-1030)
 
$
 
$
 
  </nowiki>
 
  </nowiki>

Revision as of 17:27, 30 July 2020

In Verific Netlist Database, a Netlist can be a black box, an empty box, or an unknown box (and of course, a "normal" box).

  1. An unknown box is a Netlist that is:
    • from an instantiation of an undefined Verilog module
    • from an instantiation of a VHDL component without binding entity
  2. An black box is a Netlist that has no Instances (NumOfInsts() == 0) and no Nets ((NumOfNets() == 0). It can be:
    • an unknown box
    • a Verific Primitive or Operator
    • a Netlist that has errors during RTL elaboration
    • from VeriModule::SetCompileAsBlackbox()
    • from VhdlPrimaryUnit::SetCompileAsBlackbox()
  3. An empty box is a Netlist that has no Instances and no port-port connections. It can be:
    • a black box
    • a user-defined module/entity with ports but no contents
    • a user-defined module/entity that has no assignments to its outputs

See example below:

#include "Set.h"
#include "Message.h"
#include "Strings.h"
#include "veri_file.h"
#include "vhdl_file.h"
#include "VeriModule.h"
#include "VeriWrite.h"
#include "DataBase.h"

#ifdef VERIFIC_NAMESPACE
using namespace Verific ;
#endif

void Accumulate(Netlist *netlist, Set &done) ;

int main() {
    vhdl_file::SetDefaultLibraryPath("../vdbs");

    if (!vhdl_file::Analyze("fromvhdl.vhd")) return 1 ;
    if (!veri_file::Analyze("test.v", veri_file::VERILOG_2K)) return 1 ;

    // blackboxing module "willbebackboxed"
    VeriModule *tobeblackboxed = veri_file::GetModule("willbebackboxed");
    tobeblackboxed->SetCompileAsBlackbox();

    veri_file::Elaborate("top");

    Netlist *top = Netlist::PresentDesign() ;
    if (!top) {
        Message::PrintLine("cannot find any handle to the top-level netlist") ;
        return 1 ;
    }

    Message::Msg(VERIFIC_INFO, 0, top->Linefile(), "top level design is '%s(%s)'",
                 top->Owner()->Name(), top->Name()) ;

    // Lets accumulate all netlist
    Set netlists(POINTER_HASH) ;
    Accumulate(top, netlists) ;

    // Iterate over all Netlists in the design
    Netlist *netlist ;
    SetIter si ;
    FOREACH_SET_ITEM(&netlists, si, &netlist) {
        Message::Msg(VERIFIC_INFO, 0, 0, "*** netlist '%s' of cell '%s'", netlist->Name(), netlist->Owner()->Name()) ;
        // What language does it come from?
        if (netlist->GetAttValue(" language")) {
            Message::Msg(VERIFIC_INFO, 0, 0, "       from %s", netlist->GetAttValue(" language"));
        } else {
            Message::Msg(VERIFIC_INFO, 0, 0, "       no language");
        }
        // Is it a Verific primitive or operator?
        if (netlist->IsPrimitive() || netlist->IsOperator()) {
            Message::Msg(VERIFIC_INFO, 0, 0, "       a primitive/operator");
        }
        // Check attribute for unknown box
        const Att *attr = netlist->GetAtt(" unknown_design"); // note the leading space character
        if (attr) {
            if (Strings::compare (attr->Value(),"1")) {
                // attribute value = "1" : instantiated in a Verilog module
                Message::Msg(VERIFIC_INFO, 0, 0, "       an unknown box instantiated in a Verilog module");
            }
            else if (Strings::compare (attr->Value(),"2")) {
                // attribute value = "2" : instantiated in a VHDL architecture
                Message::Msg(VERIFIC_INFO, 0, 0, "       an unknown box instantiated in a VHDL architecture");
            }
        }
        if (netlist->IsBlackBox()) {
            Message::Msg(VERIFIC_INFO, 0, 0, "       a black box");
        }
        if (netlist->IsEmptyBox()) {
            Message::Msg(VERIFIC_INFO, 0, 0, "       an empty box");
        }

    }
    VeriWrite veriWriter;
    veriWriter.WriteFile("netlistout.v", top) ;

    return 0 ;
}

// This function is recursive in nature, and collects all other
// netlists that the incoming netlist depends on in a container.

void Accumulate(Netlist *netlist, Set &done)
{
    if (!netlist) return ; // Ignore NULL netlists

    SetItem *item = done.GetItem(netlist) ;
    if (item) {
        return ; // We've already been here
    }

    Instance *inst ;
    MapIter mi ;
    FOREACH_INSTANCE_OF_NETLIST(netlist, mi, inst) {
        // Now go into the netlist associated with the instance
        Accumulate(inst->View(), done) ;
    }

    done.Insert(netlist) ;
}
  

test.v

module nocontents (input a, output o);
endmodule

module willbebackboxed (input a, b, output o);
  assign o = a ^ b;
endmodule

module containserror (input a, b, output o);
  assign o = a & b;
  assign o = a | b;
endmodule

module emptybox (input a, output o); // no outputs are driven
  wire i = a;
endmodule

module normal (input a, b, output o);
  assign o = a & b;
endmodule

module top (input i1, i2, i3, i4, i5, i6, i7, i8, i9, ia, ib,
            output o1, o2, o3, o4, o5);
  nocontents u_nocontents (i1, o1);
  willbebackboxed u_willbebackboxed (i2, i3, o2);
  containserror u_containserror (i4, i5, o3);
  emptybox u_emptybox (i9, );
  unknownverilog u_unknownverilog (i6, o4);
  normal u_normal (i7, i8, o5);
  fromvhdl u_fromvhdl (ia, ib, o6);
endmodule
 

fromvhdl.vhd:

library std;
use std.all;
entity fromvhdl is
  port ( a, b: in bit; o: out bit );
end entity;
architecture test of fromvhdl is
  component unknownvhdl
    port ( a, b : in bit; o : out bit);
  end component;
begin
  u_unknownvhdl: unknownvhdl port map (a, b, o);
end architecture;
 

Run:

$ test-linux
INFO: The default VHDL library search path is now "/mnt/Verific/extra_tests/vdbs" (VHDL-1504)
-- Analyzing VHDL file 'fromvhdl.vhd' (VHDL-1481)
-- Restoring VHDL parse-tree 'std.standard' from '/mnt/Verific/extra_tests/vdbs/std/standard.vdb' (VHDL-1493)
fromvhdl.vhd(3): INFO: analyzing entity 'fromvhdl' (VHDL-1012)
fromvhdl.vhd(6): INFO: analyzing architecture 'test' (VHDL-1010)
-- Analyzing Verilog file 'test.v' (VERI-1482)
test.v(21): INFO: compiling module 'top' (VERI-1018)
test.v(1): INFO: compiling module 'nocontents' (VERI-1018)
test.v(4): INFO: compiling module 'willbebackboxed' (VERI-1018)
test.v(8): INFO: compiling module 'containserror' (VERI-1018)
test.v(9): ERROR: net 'o' is constantly driven from multiple places (VDB-1000)
test.v(10): ERROR: another driver from here (VDB-1001)
test.v(8): INFO: module 'containserror' remains a black box, due to errors in its contents (VERI-1073)
test.v(13): INFO: compiling module 'emptybox' (VERI-1018)
test.v(27): WARNING: instantiating unknown module 'unknownverilog' (VERI-1063)
test.v(17): INFO: compiling module 'normal' (VERI-1018)
test.v(29): INFO: going to VHDL side to elaborate design unit 'fromvhdl' (VERI-1231)
fromvhdl.vhd(3): INFO: executing 'fromvhdl(test)' (VHDL-1067)
fromvhdl.vhd(9): WARNING: 'unknownvhdl' remains a black box since it has no binding entity (VHDL-1250)
test.v(29): INFO: back to Verilog to continue elaboration (VERI-1232)
test.v(21): INFO: top level design is top()
INFO: *** netlist '' of cell 'nocontents'
INFO:        from verilog
INFO:        an empty box
INFO: *** netlist '' of cell 'willbebackboxed'
INFO:        from verilog
INFO:        a black box
INFO:        an empty box
INFO: *** netlist '' of cell 'containserror'
INFO:        from verilog
INFO:        a black box
INFO:        an empty box
INFO: *** netlist 'INTERFACE' of cell 'VERIFIC_BUF'
INFO:        no language
INFO:        a primitive/operator
INFO:        a black box
INFO:        an empty box
INFO: *** netlist '' of cell 'emptybox'
INFO:        from verilog
INFO: *** netlist 'OrderedPorts' of cell 'unknownverilog'
INFO:        no language
INFO:        an unknown box instantiated in a Verilog module
INFO:        a black box
INFO:        an empty box
INFO: *** netlist 'INTERFACE' of cell 'VERIFIC_AND'
INFO:        no language
INFO:        a primitive/operator
INFO:        a black box
INFO:        an empty box
INFO: *** netlist '' of cell 'normal'
INFO:        from verilog
INFO: *** netlist '' of cell 'unknownvhdl'
INFO:        from vhdl
INFO:        an unknown box instantiated in a VHDL architecture
INFO:        a black box
INFO:        an empty box
INFO: *** netlist 'test' of cell 'fromvhdl'
INFO:        from vhdl
INFO: *** netlist '' of cell 'top'
INFO:        from verilog
-- Writing netlist 'top' to Verilog file 'netlistout.v' (VDB-1030)
$