I'm trying to use AUTOINST.
my problem is that Module name is different from the it's verilog file name (located under subdir) so the following won't work:
module ExampInout (o,i);
InstModule instName
(/*AUTOINST*/);
endmodule
// Local Variables:
// verilog-library-directories:("subdir")
// End:
How can I let verilog mode "know" that InstModule reside under subdir but in file other than InstModule.v?
verilog-library-files is what you're looking for. You can specify a full or relative path to each file in the list.
That said the comment on the question is a good one. Good style is usually to have the module name match the file name. The exception to this is when it's a 'library' file that contains lots of small module definitions.
Related
I'm a Powershell beginner and this is my first post on stackoverflow. I can understand some simple pipelines, but the following challenge is too complicated for me at this point:
I have a folder with testdata containing *.bmp files and their associated files. I want a powershell script to check which bmp-files are still used. If not used, move bmp-files and associated files to another folder.
Details:
bmp-files and associated files: For example; car01.bmp, car01.log, car01.file, car02.bmp, (...)
The bmp-files are in use if their file name (eg, car01.bmp) is mentioned in any of the (text/csv) files in at least one of 2 locations (incl. subfolders).
If the file name is not found in any of the text files, I want the script to move that file, and any file who's name differs only by file extension to a designated folder.
Looking forward to your solutions!
I found a code snippet which goes like this:
package File::MP3;
use parent 'File'; # sets #File::MP3::ISA = ('File');
my $mp3 = File::MP3->new( 'Andvari.mp3', $data );
$mp3->save();
Here, I want to ask if File::MP3 is just a name (it is named that way just to show that it inherits from File)
OR
We have to name it that way if it inherits from File?
Update
I made a module named Module.pm in lib folder, & then named the package as package lib::Module
You're getting a little confused
When use or require is actioned, Perl will form a relative path from the package name by changing something like My::Other::Module to My/Other/Module.pm using the obvious substitutions
It will look for that relative path in the list of locations in the built-in #INC array, which contains some paths that were defined when perl was built and others that may be added at run time
Up until very recently, #INC contained the current working directory, ., so if you have your module in ./lib/My/Other/Module.pm then the Perl compiler will find it if you use lib::My::Other::Module.pm. But that's not how it's meant to work
You should add ./lib to #INC (using either use lib './lib'[1] or by adding to the value of the environment variable PERL5LIB) and then use My::Other::Module. That will work fine because perl is looking for the .pm file in in ./lib. The name and path to the .pm file, the package statement, and the use statement should all agree about what the name is
[1] Note that it is a security risk to add relative paths to #INC. That is why . is no longer included as standard in the release client for Perl v5.26. That means you shouldn't use lib './lib' as described above. Instead you need something like use lib '/var/users/Me/Perl/source/lib'
A package name like File::MP3 is just a name. Perl's only requirement is that it has to be unique
But modules are grouped into families in CPAN, and most file-related modules begin with File::. There is also Win32::, Net::, Math:: etc.
It is also used to indicate subsidiary modules in a suite. For instance, Mojo::Message contains the code common to both Mojo::Message::Request and Mojo::Message::Response. But that is a mnemonic for the programmer's convenience only
In the case of Math::Poisson, perl will look for a file Math/Poisson.pm which should have a package declaration package Math::Poisson. If you use that package name elsewhere then anything you declare will be inserted into the module's namespace
The File::MP3 in the package declaration is just a name. However, if you want to use that package then the name matters. The use dispatches to require, for which the name in require EXPR is
If EXPR is a bareword, require assumes a .pm extension and replaces :: with / in the filename for you, to make it easy to load standard modules. This form of loading of modules does not risk altering your namespace.
Thus if you want to use File::MP3 then an MP3.pm file had better be in a File/ directory, which needs to be in one of (the absolute-path) directories listed in #INC.
The class File from which File::MP3 inherits has nothing to do with the directory File/. The use parent (see parent) independently specifies the package to load for the class File, and its File.pm file also has to be found in #INC.
The MP3.pm file with the package may well be in a Media/ directory, in which case it would be best named as package Media::MP3; and would be loaded with use Media::MP3; – and it can still inherit from the File class by use parent File;
Placing file-related modules in a directory named File does make sense, of course.
For example, in my main.scm file I have (load "util.scm"). util.scm is a file in the same folder as main.scm. Both files are located in ~/documents/myproject/.
Now when I'm in this directory, and I run $ chez-scheme main.scm everything works fine. However, if I'm in my home directory and run $chez-scheme documents/myproject/main.scm it complains, not being able to find the file util.scm. I suppose this is the case because the current directory was my relevant home directory, and as such util.scm is indeed not there, it is actually in documents/myproject/. That being said, I'm used (in other languages) to the functionality of looking these paths up relative to the file containing the instruction to import, and I'd like to have that here as well. I've tried prefixing it by ./ or defining the file as a libary and doing (import (util)) but none of it works outside of documents/myproject/. Is there any way to get this to work as I intend it to?
I assume this is Chez-Scheme-specific. If not I'd prefer an answer that is implementation-neutral.
load is kind of awkward in R5RS since the report states that system interfaces are off topic in the report, but they include load which is a half hearted solution. The report does not say if the load is relative to the current directory or the file the load form originates from so in order to be portable I guess you are required to run your script from the current directory and have your loaded file relative to both.
Since Chez Scheme implements R6RS load is not really the right form to use. R6RS removed load in favor of libraries. You should make your file a library and consult how to install it. In some systems that is just placing the files in the right path, adding library location in configuration or running install script. How one uses the library is the same in all implementations, by using import.
According to Chez documentation you can pass --libdirs to it to give it one or more paths to consider for loading libraries. You can see the paths it scans by evaluating (library-directories)
There are several different ways to accomplish what (I think) you are trying to do, but eventually they all boil down to letting Chez know where to look for things. When given relative paths, include and load use the source-directories parameter to search for the requested file. Libraries have their path automatically prepended to source-directories while they are being loaded or compiled, so if your main.scm were a library definition then it would find util.scm as you expect.
However, it sounds like main.scm isn't a library, it's a top-level program. Unfortunately, Chez doesn't have a command line option to set the source-directories like it does for library directories. That leaves you with a bit less flexibility. Any of the following will work:
Make util.scm a library and invoke Chez with the --libdirs option to let it know where to look for libraries.
Set source-directories and load main.scm from inside the REPL rather than from the command line.
Write a wrapper shell script that does the above by echoing the commands into scheme so you don't have to type it yourself. (Only suitable if you don't also need to then type into the scheme session).
Write a wrapper shell script that cds into your project directory before running scheme (and presumably cds back to the original directory when it's done).
I am extending an existing open-source project, which already has a very advanced Lexer/Parser/TreeParser in ANTLR. I would like to adhere to the current directory structure, so I created my own directory where I would like to put my new (already written) grammar files. They are importing these three original grammar files and to compile the code, I can use java org.antlr.Tool, where I can specify one directory to search for imported grammars with -lib option argument.
My problem is that these three original imported grammar files have some imports themselves and again in different directory. To illustrate (inheritance/importing going to top):
Abstract syntax directory: lexer parser tree parser
Original syntax directory: lexer parser tree parser
My new syntax directory: lexer parser tree parser
This is the hierarchy. The trouble I am encountering is how to specify "Abstract syntax directory" and also "Original syntax directory" at once with the -lib option on the command line for the ANTLR tool (or any other solution which would allow me to compile my grammar importing the original one with the given directories structure).
I tried -lib directory1 directory2, that just appears to ignore the directory2 (and then tries to compile it, which it cannot, because it is a directory, not an ANTLR grammar). I tried specifying "-lib directory1 -lib directory2", the "-lib directory2" just overwrites the "-lib directory1" then.
It is what I believe a fairly basic need to specify multiple directories to search in, in any more complicated system of grammars, therefore I am sure I missed something. I just cannot google anything useful out.
IF you need any more details, I am happy to provide them, it is my master thesis extending an open source project, so I do not need to keep anything secret. :) If it is not possible, I can live without it, but would really like to keep the consistency of the original project.
Looking at the source of the org.antlr.Tool class:
else if (args[i].equals("-lib")) {
if (i + 1 >= args.length) {
System.err.println("missing library directory with -lib option; ignoring");
}
else {
i++;
libDirectory = args[i];
if (libDirectory.endsWith("/") || libDirectory.endsWith("\\")) {
libDirectory = libDirectory.substring(0,libDirectory.length()-1);
}
File outDir = new File(libDirectory);
if (!outDir.exists()) {
ErrorManager.error(ErrorManager.MSG_DIR_NOT_FOUND,libDirectory);
libDirectory = ".";
}
}
}
it appears just one -lib directory is being read.
I'm assuming your (implied) question is hereby answered (that it is not possible to point to more than 1 -lib directory).
I'm going through Practical Common Lisp, I'm almost finished, and one question that has not been answered for me so far (or maybe I just missed it) is the difference between "require" and "load".
So what is the difference?
Thanks.
require is used for modules, which can each consist of one or many files.
load is used to load an arbitrary single file.
The require function tests whether a
module is already present (using a
case-sensitive comparison); if the
module is not present, require
proceeds to load the appropriate file
or set of files. The pathname
argument, if present, is a single
pathname or a list of pathnames whose
files are to be loaded in order, left
to right. If the pathname argument is
nil or is not provided, the system
will attempt to determine, in some
system-dependent manner, which files
to load. This will typically involve
some central registry of module names
and the associated file lists.
Source: http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node119.html
The load function loads the file named by
filename into the Lisp environment. It
is assumed that a text (character
file) can be automatically
distinguished from an object (binary)
file by some appropriate
implementation-dependent means,
possibly by the file type. The
defaults for filename are taken from
the variable
default-pathname-defaults. If the filename (after the merging in of the
defaults) does not explicitly specify
a type, and both text and object types
of the file are available in the file
system, load should try to select the
more appropriate file by some
implementation-dependent means.
Source: http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node217.html
The difference is that (require) loads a module if it has not been loaded already; (load) loads a file.