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

Subversion Repositories turbocodes

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 dbrochart
######################################################################
2
####                                                              ####
3
####  coder.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, posedge, negedge, always_comb, always
44
 
45
def coderState(clk, rst, a, b, q1, q2, q3):
46
    """ Coder state registers.
47
 
48
    clk, rst    -- in  : clock and negative reset
49
    a, b        -- in  : original data
50
    q1, q2, q3  -- out : coder registers
51
 
52
    """
53
    @always(clk.posedge, rst.negedge)
54
    def coderStateLogic():
55
        if rst.val == 0:
56
            q1.next = 0
57
            q2.next = 0
58
            q3.next = 0
59
        else:
60
            q1.next = a.val ^ b.val ^ q1.val ^ q3.val
61
            q2.next = q1.val ^ b.val
62
            q3.next = q2.val ^ b.val
63
    return coderStateLogic
64
 
65
def coderY1Y2(a, b, q1, q2, q3, y1, y2):
66
    """ Coder redundant output generation.
67
 
68
    a, b        -- in  : original data signals
69
    q1, q2, q3  -- in  : coder registers
70
    y1, y2      -- out : coder redundant data signals
71
 
72
    """
73
    @always_comb
74
    def coderY1Y2Logic():
75
        y1.next = a.val ^ b.val ^ q1.val ^ q3.val ^ q2.val ^ q3.val
76
        y2.next = a.val ^ b.val ^ q1.val ^ q3.val ^ q3.val
77
    return coderY1Y2Logic
78
 
79
def coder(clk, rst, a, b, y1, y2):
80
    """ Coder top level.
81
 
82
    clk, rst    -- in  : clock and negative reset
83
    a, b        -- in  : original data signals (= systematic data)
84
    y1, y2      -- out : coder redundant data signals
85
 
86
    """
87
    q1 = Signal(bool(0))
88
    q2 = Signal(bool(0))
89
    q3 = Signal(bool(0))
90
    coderState_i0 = coderState(clk, rst, a, b, q1, q2, q3)
91
    coderY1Y2_i0  = coderY1Y2(a, b, q1, q2, q3, y1, y2)
92
 
93
    return coderState_i0, coderY1Y2_i0

powered by: WebSVN 2.1.0

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