Skip to content

Commit

Permalink
const in eval too
Browse files Browse the repository at this point in the history
eval now sets the constant to a const rather
than assuming the user has constant propagated
everything away.
  • Loading branch information
wsc1 committed Nov 14, 2018
1 parent f7a795a commit 354691e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions logic/c.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ func (c *C) InPos(dst []int) []int {
// `c` is embedded in a sequential circuit `s`, then
// the inputs include the latches of `s`.
func (c *C) Eval(vs []bool) {
for i := range c.nodes {
N := len(c.nodes)
vs[1] = true
for i := 2; i < N; i++ {
n := &c.nodes[i]
if n.a < 4 {
continue
Expand All @@ -224,7 +226,9 @@ func (c *C) Eval(vs []bool) {
// Eval64 is like Eval but evaluates 64 different inputs in
// parallel as the bits of a uint64.
func (c *C) Eval64(vs []uint64) {
for i := range c.nodes {
N := len(c.nodes)
vs[1] = (1 << 63) - 1
for i := 2; i < N; i++ {
n := &c.nodes[i]
if n.a < 4 {
continue
Expand Down
3 changes: 3 additions & 0 deletions logic/c_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func TestEval(t *testing.T) {
if !vs[4] {
t.Errorf("bad and eval")
}
if !vs[1] {
t.Errorf("bad const eval")
}
}

var rnd = rand.New(rand.NewSource(1))
Expand Down

0 comments on commit 354691e

Please sign in to comment.