OpenCores
URL https://opencores.org/ocsvn/turbocodes/turbocodes/trunk

Subversion Repositories turbocodes

[/] [turbocodes/] [trunk/] [src/] [myhdl/] [permut.py] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 dbrochart
######################################################################
2
####                                                              ####
3
####  permut.py                                                   ####
4
####                                                              ####
5
####  This file is part of the turbo decoder IP core project      ####
6
####  http://www.opencores.org/projects/turbocodes/               ####
7
####                                                              ####
8
####  Author(s):                                                  ####
9
####      - David Brochart(dbrochart@opencores.org)               ####
10
####                                                              ####
11
####  All additional information is available in the README.txt   ####
12
####  file.                                                       ####
13
####                                                              ####
14
######################################################################
15
####                                                              ####
16
#### Copyright (C) 2005 Authors                                   ####
17
####                                                              ####
18
#### This source file may be used and distributed without         ####
19
#### restriction provided that this copyright statement is not    ####
20
#### removed from the file and that any derivative work contains  ####
21
#### the original copyright notice and the associated disclaimer. ####
22
####                                                              ####
23
#### This source file is free software; you can redistribute it   ####
24
#### and/or modify it under the terms of the GNU Lesser General   ####
25
#### Public License as published by the Free Software Foundation; ####
26
#### either version 2.1 of the License, or (at your option) any   ####
27
#### later version.                                               ####
28
####                                                              ####
29
#### This source is distributed in the hope that it will be       ####
30
#### useful, but WITHOUT ANY WARRANTY; without even the implied   ####
31
#### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ####
32
#### PURPOSE. See the GNU Lesser General Public License for more  ####
33
#### details.                                                     ####
34
####                                                              ####
35
#### You should have received a copy of the GNU Lesser General    ####
36
#### Public License along with this source; if not, download it   ####
37
#### from http://www.opencores.org/lgpl.shtml                     ####
38
####                                                              ####
39
######################################################################
40
 
41
 
42
 
43
from myhdl import Signal, instance
44
 
45
def zPermut(flipflop, z, zPerm, flip = 0):
46
    """ Extrinsic information permutation.
47
 
48
    flip        -- initialisation (permutation on/off)
49
    flipflop    -- in  : permutation control signal (on/off)
50
    z           -- in  : original extrinsic information
51
    zPerm       -- out : permuted extrinsic information
52
 
53
    """
54
    @instance
55
    def zPermutLogic():
56
        while 1:
57
            if flipflop.val == bool(flip):
58
                zPerm[0].next = z[0].val
59
                zPerm[1].next = z[1].val
60
                zPerm[2].next = z[2].val
61
                zPerm[3].next = z[3].val
62
            else:
63
                zPerm[0].next = z[0].val
64
                zPerm[1].next = z[2].val
65
                zPerm[2].next = z[1].val
66
                zPerm[3].next = z[3].val
67
            yield flipflop, z[0], z[1], z[2], z[3]
68
    return zPermutLogic
69
 
70
def abPermut(flipflop, a, b, abPerm, flip = 0):
71
    """ Systematic information permutation.
72
 
73
    flip        -- initialisation (permutation on/off)
74
    flipflop    -- in  : permutation control signal (on/off)
75
    a, b        -- in  : original systematic information
76
    abPerm      -- out : permuted systematic information
77
 
78
    """
79
    @instance
80
    def abPermutLogic():
81
        while 1:
82
            if flipflop.val == bool(flip):
83
                abPerm[1].next = a.val
84
                abPerm[0].next = b.val
85
            else:
86
                abPerm[1].next = b.val
87
                abPerm[0].next = a.val
88
            yield flipflop, a, b
89
    return abPermutLogic

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.