Skip to content

Commit

Permalink
add cdc one single
Browse files Browse the repository at this point in the history
  • Loading branch information
guttatus committed Aug 13, 2023
0 parents commit 8d28f43
Show file tree
Hide file tree
Showing 18 changed files with 4,259 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/hugo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Sample workflow for building and deploying a Hugo site to GitHub Pages
name: Deploy Hugo site to Pages

on:
# Runs on pushes targeting the default branch
push:
branches:
- main

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

# Default to bash
defaults:
run:
shell: bash

jobs:
# Build job
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.115.4
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./public

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "themes/tokiwa"]
path = themes/tokiwa
url = git@github.com:guttatus/hugo-theme-tokiwa.git
branch = gitalk
6 changes: 6 additions & 0 deletions archetypes/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
---

93 changes: 93 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
DefaultContentLanguage = "zh-cn"
author = "guttatus"
baseURL = "https://guttatus.github.io"
copyright = "Copyright &copy;guttatus,<a href=\"https://creativecommons.org/licenses/by-sa/4.0/deed.zh\">CC BY-SA</a>"
disqusShortname = "guttatus"
enableInlineShortcodes = true
footnoteReturnLinkContents = "^"
googleAnalytics = "UA-FAKE" ## or "G-xxxxxxxx" in Google Analytics v4, in hugo v0.82+
hasCJKLanguage = true
languageCode = "cn"
theme = "tokiwa"
title = "Guttatus's Blog"

[markup]
[markup.highlight]
style = "monokailight"

[markup.goldmark.renderer]
unsafe = true

[markup.tableOfContents]
startLevel = 2
endLevel = 5
ordered = false

[params]
bannerFont = "fonts/exampleFont"
description = """
虽千万人吾往矣
"""
env = "production" # for Google Analytics and DISQUS.
favicon = "img/favicon.png"
fuse = true # for searchbox. "JSON" must added to output contents. See [outputs].
math = true # for introducing $KaTEX$
useChineseFonts = true
postDateFormat = "2006-1-2"
enableGitalk = true

[menu]
# Shown in the side menu.
[[menu.main]]
identifier = "post"
name = "Posts"
url = "/post/"
weight = 1
[[menu.main]]
name = "Tags"
url = "/tags/"
weight = 2

[[menu.main]]
name = "Categories"
url = "/categories/"
weight = 2

[[menu.main]]
identifier = "about"
name = "About"
url = "/about/"
weight = 3

[taxonomies]
category = "categories"
series = "series"
tag = "tags"
[social]
bilibili = "https://space.bilibili.com/435228864"
github = "https://github.com/guttatus"
# gitlab = "http://gitlab.com/"
# instagram = "http://example.com/"
mail = "mailto:xingzhiang2020@gmail.com"
# twitter = "http://twitter.com/"
# weibo = "http://example.com/"
# youtube = "http://youtube.com/"
# zhihu = "http://example.com/"
# any icon in layouts/partials/svg can be used by the name without the "-line.svg"

[outputs]
home = ["HTML", "RSS", "JSON"]

[params.gitalk]
clientID = "de25a843e28e54ff3a20" # 您刚才创建Github Application 的 Client ID
clientSecret = "29e4adfe5bd0d694813a2bddd0f2ab03b5e0f18f" # 您刚才创建Github Application 的 Client Secret
repo = "guttatus.github.io" # 您的博客的github地址Repository name,例如:xxxx.github.io
owner = "guttatus" # 您的GitHub ID
admin= "guttatus" # 您的GitHub ID
id= "location.pathname" # 文章页面的链接地址就是ID
labels= "gitalk" # Github issue labels. If you used to use Gitment, you can change it
perPage= 15 # Pagination size, with maximum 100.
pagerDirection= "last" # Comment sorting direction, available values are 'last' and 'first'.
createIssueManually= true # 设置为true,如果是管理员登录,会自动创建issue,如果是false,需要管理员手动添加第一个评论(issue)
distractionFreeMode= false # Enable hot key (cmd|ctrl + enter) submit comment.

4 changes: 4 additions & 0 deletions content/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
+++
author = "guttatus"
+++

54 changes: 54 additions & 0 deletions content/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
+++
title = "About"
description = "What should I write?🤯"
date = "2023-08-09"
aliases = ["about-me","contact"]
author = "guttatus"
+++

# General Information

