mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-25 15:23:42 +00:00
Merge branch 'YosysHQ:main' into main
This commit is contained in:
commit
63a7996cb4
4 changed files with 18 additions and 54 deletions
|
@ -18,32 +18,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// https://stackoverflow.com/a/46137633
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include <stdlib.h>
|
|
||||||
#define bswap32 _byteswap_ulong
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#include <libkern/OSByteOrder.h>
|
|
||||||
#define bswap32 OSSwapInt32
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
#define bswap32 __builtin_bswap32
|
|
||||||
#else
|
|
||||||
#include <cstdint>
|
|
||||||
inline static uint32_t bswap32(uint32_t x)
|
|
||||||
{
|
|
||||||
// https://stackoverflow.com/a/27796212
|
|
||||||
register uint32_t value = number_to_be_reversed;
|
|
||||||
uint8_t lolo = (value >> 0) & 0xFF;
|
|
||||||
uint8_t lohi = (value >> 8) & 0xFF;
|
|
||||||
uint8_t hilo = (value >> 16) & 0xFF;
|
|
||||||
uint8_t hihi = (value >> 24) & 0xFF;
|
|
||||||
return (hihi << 24)
|
|
||||||
| (hilo << 16)
|
|
||||||
| (lohi << 8)
|
|
||||||
| (lolo << 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "kernel/yosys.h"
|
#include "kernel/yosys.h"
|
||||||
#include "kernel/sigtools.h"
|
#include "kernel/sigtools.h"
|
||||||
#include "kernel/utils.h"
|
#include "kernel/utils.h"
|
||||||
|
@ -52,16 +26,6 @@ inline static uint32_t bswap32(uint32_t x)
|
||||||
USING_YOSYS_NAMESPACE
|
USING_YOSYS_NAMESPACE
|
||||||
PRIVATE_NAMESPACE_BEGIN
|
PRIVATE_NAMESPACE_BEGIN
|
||||||
|
|
||||||
inline int32_t to_big_endian(int32_t i32) {
|
|
||||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
|
||||||
return bswap32(i32);
|
|
||||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
||||||
return i32;
|
|
||||||
#else
|
|
||||||
#error "Unknown endianness"
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void aiger_encode(std::ostream &f, int x)
|
void aiger_encode(std::ostream &f, int x)
|
||||||
{
|
{
|
||||||
log_assert(x >= 0);
|
log_assert(x >= 0);
|
||||||
|
@ -537,9 +501,12 @@ struct XAigerWriter
|
||||||
|
|
||||||
f << "c";
|
f << "c";
|
||||||
|
|
||||||
auto write_buffer = [](std::stringstream &buffer, int i32) {
|
auto write_buffer = [](std::ostream &buffer, unsigned int u32) {
|
||||||
int32_t i32_be = to_big_endian(i32);
|
typedef unsigned char uchar;
|
||||||
buffer.write(reinterpret_cast<const char*>(&i32_be), sizeof(i32_be));
|
unsigned char u32_be[4] = {
|
||||||
|
(uchar) (u32 >> 24), (uchar) (u32 >> 16), (uchar) (u32 >> 8), (uchar) u32
|
||||||
|
};
|
||||||
|
buffer.write((char *) u32_be, sizeof(u32_be));
|
||||||
};
|
};
|
||||||
std::stringstream h_buffer;
|
std::stringstream h_buffer;
|
||||||
auto write_h_buffer = std::bind(write_buffer, std::ref(h_buffer), std::placeholders::_1);
|
auto write_h_buffer = std::bind(write_buffer, std::ref(h_buffer), std::placeholders::_1);
|
||||||
|
@ -640,14 +607,12 @@ struct XAigerWriter
|
||||||
|
|
||||||
f << "r";
|
f << "r";
|
||||||
std::string buffer_str = r_buffer.str();
|
std::string buffer_str = r_buffer.str();
|
||||||
int32_t buffer_size_be = to_big_endian(buffer_str.size());
|
write_buffer(f, buffer_str.size());
|
||||||
f.write(reinterpret_cast<const char*>(&buffer_size_be), sizeof(buffer_size_be));
|
|
||||||
f.write(buffer_str.data(), buffer_str.size());
|
f.write(buffer_str.data(), buffer_str.size());
|
||||||
|
|
||||||
f << "s";
|
f << "s";
|
||||||
buffer_str = s_buffer.str();
|
buffer_str = s_buffer.str();
|
||||||
buffer_size_be = to_big_endian(buffer_str.size());
|
write_buffer(f, buffer_str.size());
|
||||||
f.write(reinterpret_cast<const char*>(&buffer_size_be), sizeof(buffer_size_be));
|
|
||||||
f.write(buffer_str.data(), buffer_str.size());
|
f.write(buffer_str.data(), buffer_str.size());
|
||||||
|
|
||||||
RTLIL::Design *holes_design;
|
RTLIL::Design *holes_design;
|
||||||
|
@ -664,22 +629,19 @@ struct XAigerWriter
|
||||||
|
|
||||||
f << "a";
|
f << "a";
|
||||||
std::string buffer_str = a_buffer.str();
|
std::string buffer_str = a_buffer.str();
|
||||||
int32_t buffer_size_be = to_big_endian(buffer_str.size());
|
write_buffer(f, buffer_str.size());
|
||||||
f.write(reinterpret_cast<const char*>(&buffer_size_be), sizeof(buffer_size_be));
|
|
||||||
f.write(buffer_str.data(), buffer_str.size());
|
f.write(buffer_str.data(), buffer_str.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
f << "h";
|
f << "h";
|
||||||
std::string buffer_str = h_buffer.str();
|
std::string buffer_str = h_buffer.str();
|
||||||
int32_t buffer_size_be = to_big_endian(buffer_str.size());
|
write_buffer(f, buffer_str.size());
|
||||||
f.write(reinterpret_cast<const char*>(&buffer_size_be), sizeof(buffer_size_be));
|
|
||||||
f.write(buffer_str.data(), buffer_str.size());
|
f.write(buffer_str.data(), buffer_str.size());
|
||||||
|
|
||||||
f << "i";
|
f << "i";
|
||||||
buffer_str = i_buffer.str();
|
buffer_str = i_buffer.str();
|
||||||
buffer_size_be = to_big_endian(buffer_str.size());
|
write_buffer(f, buffer_str.size());
|
||||||
f.write(reinterpret_cast<const char*>(&buffer_size_be), sizeof(buffer_size_be));
|
|
||||||
f.write(buffer_str.data(), buffer_str.size());
|
f.write(buffer_str.data(), buffer_str.size());
|
||||||
//f << "o";
|
//f << "o";
|
||||||
//buffer_str = o_buffer.str();
|
//buffer_str = o_buffer.str();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
# You can set these variables from the command line.
|
# You can set these variables from the command line.
|
||||||
SPHINXOPTS =
|
SPHINXOPTS = -W --keep-going
|
||||||
SPHINXBUILD = sphinx-build
|
SPHINXBUILD = sphinx-build
|
||||||
PAPER =
|
PAPER =
|
||||||
BUILDDIR = build
|
BUILDDIR = build
|
||||||
|
|
|
@ -131,9 +131,11 @@ struct FfData {
|
||||||
bool is_fine;
|
bool is_fine;
|
||||||
// True if this FF is an $anyinit cell. Depends on has_gclk.
|
// True if this FF is an $anyinit cell. Depends on has_gclk.
|
||||||
bool is_anyinit;
|
bool is_anyinit;
|
||||||
// Polarities, corresponding to sig_*. True means active-high, false
|
// Polarities, corresponding to sig_*.
|
||||||
// means active-low.
|
// True means rising edge, false means falling edge.
|
||||||
bool pol_clk;
|
bool pol_clk;
|
||||||
|
// True means active-high, false
|
||||||
|
// means active-low.
|
||||||
bool pol_ce;
|
bool pol_ce;
|
||||||
bool pol_aload;
|
bool pol_aload;
|
||||||
bool pol_arst;
|
bool pol_arst;
|
||||||
|
|
|
@ -70,11 +70,11 @@ std::optional<uint64_t> current_mem_bytes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct InternalStatsPass : public Pass {
|
struct InternalStatsPass : public Pass {
|
||||||
InternalStatsPass() : Pass("internal_stats", "print some internal statistics") { }
|
InternalStatsPass() : Pass("internal_stats", "print internal statistics") { }
|
||||||
void help() override
|
void help() override
|
||||||
{
|
{
|
||||||
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
||||||
log("\n"); // TODO
|
log("Print internal statistics for developers (experimental)\n");
|
||||||
}
|
}
|
||||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue