Skip to content

Instantly share code, notes, and snippets.

from myhdl import *
def switchchannels(mem2d, q, clk):
def assign_los(mem1d_a, mem1d_b):
print(mem1d_a, mem1d_b)
for i in range(len(mem1d_a)):
mem1d_a[i].next = mem1d_b[i]
return mem1d_a
@ravijain056
ravijain056 / mem2d.py
Last active August 29, 2015 14:17
2d list example
from myhdl import *
def switchchannels(mem2d, q, clk):
def assign_los(mem1d_a, mem1d_b):
print(mem1d_a, mem1d_b)
for i in range(len(mem1d_a)):
mem1d_a[i].next = mem1d_b[i]
return mem1d_a
# say u have 3 channels transmitting 4-bit signals
a = [[1,0,0,1],[1,1,0,0],[1,1,0,1]]
# say u flatten it to get b
b = [1,0,0,1,1,1,0,0,1,1,0,1]
#so when you wish to access signal in 3rd channel you need to
print(a[2])
print(b[4*(2-1):4*(2)])
#now when you just wish to assign channel 2 to 3 and 3 to 2...problem would really start to exponentially increase in
#flattened part and the point of generalising ND list using flattening seems to be lost...please correct me if i am wrng..