2024年终总结

这是一篇写在2025年初的2024年的年终总结,是一篇流水账文章,感觉一切过的好快,又要过年了,在2024年所做的事情有一些甚至都想不起来了,但感觉这一年收获了一些,却还是不够。随着年龄越来越大,日益感觉到了紧迫,也越来越想躺平或者懈怠,不愿意干任何事情,想发呆,想默默的待着。有时候也会遇到了学习上的困难,更想去回避,甚至不想学习或深挖一些内容。

2024年 在leetcode上也刷了一些题,几乎每天都刷,但是没有深入进行,都是围绕着一些基础类型的题,有的时候也会想放弃打退堂鼓。

同时也学习了操作系统和一生一芯,复习了以前学的C语言,以及接触了一些新的工具,需要记忆的东西也变多了,例如:verilator、make/makefile、cmake、gtkwave、systemc,越发觉得知识浩瀚无边,该学的东西太多了。

我只能一个一个工具去学习,去安装有从源码安装也有直接使用apt进行安装,再去看man,去google关于这个工具的document,开始对tutorial,getting started xxx或example进行系统性的学习和分析,然后掌握工具的使用,以及与其他工具进行配合使用等,这可能是最笨的方法了。

有的时候会遇到连某个工具的getting started或tutorial都看不下去,只想速成; 有的时候也会有好几天卡在一个问题上无法进行下去,甚至连工具的example运行都会报出一些莫名其妙的错误; 有的时候也会想放弃,不知道学习这些是为了什么,后续能干啥,会有点小emo,学习的路上也是比较孤单,没有任何交流。

2024年没考什么证,这一点不如2022年和2023年(那两年考了cka/ckad/cks和软考系统工程师),计划2025年考一个但是没想好考什么,单位的报销目录下面目前没有几个感兴趣并且有用的能考的证书。

使用github/cloudflare进行了hexo博客的搭建,但是还有很多配置没有做,看着有点简单,抽空弄一弄各种配置。

每到下午偶尔想来杯瑞幸9.9元的美式咖啡,感觉冰凉又解渴,还有一种苦涩的快乐

2024年夏天那几个周末,去了白洋淀、保定、廊坊、济南游玩了,感觉周末两天也可以去北京周边很多地方,体验感保定是最佳的,有一个驴肉套皮非常好吃。

兴趣上发展了航模RC,购买了一些设备、整机、电源电池等,学习了遥控器opentx/edgetx系统的使用,例如:input/mixed/output混控。
计划2025年春节回老家试一试,飞一下好好玩。

计划2025年再发展一下音乐,先计划使用库乐队进行启蒙学习,然后再使用具体的乐器进行深入学习,包括钢琴和木吉他/电吉他。

计划2025年把博客进行完善一下,目前还是处于毛坯状态,需要进行软装了。

应该抽一些时间去复习一下2024年发在csdn上的博客文章,偷偷看了一眼感觉大部分文章都忘记了非常陌生了,甚至感觉这不是自己写的博客了。

还有两个星期就放假了,享受这段工作不那么忙的时间,去做一些自己想做的事情。

学习verilator-笔记1

笔记1所包括的范围

verilator安装

我的电脑是Linux Ubuntu 24.04.1 LTS (vmware虚拟机x86) 和 Linux UnionTech OS Desktop 20 Pro(真实机器aarch64)
安装方法有两种:
第一种是直接使用apt进行安装
apt-get install verilator
第二种是通过编译的方式(我采用这种方法)
根据ysyx的手册,我们安装v5.008版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
前提条件,需要预先安装一些包用于编译:
#sudo apt-get install git help2man perl python3 make autoconf g++ flex bison ccache
#sudo apt-get install libgoogle-perftools-dev numactl perl-doc
#sudo apt-get install libfl2 # Ubuntu only (ignore if gives error)
#sudo apt-get install libfl-dev # Ubuntu only (ignore if gives error)
#sudo apt-get install zlibc zlib1g zlib1g-dev # Ubuntu only (ignore if gives error)

git clone https://github.com/verilator/verilator # Only first time

# Every time you need to build:
unsetenv VERILATOR_ROOT # For csh; ignore error if on bash
unset VERILATOR_ROOT # For bash
cd verilator
git pull # Make sure git repository is up-to-date
git tag # See what versions exist
# 这里的版本与 文档保持一致,v5.008
git checkout v{version} # Switch to specified release version

