mirror of https://github.com/YosysHQ/yosys.git
Compare commits
18 Commits
9996cc909d
...
0bb2e09af1
Author | SHA1 | Date |
---|---|---|
Emil J | 0bb2e09af1 | |
Emil J | 56b80bdd22 | |
Emil J | da8c8b4fd0 | |
Emil J | cc17d5bb70 | |
Emil J | 18459b4b09 | |
Emil J | 88abc4c20f | |
Martin Povišer | 7ebe451f9a | |
Martin Povišer | 1184418cc8 | |
Pepijn de Vos | b8329df1d0 | |
Henner Zeller | a750c94c38 | |
George Rennie | c23e64a236 | |
George Rennie | 626dbbe1e0 | |
George Rennie | de728c9824 | |
George Rennie | 0572f8806f | |
George Rennie | 023f029dcf | |
George Rennie | e105cae4a9 | |
George Rennie | 58af70624f | |
George Rennie | 41aaaa153e |
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "ezminisat.h"
|
#include "ezminisat.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define INIT_X 123456789
|
#define INIT_X 123456789
|
||||||
#define INIT_Y 362436069
|
#define INIT_Y 362436069
|
||||||
|
@ -143,4 +144,3 @@ int main()
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "ezminisat.h"
|
#include "ezminisat.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define INIT_X 123456789
|
#define INIT_X 123456789
|
||||||
#define INIT_Y 362436069
|
#define INIT_Y 362436069
|
||||||
|
@ -109,4 +110,3 @@ int main()
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1273,6 +1273,11 @@ class WFunction:
|
||||||
func.duplicate = False
|
func.duplicate = False
|
||||||
func.namespace = namespace
|
func.namespace = namespace
|
||||||
str_def = str_def.replace("operator ","operator")
|
str_def = str_def.replace("operator ","operator")
|
||||||
|
|
||||||
|
# remove attributes from the start
|
||||||
|
if str.startswith(str_def, "[[") and "]]" in str_def:
|
||||||
|
str_def = str_def[str_def.find("]]")+2:]
|
||||||
|
|
||||||
if str.startswith(str_def, "static "):
|
if str.startswith(str_def, "static "):
|
||||||
func.is_static = True
|
func.is_static = True
|
||||||
str_def = str_def[7:]
|
str_def = str_def[7:]
|
||||||
|
|
|
@ -39,6 +39,10 @@ void demorgan_worker(
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto insig = sigmap(cell->getPort(ID::A));
|
auto insig = sigmap(cell->getPort(ID::A));
|
||||||
|
|
||||||
|
if (GetSize(insig) < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
log("Inspecting %s cell %s (%d inputs)\n", log_id(cell->type), log_id(cell->name), GetSize(insig));
|
log("Inspecting %s cell %s (%d inputs)\n", log_id(cell->type), log_id(cell->name), GetSize(insig));
|
||||||
int num_inverted = 0;
|
int num_inverted = 0;
|
||||||
for(int i=0; i<GetSize(insig); i++)
|
for(int i=0; i<GetSize(insig); i++)
|
||||||
|
|
|
@ -89,6 +89,9 @@ struct OptReduceWorker
|
||||||
RTLIL::SigSpec new_sig_a(new_sig_a_bits);
|
RTLIL::SigSpec new_sig_a(new_sig_a_bits);
|
||||||
new_sig_a.sort_and_unify();
|
new_sig_a.sort_and_unify();
|
||||||
|
|
||||||
|
if (GetSize(new_sig_a) == 0)
|
||||||
|
new_sig_a = (cell->type == ID($reduce_or)) ? State::S0 : State::S1;
|
||||||
|
|
||||||
if (new_sig_a != sig_a || sig_a.size() != cell->getPort(ID::A).size()) {
|
if (new_sig_a != sig_a || sig_a.size() != cell->getPort(ID::A).size()) {
|
||||||
log(" New input vector for %s cell %s: %s\n", cell->type.c_str(), cell->name.c_str(), log_signal(new_sig_a));
|
log(" New input vector for %s cell %s: %s\n", cell->type.c_str(), cell->name.c_str(), log_signal(new_sig_a));
|
||||||
did_something = true;
|
did_something = true;
|
||||||
|
|
|
@ -53,6 +53,11 @@ match add
|
||||||
select port(add, constport).is_fully_const()
|
select port(add, constport).is_fully_const()
|
||||||
define <IdString> varport (constport == \A ? \B : \A)
|
define <IdString> varport (constport == \A ? \B : \A)
|
||||||
|
|
||||||
|
// only optimize for constants up to a fixed width. this prevents cases
|
||||||
|
// with a blowup in internal term size and prevents larger constants being
|
||||||
|
// casted to int incorrectly
|
||||||
|
select (GetSize(port(add, constport)) <= 24)
|
||||||
|
|
||||||
// if a value of var is able to wrap the output, the transformation might give wrong results
|
// if a value of var is able to wrap the output, the transformation might give wrong results
|
||||||
// an addition/substraction can at most flip one more bit than the largest operand (the carry bit)
|
// an addition/substraction can at most flip one more bit than the largest operand (the carry bit)
|
||||||
// as long as the output can show this bit, no wrap should occur (assuming all signed-ness make sense)
|
// as long as the output can show this bit, no wrap should occur (assuming all signed-ness make sense)
|
||||||
|
|
|
@ -262,7 +262,7 @@ void proc_dff(RTLIL::Module *mod, RTLIL::Process *proc, ConstEval &ce)
|
||||||
{
|
{
|
||||||
log_warning("Complex async reset for dff `%s'.\n", log_signal(sig));
|
log_warning("Complex async reset for dff `%s'.\n", log_signal(sig));
|
||||||
gen_dffsr_complex(mod, insig, sig, sync_edge->signal, sync_edge->type == RTLIL::SyncType::STp, async_rules, proc);
|
gen_dffsr_complex(mod, insig, sig, sync_edge->signal, sync_edge->type == RTLIL::SyncType::STp, async_rules, proc);
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a reset condition in the async rules, use it
|
// If there is a reset condition in the async rules, use it
|
||||||
|
@ -277,7 +277,7 @@ void proc_dff(RTLIL::Module *mod, RTLIL::Process *proc, ConstEval &ce)
|
||||||
sync_edge->type == RTLIL::SyncType::STp,
|
sync_edge->type == RTLIL::SyncType::STp,
|
||||||
sync_level && sync_level->type == RTLIL::SyncType::ST1,
|
sync_level && sync_level->type == RTLIL::SyncType::ST1,
|
||||||
sync_edge->signal, sync_level->signal, proc);
|
sync_edge->signal, sync_level->signal, proc);
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
gen_dff(mod, insig, rstval.as_const(), sig_q,
|
gen_dff(mod, insig, rstval.as_const(), sig_q,
|
||||||
|
|
|
@ -65,6 +65,8 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
dirs = [
|
dirs = [
|
||||||
os.path.join(args.gowin_dir, 'IDE/simlib/gw1n/'),
|
os.path.join(args.gowin_dir, 'IDE/simlib/gw1n/'),
|
||||||
|
os.path.join(args.gowin_dir, 'IDE/simlib/gw2a/'),
|
||||||
|
os.path.join(args.gowin_dir, 'IDE/simlib/gw5a/'),
|
||||||
]
|
]
|
||||||
|
|
||||||
with open('cells_xtra.v', 'w') as fout:
|
with open('cells_xtra.v', 'w') as fout:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,15 @@
|
||||||
|
read_ilang <<EOT
|
||||||
|
autoidx 1
|
||||||
|
module \top
|
||||||
|
wire output 1 \Y
|
||||||
|
cell $reduce_or $reduce_or$rtl.v:29$20
|
||||||
|
parameter \A_SIGNED 0
|
||||||
|
parameter \A_WIDTH 0
|
||||||
|
parameter \Y_WIDTH 1
|
||||||
|
connect \A { }
|
||||||
|
connect \Y \Y
|
||||||
|
end
|
||||||
|
end
|
||||||
|
EOT
|
||||||
|
|
||||||
|
equiv_opt -assert opt_demorgan
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Check that opt_reduce doesn't produce zero width $reduce_or/$reduce_and,
|
||||||
|
|
||||||
|
read_verilog <<EOT
|
||||||
|
module reduce_const(output wire o, output wire a);
|
||||||
|
wire [3:0] zero = 4'b0000;
|
||||||
|
wire [3:0] ones = 4'b1111;
|
||||||
|
assign o = |zero;
|
||||||
|
assign a = &ones;
|
||||||
|
endmodule
|
||||||
|
EOT
|
||||||
|
|
||||||
|
equiv_opt -assert opt_reduce
|
||||||
|
design -load postopt
|
||||||
|
select -assert-none r:A_WIDTH=0
|
|
@ -0,0 +1,31 @@
|
||||||
|
read_rtlil <<EOT
|
||||||
|
autoidx 1
|
||||||
|
module \top
|
||||||
|
wire input 1 \clk
|
||||||
|
wire input 2 \rst
|
||||||
|
|
||||||
|
wire input 3 \a_r
|
||||||
|
wire input 4 \a_n
|
||||||
|
wire input 5 \b_n
|
||||||
|
|
||||||
|
wire \a
|
||||||
|
wire \b
|
||||||
|
|
||||||
|
process $proc
|
||||||
|
sync high \rst
|
||||||
|
update \a \a_r
|
||||||
|
update \b \b
|
||||||
|
sync posedge \clk
|
||||||
|
update \a \a_n
|
||||||
|
update \b \b_n
|
||||||
|
end
|
||||||
|
end
|
||||||
|
EOT
|
||||||
|
|
||||||
|
proc_dff
|
||||||
|
proc_clean
|
||||||
|
|
||||||
|
# Processes should have been converted to one aldff and one dff
|
||||||
|
select -assert-none p:*
|
||||||
|
select -assert-count 1 t:$aldff
|
||||||
|
select -assert-count 1 t:$dff
|
Loading…
Reference in New Issue