Hexo 技巧收录

草稿功能

草稿相当于很多博客都有的“私密文章”功能。

1
$ hexo new draft "new draft"

会在source/_drafts目录下生成一个new-draft.md文件。但是这个文件不被显示在页面上,链接也访问不到。也就是说如果你想把某一篇文章移除显示,又不舍得删除,可以把它移动到_drafts目录之中。
如果你希望强行预览草稿,更改配置文件:

1
render_drafts: true

或者,如下方式启动server:

1
$ hexo server --drafts

下面这条命令可以把草稿变成文章,或者页面:

1
$ hexo publish [layout] <filename>

Python lambda实现Y组合子

也许你我都难以理解,为什么有人对她痴迷疯狂,铭记在心中不说,还要刻在身上:

她让人绞尽脑汁,也琢磨不定!她让人心力憔悴,又百般回味!

她,看似平淡,却深藏玄机!她,貌不惊人,却天下无敌!

她是谁?

Chisel BugList

  • [ ] BitPat length bugs
    BitPat.pare("b1100_0000") = (192,255,9) 实际8bit,返回9bit
    BitPat.pare("b11000000") = (192,255,8)

    1
    2
    3
    35:     (bits, mask, x.length - 1) 
    fix 剔除字符'_' 后统计长度
    35: (bits, mask, x.filter(_!='_').length - 1)
  • [ ] bug2

Chisel版本

如何查看当前使用的chisel版本

一般情况下chisel的版本会在build.sbt里显式定义,但有时候像jupter-notebook里并不能看到版本号
这种情况下有一个方法可以得到版本号
即生成的firrtl文件头会打印版本信息

Chiel Keep变量名

how to keep chisel variable name when generate verilog

There are several reasons why a name may be disappearing.

Constant Propagation
For many reasons, including interoperability with existing CAD tools, performance, and Verilog debug-ability, Chisel (actually the FIRRTL compiler underneath Chisel) will propagate constants and direct wire connections. For example:

Verilog 模块重名问题

Chisel 不同开发生产的Verilog 模块名冲突

同学A 负责开发AP
同学B 负责开发CP
其中都会用到Queue,生产的AP_system_top.v CP_system_top.v中可能都会包含一个
module Queue (
集成到SOC_top.v时会面临模块名冲突的问题,目前Chisel 本身没有提供解决该问题的方法。
只能依赖于原始verilog 的解决方法

Chisel组合逻辑时序逻辑

时序逻辑的声明和写法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
实例1
val tiRomStartAddr = RegInit(0.U(6.W)) //显示的声明Reg
when (io.swif.K<40.U ){tiRomStartAddr := 25.U }
.elsewhen (io.swif.K<159.U ){tiRomStartAddr := 21.U }
.elsewhen (io.swif.K<200.U ){tiRomStartAddr := 35.U }
.elsewhen (io.swif.K<481.U ){tiRomStartAddr := 15.U }
.elsewhen (io.swif.K<530.U ){tiRomStartAddr := 10.U }
.elsewhen (io.swif.K<2881.U){tiRomStartAddr := 5.U }
.otherwise {tiRomStartAddr := 25.U }
实例2
val RRomRdata = RegInit(0.U(log2Up(pm.MaxR).W)) //显示的声明Reg并初始化(switch语句不带default)
switch (io.RRomAddr) {
is (0.U) {RRomRdata := intraRowTi.RRomVal(0).U}
is (1.U) {RRomRdata := intraRowTi.RRomVal(1).U}
is (2.U) {RRomRdata := intraRowTi.RRomVal(2).U}
is (3.U) {RRomRdata := intraRowTi.RRomVal(3).U}
is (4.U) {RRomRdata := intraRowTi.RRomVal(4).U}
is (5.U) {RRomRdata := intraRowTi.RRomVal(5).U}
is (6.U) {RRomRdata := intraRowTi.RRomVal(6).U}
is (7.U) {RRomRdata := intraRowTi.RRomVal(7).U}
}

Scala 初探.二(package组织方式)

多个文件的package组织方式

1
2
3
4
5
6
//a.scala 
package com.east
import com.west._
object objectMain extends App{
println("add Function from west used in east, 1+2=%d".format(Add.add(1,2)))
}

Scala 初探.四(sbt组织scala代码2)

package and import

1
2
3
4
5
6
7
├── build.sbt
└── src
└── main
└── scala
├── Interleave.scala
├── utils.scala
└── config.scala

对于同一目录下的两个文件,可以不用import,默认在一个package内

1
2
3
4
5
//Interleave.scala

class A {
val a = new ClassInUtils
}

Scala 初探.三(sbt组织scala代码1)

上一节我们用Makefile来组织scala代码,这里有更好的选择sbt来管理项目
sbt推荐将scala代码放在src路径,如下为标准的组织方式(代码还是原封使用第二节的样例代码)
总共3个文件

1
2
3
4
5
6
7
├── build.sbt
└── src
└── main
└── scala
├── a.scala
├── b.scala
└── c.scala