![v5.008](https://telegraph-image-cnr.pages.dev/api/rfile/verilator1-1.png)

autoconf # Create ./configure script
./configure # Configure and create Makefile
make -j `nproc` # Build Verilator itself (if error, try just 'make')
sudo make install

systemc安装

官方安装步骤

我自己的安装步骤:

  1. 下载systemc并解压
    1
    2
    3
    4
    5
    6
     tar -xzvf systemc-3.0.1.tar.gz
    2. 进入systemc目录并创建临时目录objdir
    ```bash
    cd systemc-3.0.1
    mkdir objdir
    cd objdir
  2. 配置
    1
    2
    3
    4
    5
      ../configure
    or
    ../configure 'CXXFLAGS=-std=c++17'
    or
    ../configure --prefix=/usr/local/systemc-3.0.0
  3. 编译
    1
    make
  4. 编译和运行子文件夹中的案例
    1
    make check
    ![Testsuite summary for SystemC 3.0.0](https://telegraph-image-cnr.pages.dev/api/rfile/verilator1-2.png)
    ![Testsuite summary for TLM 2.0.6](https://telegraph-image-cnr.pages.dev/api/rfile/verilator1-3.png)
    
  5. 安装
    1
    make install
    7. 添加环境变量
    
    1
    2
    3
    4
    echo "# SystemC Install path" >> ~/.bashrc
    echo "export SYSTEMC_HOME=$HOME/Program/systemc-3.0.1" >> ~/.bashrc
    echo "export SYSTEMC_INCLUDE=$SYSTEMC_HOME/include" >> ~/.bashrc
    echo "export SYSTEMC_LIBDIR=$SYSTEMC_HOME/lib-linuxaarch64" >> ~/.bashrc

verilator使用

verilator不是一个传统的仿真器而是一个编译器,用于将verilog和systemverilog等硬件描述语言转换为C++或SystemC模型,编译后可执行。
verilator给的案例中,有一个是Example C++ Execution,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
mkdir test_our
cd test_our
cat >our.v <<'EOF'
module our;
initial begin
$display("Hello World");
$finish;
end
endmodule
EOF

cat >sim_main.cpp <<'EOF'
#include "Vour.h"
#include "verilated.h"
int main(int argc, char** argv) {
VerilatedContext* contextp = new VerilatedContext;
contextp->commandArgs(argc, argv);
Vour* top = new Vour{contextp};
while (!contextp->gotFinish()) { top->eval(); }
delete top;
delete contextp;
return 0;
}
EOF

编译并运行

1
2
verilator --cc --exe --build -j 0 -Wall sim_main.cpp our.v
obj_dir/Vour

gtkwave安装

GTKWave是一个基于Unix/Win32/MacOSX的全特性的示波器,类似于学习物理或通信所用的物理示波器,可以支持FST、LXT、LXT2、VZT、GHW和标准verilog VCD/EVCD等格式,主要用于挑食Verilog和VHDL仿真模型,它是通过分析采集后的dumpfiles文件进行分析,而不是实时交互式的那种示波器,支持模拟数据或数字数据,支持各种搜索操作,可从信号波形中提取感兴趣的,也可以通过PostScript和FrameMaker格式生成输出。

这个组件的安装就很随意了,直接使用apt进行安装

1
sudo apt install gtkwave

gtkwave使用

我们直接按照它提供的案例进行说明。
example代码下载到本地
这个例子是des加密即des.v, 我的当前系统并没有安装iverilog软件,咱们这里仅是将现有的des.fst转换为vcd

1
$ fst2vcd des.fst > des.vcd

我们会发现这个以.vcd为结尾的文件比.fst文件大很多,推荐使用.fst文件,后面会说如何将.vcd文件自动转化为.fst文件。
.vcd vs .fst

下一步,我们通过verilator生成一个stems文件

1
2
verilator -Wno-fatal --no-timing des.v -xml-only
xml2stems obj_dir/Vdes.xml des.stems

当源文件布局或体系变更需要重新生成stems文件。

1
2
3
4
5
6
7
8
//  -o, --optimize             optimize VCD to FST 对vcd文件进行自动优化为fst
// -t, --stems=FILE specify stems file for source code annotation 为源代码注解指定stems文件
$ gtkwave -o -t des.stems des.vcd des.gtkw
GTKWave Analyzer v3.3.118 (w)1999-2023 BSI
FSTLOAD | Processing 1432 facs.
FSTLOAD | Built 1287 signals and 145 aliases.
FSTLOAD | Building facility hierarchy tree.
FSTLOAD | Sorting facility hierarchy tree.

cmake安装

下载链接进行下载最新版本的cmake源码,当前版本是3.31.3

1
2
3
4
5
tar -xzvf cmake-3.31.3.tar.gz
cd cmake-3.31.3
./configure
make -j8
sudo make install

并输出cmake版本

1
cmake --version

cmake version

笨方法学习C-笔记1

笨方法学习C-笔记1

LCTHW: Learn C The Hard Way

笨方法学习C(译)

LCTHW Github

笔记1所包括的范围

前言

期望我能一个月搞定这些教程

导言

所能学到的内容有:

  • C的基本语法和编写习惯。
  • 编译,make文件和链接。
  • 寻找和预防bug。
  • 防御性编程实践。
  • 使C的代码崩溃。
  • 编写基本的Unix系统软件。

必须遵守的规则:

  • 手动输入所有代码。不要复制粘贴!
  • 正确地输入所有代码,也包括注释
  • 运行代码并保证产生相同的输出。
  • 如果出现了bug则修正它。
  • 做附加题时,如果你做不出某道题,马上跳过。
  • 在寻求帮助之前首先试着自己弄懂。

学习C语言会使你变成更好的程序员,是一门提升程序员核心技能的最佳语言。
C比其它语言都要难,而这是由于C并不对你隐藏细节,它们在其它语言中都试图并且未能被掩盖,实质是其他语言对底层细节进行了进一步的封装,程序员仅仅是调用这些上层的函数即可实现功能。

练习0

我计划使用

  • Linux Ubuntu 24.04.1 LTS (vmware虚拟机x86) 或 Linux UnionTech OS Desktop 20 Pro(真实机器aarch64)
  • vim
  • 警告不要使用IDE

其中,如何配置vim可以参考这个链接

IDE,或者“集成开发工具”,它隐藏了背后的细节,你的工作是弄清楚背后发生了什么,对于学习C编程(以及许多其它语言),它们没有意义。

IDE类似于吉他的TAB(tablature),而我们需要学习的是五线谱

练习1

好好学习,天天向上

毛泽东

编写如下代码到ex1.c中,如图所示:

1
2
3
4
5
6
int main(int argc,char* argv[]){
puts("hello world!");
puts("happy new year!");
puts("good good study, day day up!");
return 0;
}

ex1.c

执行命令:

1
make ex1

make ex1
通过编译的结果来看,存在一个警告,提示我们需要将 #include<stdio.h>添加到代码中

未加#include<stdio.h>,运行ex1:

./ex1

添加加#include<stdio.h>,运行ex1:

附加题

在你的文本编辑器中打开ex1文件,随机修改或删除一部分,之后运行它看看发生了什么。

ex1是一个ELF文件,随机修改或删除一部分,会导致无法运行

再多打印5行文本或者其它比”Hello world.”更复杂的东西。

1
2
3
4
5
6
7
8
9
#include<stdio.h>
int main(int argc,char* argv[]){
puts("hello world!");
puts("happy new year!");
puts("good good study, day day up!");
puts("路曼曼其修远兮,吾将上下而求索");
puts("萧瑟秋风今又是,换了人间");
return 0;
}

执行man 3 puts来阅读这个函数和其它函数的文档

这个文档包括了 fputc, fputs, putc, putchar, puts函数,用于输出字符和字符串。

SYNOPSIS
#include <stdio.h>

   int fputc(int c, FILE *stream);
   int putc(int c, FILE *stream);
   int putchar(int c);

   int fputs(const char *restrict s, FILE *restrict stream);
   int puts(const char *s);

DESCRIPTION
fputc() writes the character c, cast to an unsigned char, to stream.

   putc() is equivalent to fputc() except that it may be implemented as a macro which evaluates stream more than once.

   putchar(c) is equivalent to putc(c, stdout).

   fputs() writes the string s to stream, without its terminating null byte ('\0').

   puts() writes the string s and a trailing newline to stdout.

   Calls to the functions described here can be mixed with each other and with calls to other output functions from the stdio library for the same output stream.

   For nonlocking counterparts, see unlocked_stdio(3).

RETURN VALUE
fputc(), putc(), and putchar() return the character written as an unsigned char cast to an int or EOF on error.

   puts() and fputs() return a nonnegative number on success, or EOF on error.

练习2

Makefile文件的缩进是一个TAB,下面代码中第四行rm前面是一个 TAB ,而不是多个等量的空格。
其中每条规则就明确两件事:构建目标的前置条件是什么,以及如何构建

1
2
<target> : <prerequisites> 
[tab] <commands>
1
2
3
4
5
CFLAGS=-Wall -g

clean:
rm -f ex1

1
2
3
4
5
6
7
8
9
10
11
#include<stdio.h>
int main(int argc,char* argv[]){
puts("hello world!");
puts("happy new year!");
puts("good good study, day day up!");
puts("路曼曼其修远兮,吾将上下而求索");
puts("萧瑟秋风今又是,换了人间");
puts("仰天大笑出门去,我辈岂是蓬蒿人");
return 0;
}

附加题

1
2
3
4
5
6
7
8
9
10
11
12
CFLAGS=-Wall -g

all: ex2

%: %.c
cc ${CFLAGS} -o $@ $^

.PHONY: clean all

clean:
rm -rf ex2

阅读man make来了解关于如何执行它的更多信息。
阅读man cc来了解关于-Wall和-g行为的更多信息。
在互联网上搜索Makefile文件,看看你是否能改进你的文件。
在另一个C语言项目中找到Makefile文件,并且尝试理解它做了什么。

练习3

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>

int main()
{
int age = 10;
int height = 72;

printf("I am %d years old.\n", age);
printf("I am %d inches tall.\n", height);

return 0;
}

1
2
3
4
5
6
7
8
9
10
11
12
CFLAGS=-Wall -g

all: ex3

%: %.c
cc ${CFLAGS} -o $@ $^

.PHONY: clean all

clean:
rm -rf ex3

直接执行 make clean all

练习4

Valgrind 我之前没有系统学习过,只是零零散散的看到过这个命令。

今天建站了

今天由原来的jekyll变更为了 Hexo! 一次非常有意义的尝试,这是第一篇文章,后续将在这里写一些技术、生活等等东西

You need to set client_id and slot_id to show this AD unit. Please set it in _config.yml.
Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×