diff options
author | N. Engelhardt <nak@symbioticeda.com> | 2020-03-30 13:51:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-30 13:51:12 +0200 |
commit | 2c847e7efec5e940331a94580fad99375ce73c6f (patch) | |
tree | c87b514d072beb687287ae0432e57964bf0999b9 /frontends/verilog/preproc.h | |
parent | 1dbc70172830c57cda22e4bc82d2db57a2067203 (diff) | |
parent | 044ca9dde409e3c91542fe95513d6641110f8462 (diff) | |
download | yosys-2c847e7efec5e940331a94580fad99375ce73c6f.tar.gz yosys-2c847e7efec5e940331a94580fad99375ce73c6f.tar.bz2 yosys-2c847e7efec5e940331a94580fad99375ce73c6f.zip |
Merge pull request #1778 from rswarbrick/sv-defines
Add support for SystemVerilog-style `define to Verilog frontend
Diffstat (limited to 'frontends/verilog/preproc.h')
-rw-r--r-- | frontends/verilog/preproc.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/frontends/verilog/preproc.h b/frontends/verilog/preproc.h new file mode 100644 index 000000000..673d633c0 --- /dev/null +++ b/frontends/verilog/preproc.h @@ -0,0 +1,77 @@ +/* + * yosys -- Yosys Open SYnthesis Suite + * + * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * --- + * + * The Verilog preprocessor. + * + */ +#ifndef VERILOG_PREPROC_H +#define VERILOG_PREPROC_H + +#include "kernel/yosys.h" + +#include <iosfwd> +#include <list> +#include <memory> +#include <string> + +YOSYS_NAMESPACE_BEGIN + +struct define_body_t; +struct arg_map_t; + +struct define_map_t +{ + define_map_t(); + ~ define_map_t(); + + // Add a definition, overwriting any existing definition for name. + void add(const std::string &name, const std::string &txt, const arg_map_t *args = nullptr); + + // Merge in another map of definitions (which take precedence + // over anything currently defined). + void merge(const define_map_t &map); + + // Find a definition by name. If no match, returns null. + const define_body_t *find(const std::string &name) const; + + // Erase a definition by name (no effect if not defined). + void erase(const std::string &name); + + // Clear any existing definitions + void clear(); + + // Print a list of definitions, using the log function + void log() const; + + std::map<std::string, std::unique_ptr<define_body_t>> defines; +}; + + +struct define_map_t; + +std::string +frontend_verilog_preproc(std::istream &f, + std::string filename, + const define_map_t &pre_defines, + define_map_t &global_defines_cache, + const std::list<std::string> &include_dirs); + +YOSYS_NAMESPACE_END + +#endif |