-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from jandecaluwe/mep-114
MEP 114
- Loading branch information
Showing
174 changed files
with
1,335 additions
and
505 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
def bin2gray(B, G, width): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
ACTIVE_LOW, INACTIVE_HIGH = 0, 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
from dff import dff | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
ACTIVE_LOW, INACTIVE_HIGH = 0, 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
from arith_utils import BEHAVIOR | ||
from PrefixAnd import PrefixAnd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
from arith_utils import BEHAVIOR | ||
from PrefixAnd import PrefixAnd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
from arith_utils import log2ceil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,94 @@ | ||
import subprocess | ||
|
||
import myhdl | ||
from myhdl import * | ||
from myhdl.conversion import analyze | ||
|
||
DESCENDING, ASCENDING = False, True | ||
|
||
def compare(a1, a2, z1, z2, dir): | ||
|
||
@block | ||
def comp(a1, a2, z1, z2, dir): | ||
|
||
@always_comb | ||
def logic(): | ||
z1.next = a1 | ||
z2.next = a2 | ||
if dir == (a1 > a2): | ||
z1.next = a2 | ||
z2.next = a1 | ||
|
||
return logic | ||
|
||
|
||
@block | ||
def feedthru(a, z): | ||
|
||
@always_comb | ||
def logic(): | ||
z.next = a | ||
|
||
return logic | ||
|
||
|
||
@block | ||
def bitonicMerge(a, z, dir): | ||
|
||
n = len(a) | ||
k = n//2 | ||
w = len(a[0]) | ||
|
||
if n > 1: | ||
t = [Signal(intbv(0)[w:]) for i in range(n)] | ||
comp = [compare(a[i], a[i+k], t[i], t[i+k], dir) for i in range(k)] | ||
loMerge = bitonicMerge(t[:k], z[:k], dir) | ||
hiMerge = bitonicMerge(t[k:], z[k:], dir) | ||
return comp, loMerge, hiMerge | ||
comps = [comp(a[i], a[i+k], t[i], t[i+k], dir) for i in range(k)] | ||
lomerge = bitonicMerge(t[:k], z[:k], dir) | ||
himerge = bitonicMerge(t[k:], z[k:], dir) | ||
lomerge.name = "lomerge" | ||
himerge.name = "hiMerge" | ||
return comps, lomerge, himerge | ||
else: | ||
feed = feedthru(a[0], z[0]) | ||
return feed | ||
return feedthru(a[0], z[0]) | ||
|
||
|
||
@block | ||
def bitonicSort(a, z, dir): | ||
|
||
n = len(a) | ||
k = n//2 | ||
w = len(a[0]) | ||
|
||
if n > 1: | ||
t = [Signal(intbv(0)[w:]) for i in range(n)] | ||
loSort = bitonicSort(a[:k], t[:k], ASCENDING) | ||
hiSort = bitonicSort(a[k:], t[k:], DESCENDING) | ||
losort = bitonicSort(a[:k], t[:k], ASCENDING) | ||
hisort = bitonicSort(a[k:], t[k:], DESCENDING) | ||
merge = bitonicMerge(t, z, dir) | ||
return loSort, hiSort, merge | ||
losort.name = "losort" | ||
hisort.name = "hisort" | ||
merge.name = "merge" | ||
return losort, hisort, merge | ||
else: | ||
feed = feedthru(a[0], z[0]) | ||
return feed | ||
|
||
return feedthru(a[0], z[0]) | ||
|
||
@block | ||
def Array8Sorter(a0, a1, a2, a3, a4, a5, a6, a7, | ||
z0, z1, z2, z3, z4, z5, z6, z7): | ||
|
||
a = [a0, a1, a2, a3, a4, a5, a6, a7] | ||
z = [z0, z1, z2, z3, z4, z5, z6, z7] | ||
sort = bitonicSort(a, z, ASCENDING) | ||
sort.name = "sort" | ||
return sort | ||
|
||
|
||
def Array8Sorter_v(a0, a1, a2, a3, a4, a5, a6, a7, | ||
z0, z1, z2, z3, z4, z5, z6, z7): | ||
|
||
analyze.simulator = 'iverilog' | ||
toVerilog(Array8Sorter, a0, a1, a2, a3, a4, a5, a6, a7, | ||
z0, z1, z2, z3, z4, z5, z6, z7) | ||
analyze(Array8Sorter, a0, a1, a2, a3, a4, a5, a6, a7, | ||
z0, z1, z2, z3, z4, z5, z6, z7) | ||
toVerilog(Array8Sorter(a0, a1, a2, a3, a4, a5, a6, a7, | ||
z0, z1, z2, z3, z4, z5, z6, z7)) | ||
analyze(Array8Sorter(a0, a1, a2, a3, a4, a5, a6, a7, | ||
z0, z1, z2, z3, z4, z5, z6, z7)) | ||
# cmd = "cver -q +loadvpi=../../../cosimulation/cver/myhdl_vpi:vpi_compat_bootstrap " + \ | ||
# "Array8Sorter.v tb_Array8Sorter.v" | ||
subprocess.call("iverilog -o Array8Sorter.o Array8Sorter.v tb_Array8Sorter.v", shell=True) | ||
cmd = "vvp -m ../../../cosimulation/icarus/myhdl.vpi Array8Sorter.o" | ||
return Cosimulation(cmd, **locals()) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
from myhdl.conversion import analyze | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
def dffa(q, d, clk, rst): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
ACTIVE = 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
ACTIVE = 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
ACTIVE, INACTIVE = bool(0), bool(1) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
def latch(q, d, g): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
from TimeCount import TimeCount | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
def TimeCount(tens, ones, tenths, startstop, reset, clock): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import seven_segment | ||
|
||
import myhdl | ||
from myhdl import * | ||
|
||
code = [None] * 10 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from random import randrange | ||
|
||
import myhdl | ||
from myhdl import * | ||
|
||
from TimeCount import TimeCount | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from random import randrange | ||
import seven_segment | ||
import myhdl | ||
from myhdl import * | ||
from bcd2led import bcd2led | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
from bin2gray2 import bin2gray | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
def bin2gray(B, G, width): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import myhdl | ||
from myhdl import * | ||
|
||
def inc_comb(nextCount, count, n): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import sys | ||
import traceback | ||
|
||
import myhdl | ||
from myhdl import * | ||
|
||
class Error(Exception): | ||
|
Oops, something went wrong.