Skip to content

Commit ef0d426

Browse files
committed
update readme
1 parent d56a2a1 commit ef0d426

9 files changed

Lines changed: 523 additions & 18 deletions

File tree

BCJR_K3_75.c

Lines changed: 440 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,66 @@
11
# 信道编码课程大作业 (Channel Coding Course Work)
22

3-
这是一个关于卷积码编码与 Viterbi 译码(硬判决/软判决)的 C 语言实现项目。
3+
![Build Status](https://github.com/Yauanyyy/InformationTheory/actions/workflows/run_simulation.yml/badge.svg)
4+
![Language](https://img.shields.io/badge/language-C%20%7C%20Python-blue.svg)
45

5-
## 📁 文件说明
6+
本项目是信道编码课程的大作业实现。主要包含 **(2,1,3) 卷积码** 的编码器以及基于 **Viterbi 算法** 的硬判决与软判决译码器的 C 语言实现。
67

7-
* `template.c`: 老师提供的原始代码模板。
8-
* `Viterbi_Hard_K3_75.c`: **当前主程序**。包含卷积编码器和**硬判决** Viterbi 译码器的实现。
9-
* `print_stateTABLE.c`: 一个辅助工具,用于打印和检查状态转移表 (State Table) 的逻辑是否正确。
10-
* `.gitignore`: 配置文件,用于忽略编译生成的 `.exe`, `.o` 等临时文件。
8+
## 📂 文件结构
119

12-
## ✅ 任务进度 (To-Do List)
10+
```text
11+
.
12+
├── Viterbi_Hard_K3_75.c # 硬判决 Viterbi 仿真主程序
13+
├── Viterbi_Soft_K3_75.c # 软判决 Viterbi 仿真主程序
14+
├── print_stateTABLE.c # 状态转移表验证工具
15+
├── plot_new.py # 自动化绘图脚本 (Python)
16+
├── .github/workflows/ # GitHub Actions 自动化配置
17+
├── zoutput/ # 仿真数据输出目录 (.csv)
18+
└── pictures/ # 结果图输出目录 (.png)
19+
```
1320

14-
- [x] **编码器 (Encoder)**: 完成状态表生成与编码逻辑。
15-
- [x] **硬判决译码 (Hard Viterbi)**: 完成 Hamming 距离计算与回溯算法。
16-
- [x] **软判决译码 (Soft Viterbi)**: 需修改度量计算方式 (Euclidean distance)。
17-
- [x] **性能仿真 (Simulation)**: 导出 BER vs SNR 数据并绘图。
18-
- [ ] **(可选) BCJR**
19-
- [ ] **(可选) Turbo: 进阶任务。**
21+
## 🚀 快速开始 (How to Run)
22+
23+
### 方式一:GitHub Actions (推荐)
24+
25+
无需本地环境,直接在网页操作:
26+
27+
1. 点击仓库上方 **Actions** -\> 选择 **Simulation and Plotting**
28+
2. 点击 **Run workflow**
29+
3. 运行结束后在 **Artifacts** 处下载结果(含 CSV 数据与高清对比图)。
30+
31+
### 方式二:本地运行
32+
33+
需要 GCC 与 Python 环境:
34+
35+
```bash
36+
# 1. 编译
37+
gcc Viterbi_Hard_K3_75.c -o viterbi_hard -lm
38+
gcc Viterbi_Soft_K3_75.c -o viterbi_soft -lm
39+
40+
# 2. 运行仿真 (示例: 0-10dB, 10000帧)
41+
# 使用 echo 自动输入参数: 起始SNR 终止SNR 帧数
42+
echo "0 10 10000" | ./viterbi_hard
43+
echo "0 10 10000" | ./viterbi_soft
44+
45+
# 3. 绘图
46+
# 注意:请手动将生成的 .csv 移动至 zoutput/ 文件夹
47+
python plot_new.py
48+
```
49+
50+
## 📊 仿真结果
51+
52+
下图展示了 K=3, (7,5) 卷积码的性能对比(软判决相比硬判决约有 2dB 增益):
53+
54+
> *请运行仿真后查看 `pictures/` 目录下的结果图*
55+
56+
## ✅ 任务进度
57+
58+
- [x] **编码器 (Encoder)**: 完成状态表生成与编码逻辑。
59+
- [x] **硬判决译码 (Hard Viterbi)**: 完成 Hamming 距离计算与回溯。
60+
- [x] **软判决译码 (Soft Viterbi)**: 完成 Euclidean 距离计算。
61+
- [x] **自动化流水线**: GitHub Actions 自动编译绘图。
62+
- [ ] **(可选) BCJR / Turbo 码**: 待进阶实现。
63+
64+
-----
65+
66+
*Created by ZZ, LSH, HZH*

Viterbi_Soft_K3_75.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/***************************************************
2-
Channel Coding Course Work: Convolutional Codes (Soft Decision)
2+
Channel Coding Course Work: conolutional codes
3+
This program template has given the message generator, BPSK modulation, AWGN channel model and BPSK demodulation,
4+
you should first determine the encoder structure, then define the message and codeword length, generate the state table, write the convolutional encoder and decoder.
5+
6+
If you have any question, please contact me via e-mail: liangjw59@mail2.sysu.edu.cn, or, yangzhj59@mail2.sysu.edu.cn.
37
***************************************************/
48

59
#define _CRT_SECURE_NO_WARNINGS

pictures/ber_plot_academic.png

3.4 KB
Loading

pictures/ber_plot_modern.png

10.7 KB
Loading

pictures/ber_plot_presentation.png

7.26 KB
Loading

plot_new.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# ================= 风格配置区域 =================
88

99
# 选项: "ACADEMIC", "MODERN", "PRESENTATION"
10-
STYLE_OPTION = "PRESENTATION"
10+
STYLE_OPTION = "ACADEMIC"
1111

1212
# 路径配置
1313
csv_dir = "zoutput"
@@ -17,7 +17,7 @@
1717
curves = {
1818
"Hard Decision Viterbi": "hard_viterbi.csv",
1919
"Soft Decision Viterbi": "soft_viterbi.csv",
20-
# "BCJR": "bcjr.csv",
20+
"BCJR": "bcjr_soft.csv",
2121
"Uncoded BPSK (Theory)": "theory"
2222
}
2323

@@ -72,7 +72,7 @@ def plot_ber():
7272
markers = ['o', '^', 's', 'D', 'v', 'x']
7373

7474
# --- 定义线型列表 (学术风可能需要实线虚线交替) ---
75-
linestyles = ['-', '-', '-', '-']
75+
linestyles = ['-', '--', '-', '--']
7676

7777
idx = 0 # 用于轮询颜色和标记
7878

plot_old.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
curves = {
2020
"Hard Decision Viterbi": "hard_viterbi.csv",
2121
# "Soft Decision Viterbi": "soft_viterbi.csv",
22-
# "BCJR": "bcjr.csv",
22+
# "BCJR": "bcjr_soft.csv",
2323
"Uncoded BPSK (Theory)": "theory"
2424
}
2525

zoutput/bcjr_soft.csv

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
SNR,BER
2+
0.000000,8.755680E-02
3+
1.000000,3.991950E-02
4+
2.000000,1.376660E-02
5+
3.000000,3.497200E-03
6+
4.000000,6.481000E-04
7+
5.000000,8.080000E-05
8+
6.000000,6.400000E-06
9+
7.000000,4.000000E-07
10+
8.000000,0.000000E+00
11+
9.000000,0.000000E+00
12+
10.000000,0.000000E+00
13+
11.000000,0.000000E+00
14+
12.000000,0.000000E+00

0 commit comments

Comments
 (0)