File: lfsr24.py

package info (click to toggle)
myhdl 0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,728 kB
  • sloc: python: 25,033; ansic: 2,203; makefile: 243; sh: 206
file content (18 lines) | stat: -rw-r--r-- 436 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from __future__ import absolute_import
import myhdl
from myhdl import *

def lfsr24(lfsr, enable, clock, reset):

    @always(clock.posedge, reset.posedge)
    def logic():
        if reset == 1:
            lfsr.next = 1
        else:
            if enable:
                # lfsr.next[24:1] = lfsr[23:0]
                lfsr.next = lfsr << 1
                lfsr.next[0] = lfsr[23] ^ lfsr[22] ^ lfsr[21] ^ lfsr[16]

    return logic