from nmigen import Elaboratable, Module, Signal, Array, unsigned, Const
from nmigen.build import Platform
from nmigen.cli import main_parser, main_runner
from src.ldpc_decoder import LDPC_Decoder

if __name__ == "__main__":
    #Instantiate a command line argument parser
    parser = main_parser()
    args = parser.parse_args()

    #Instantiate an nMigen Module
    m = Module()

    #Instantiate the Parity Check Matrix 'H' for generating ldpc Code Words
    #https://en.wikipedia.org/wiki/Low-density_parity-check_code

    parityCheckMatrix = [[0b111100], [0b001101], [0b100110]]

    #Instantiate the LDPC_Decoder Module with the parity check matrix, input codeword size and output data size as parameters
    m.submodules.LDPC_Decoder = LDPC_Decoder = LDPC_Decoder(
        parityCheckMatrix, 6, 3)

    main_runner(parser,
                args,
                m,
                ports=[
                    LDPC_Decoder.data_input, LDPC_Decoder.data_output,
                    LDPC_Decoder.start, LDPC_Decoder.done, LDPC_Decoder.success
                ])
Esempio n. 2
0
 def setUp(self):
     parityCheckMatrix = [[0b000011100], [0b110000010], [0b001100001],
                          [0b100001010], [0b001000101], [0b010110000]]
     self.dut = LDPC_Decoder(parityCheckMatrix, 9, 4)
    #Delay for 25 clock cycles
    for i in range(25):
        yield Delay(1e-6)
if __name__ == "__main__":

    #Instantiate an nMigen Module
    m = Module()

    #Instantiate the Parity Check Matrix 'H'
    #https://en.wikipedia.org/wiki/Low-density_parity-check_code

    parityCheckMatrix = [[0b000011100], [0b110000010], [0b001100001],
                         [0b100001010], [0b001000101], [0b010110000]]

    #Instantiate the LDPC_Decoder Module with the generator matrix, input codeword size and output data size as parameters
    m.submodules.LDPC_Decoder = LDPC_Decoder = LDPC_Decoder(
        parityCheckMatrix, 9, 4)

    #Simulation

    #[SIGNAL] - data_input - A top level signal which connects the 'data_input' signal on the LDPC Decoder
    data_input = Signal(9)

    #[SIGNAL] - start - A top level signal which connects the 'start' signal on the LDPC Decoder
    start = Signal(1)

    #Link the local data_input and start signals to the LDPC Input Ports
    m.d.comb += LDPC_Decoder.data_input.eq(data_input)
    m.d.comb += LDPC_Decoder.start.eq(start)

    #Create a simulator instance with the local nMigen module which contains the LDPC Decoder
    sim = Simulator(m)
Esempio n. 4
0
if __name__ == "__main__":

    #Instantiate an nMigen Module
    m = Module()
    
    #Instantiate the parity check Matrix 'H'
    #https://en.wikipedia.org/wiki/Low-density_parity-check_code

   
    parityCheckMatrix = [[0b111100],
                         [0b001101],
                         [0b100110] ]

    #Instantiate the LDPC_Decoder Module with the generator matrix and output codeword size as parameters
    m.submodules.LDPC_Decoder = LDPC_Decoder = LDPC_Decoder(parityCheckMatrix,6,3)

    #Simulation

    #[SIGNAL] - data_input - A top level signal which connects the 'data_input' signal on the LDPC Decoder
    data_input = Signal(6)

    #[SIGNAL] - start - A top level signal which connects the 'start' signal on the LDPC Decoder
    start = Signal(1)

    #Link the local data_input and start signals to the LDPC Decoder Input Ports
    m.d.comb += LDPC_Decoder.data_input.eq(data_input)
    m.d.comb += LDPC_Decoder.start.eq(start)

    #Create a simulator instance with the local nMigen module which contains the LDPC Decoder
    sim = Simulator(m)