* 🫣 Hi, I’m @[guttatus](https://github.com/guttatus)
* 👀 I’m interested in Functional Programming and Computer Architecture.
* 🌱 I’m currently learning [__Haskell__](https://www.haskell.org/) and __Verilog HDL__
* 📪 You can reach me by xingzhiang2020@gmail.com

# Education

<style>
.data{
color:#028760;
}

img {
max-width: none;
overflow-clip-margin: content-box;
overflow: clip;
}
</style>

<table class="imgtable">
<tbody>
<tr>
<td>
<img src="/img/logo/npu.svg" alt="npu's logo" width="70px" style="border:none; box-shadow: none;">
</td>
<td align="left" valign="middle">
<p><strong style="margin-right: 30px;">Northwestern Polytechnical University</strong></p>
<p class="data"><i> Sep 2023 - Jul 2026 (expected) </i> </p>
<p>M.Eng. in Computer Technology</p>
</td>
</tr>
<tr>
<td>
<img src="/img/logo/shu.svg" alt="Shanghai University's logo" width="70px" height="70px" style="border:none; box-shadow: none;">
</td>
<td align="left">
<p><strong style="margin-right: 30px;">Shanghai University</strong>
<p class="data"><i> Sep 2019 - Jul 2023 </i> </p>
<p>B.S. in Computer Science and Technology</p>
</td>
</tr>
</tbody>
</table>

5 changes: 5 additions & 0 deletions content/archives.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
date: 2023-08-09
type: section
layout: "archives"
---
5 changes: 5 additions & 0 deletions content/post/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
aliases = ["posts","articles","blog","showcase","docs"]
title = "Posts"
author = "guttatus"
+++
8 changes: 8 additions & 0 deletions content/post/at-beginning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
author: guttatus
title: At Beginning
date: 2023-08-09
description: 写在开始时
---

之前写过一段时间博客,但是由于种种原因,未能坚持。在升入研究生之际,重新搭建模板,主要记录学习和生活,希望能够坚持下去。
70 changes: 70 additions & 0 deletions content/post/cdc-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
+++
author = "guttatus"
title = "跨过那个时钟域(1)"
date = "2023-08-12"
description = "浅谈数字电路设计中跨时钟域相关概念及单比特信号跨时钟域的同步处理方法"
tags = [
"CDC",
]
categories = [
"IC",
]
toc = true
+++

## 时钟域概念
在同步时序电路中,一个时钟通常驱动(Feed)许多同步单元(触发器,同步RAM块等)。由同一时钟驱动的一组同步单元被称为该时钟的**时钟域**(Clock Domain)。


## 跨时钟域概念
**跨时钟域**(Clock Domain Crossing,CDC)是指同步数字电路中的信号从一个时钟域跨越到另一个时钟域。

### 亚稳态
对于边缘触发的触发器,触发器的建立时间(setup)和保持时间(hold)在时钟上升沿左右定义了一个时间窗口。如果输入数据在该窗口发生变化,那么就会产生时序违约。此时,触发器无法稳定在0或1状态,而是徘徊在一个中间电平状态(这个中间电平可能是正确值,也可能不是),得到的结果将是不可预知的。这种状态称为**亚稳态**(Metastability)。

## 单比特信号跨时钟域的同步处理方法

当在时钟域之间传递信号时,我们需要考虑一个重要的问题:是否要对从一个时钟域传输到另一个时钟域的信号的每一个值进行采样?

针对上述问题,当信号跨越时钟域边界时有两种可能的场景:
1. 在跨时钟域时允许丢失部分采样值。
2. 在跨时钟域时不允许丢失任何信号采样值。

对于第一种场景,有时对信号的每一个值进行采样是不必要的,但是被采样的值必须要保证精确度。标准异步 FIFO 设计中使用的一组格雷码计数器就是一个例子。在设计得当的异步 FIFO 模型中,同步格雷码计数器不需要捕获来自另一时钟域的每一个合法值,但采样值必须准确无误,以便识别何时出现了满和空的情况。

对于第二种场景,在允许对跨时钟域信号发生改变之前,必须被正确识别或识别并确认。

在这两种情况下,跨时钟域信号都需要被同步到其接受时钟域中。

### 双触发同步器

> **同步器**是对异步信号进行采样,并输出与本地时钟或采样时钟同步转换的信号的设备。
如下图所示,数字电路设计中,最简单和普遍的是使用**双触发同步器**(Two flip-flop synchronizer),也就是所谓的“打两拍”。

![Two-flip-flop](/img/posts/cdc/twoflipflop.png)

值得注意的是,即使通过使用双触发同步器消除了亚稳态,也并不意味着第二级Flop所采到的值就是**正确**的,而只能保证其是**稳定**的。

当然,从理论上,由于第一阶段的信号在打一拍后还是有可能处于非稳定状态,从而导致级联的第二个寄存器输出还会表现为非稳定状态。


>触发器进入亚稳态的时间可以用参数 **MTBF**(mean time between failures)来描述, MTBF即触发器采样失败的时间间隔,其公式描述如下:
$$ MTBF = \frac{e^{{t_R}/\tau}}{f_df_cT_0} $$
$t_R$ = 分辨时间(resolution time, the time after the clock edge that output data is needed)
$\tau, T_0$ = 触发器参数,由工艺决定
$f_d$ = 数据改变频率
$f_c$ = 采样时钟频率
从上述公式中我们可以看出,随着时钟频率的提高或者数据改变频率的提高,失败会发生的更频繁。

对于大多数同步应用,双触发同步器已经足够消除可能的亚稳态了。(存疑,该结论今天是否任然适用?)

### 三级触发同步器
对于一些高速设计,使用两级触发器同步未必能满足要求,这时可以额外添加一级触发器来增加MTBF。

下图展示了一个三级触发同步器。

<img src="/img/posts/cdc/threeff.png" style="margin: 0 auto;" />


## to be continued
Binary file added static/fonts/exampleFont.woff
Binary file not shown.
Binary file added static/fonts/exampleFont.woff2
Binary file not shown.
Binary file added static/img/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,925 changes: 3,925 additions & 0 deletions static/img/logo/npu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions static/img/logo/shu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/posts/cdc/threeff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/posts/cdc/twoflipflop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions themes/tokiwa
Submodule tokiwa added at aa034b

0 comments on commit 8d28f43

Please sign in to comment.