Skip to content

Commit 354691e

Browse files
committed
const in eval too
eval now sets the constant to a const rather than assuming the user has constant propagated everything away.
1 parent f7a795a commit 354691e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

logic/c.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ func (c *C) InPos(dst []int) []int {
203203
// `c` is embedded in a sequential circuit `s`, then
204204
// the inputs include the latches of `s`.
205205
func (c *C) Eval(vs []bool) {
206-
for i := range c.nodes {
206+
N := len(c.nodes)
207+
vs[1] = true
208+
for i := 2; i < N; i++ {
207209
n := &c.nodes[i]
208210
if n.a < 4 {
209211
continue
@@ -224,7 +226,9 @@ func (c *C) Eval(vs []bool) {
224226
// Eval64 is like Eval but evaluates 64 different inputs in
225227
// parallel as the bits of a uint64.
226228
func (c *C) Eval64(vs []uint64) {
227-
for i := range c.nodes {
229+
N := len(c.nodes)
230+
vs[1] = (1 << 63) - 1
231+
for i := 2; i < N; i++ {
228232
n := &c.nodes[i]
229233
if n.a < 4 {
230234
continue

logic/c_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ func TestEval(t *testing.T) {
9292
if !vs[4] {
9393
t.Errorf("bad and eval")
9494
}
95+
if !vs[1] {
96+
t.Errorf("bad const eval")
97+
}
9598
}
9699

97100
var rnd = rand.New(rand.NewSource(1))

0 commit comments

Comments
 (0)