網頁

2014年10月27日 星期一

Verilog - UART Simple Send / Receive

Last Update: 2014/10/29 00:24+08
Type: Note



看到 embecosm/chiphack 寫的 UART transmit
使用 除頻器 和 Finite State Machine 完成 UART 的發送
很不錯的練習題

他的github裡有 uart.v
但主要部份沒填, 只有FSM的架構
圖層 1 Idle Send Start Bit Send Data Bit Send End Bit Key1 Press not last bit last data bit

可以思考一下除頻器的運作, 填上適當的counter數
還有 UART 10-bit 一組, start-bit=0 + 8-bit data + end-bit=1

這是改完 測試通過的檔案 DE0_NANO_UART_Send.v


接著做 Receive: DE0_NANO_UART.v
PC端 C#測試代碼: DE0_NANO_UART.cs



2014年10月25日 星期六

OpenRISC with DE0-Nano

Last Update: 2014/10/29 00:24+08
Type: Note



---Intro---


把 OpenRISC 燒進 DE0-Nano 執行嵌入式的 Linux 系統

Environment & Requirement:
VMWare
Ubuntu 12.04.2 Desktop i386
FPGA板 - DE0-Nano
USB to UART (FTDI接腳, ex. UB-391 記得裝驅動)


2014年10月20日 星期一

OpenRISC with DE0-Nano - kevinmehall version

Last Update: 2014/10/17 01:11+08
Type: Note



---Intro---


把 OpenRISC 燒進 DE0-Nano 執行嵌入式的 Linux 系統

Environment & Requirement:
VMWare
Ubuntu 12.04.2 Desktop i386
FPGA板 - DE0-Nano
USB to UART (FTDI接腳)

個人建議 看 這篇 官方版本的


2014年10月11日 星期六

Hello! DE0 Nano (Altera FPGA)

Last Update: 2014/10/12 15:20+08
Type: Note



---Intro---


因為要學著用 OpenRISC
所以買了官方推薦的 FPGA: Terasic DE0 Nano
畢竟是練習用的 所以買個比較便宜的
真心建議要玩FPGA就直接買個板子吧!
讀萬卷書 不如行萬里路~ 比較有感覺

Content
  • 開個箱文唄
  • Installation & Driver & Test
  • My First FPGA


2014年10月9日 星期四

Linux CentOS 網路設定

Last Update: 2014/10/09 16:36+08
Type: Note


網路設定 - 固定IP

CentOS
http://yenpai.idis.com.tw/archives/240-%E6%95%99%E5%AD%B8-centos-6-3-%E5%AE%89%E8%A3%9D-2%E7%B6%B2%E8%B7%AF%E8%A8%AD%E5%AE%9A%E7%AF%87
(P.S. 有空再整理)



Troubleshooting


修改 /etc/resolv.conf 無效
請修改 /etc/sysconfig/network-scripts/ifcfg-eth0
ex:
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
PEERDNS=yes
NETMASK=255.255.255.0
IPADDR=xxx.xxx.xxx.xxx
GATEWAY=xxx.xxx.xxx.xxx
DNS1=8.8.8.8
DNS2=168.95.1.1
記得重啟 service network restart



如果要生成device的uuid
uuidgen eth0

C++ Split

Last Update: 2014/10/09 16:35+08
Type: Note


用 stringstream by 特定字元切割 ex: ':'
  std::ifstream infile("file.txt");
  if (!infile.is_open()) 
   return;
  
  std::string line;
  while (std::getline(infile, line)) {
   std::stringstream ss(line);
   std::string key, val;
   std::getline(ss, key, ':');
   std::getline(ss, val, ':');
用 istringstream by token (空白) 切割
  while (std::getline(infile, line)) {
   std::string key, val;

   istringstream iss(line);
   std::vector<std::string> tokens;
   copy(std::istream_iterator<std::string>(iss),
     std::istream_iterator<std::string>(),
     back_inserter<vector<std::string> >(tokens));
   if (tokens.size() != 2)
    continue;
   key = tokens[0];
   val = tokens[1];



C++ Interface Destructor

Last Update: 2014/10/09 16:32+08
Type: Note


即使是 interface 也需要有解構子
class IAnimal
{
  virtual void walk()=0;
  virtual ~IAnimal(){}
};
如果你這樣用
IAnimal* animal = new Lion();
delete animal;
這個 interface 是不知道 Lion 的解構子



Drag and Drop Files into a C# application

  public partial class Form1 : Form {
    public Form1() {
      InitializeComponent();
      this.AllowDrop = true;
      this.DragEnter += new DragEventHandler(Form1_DragEnter);
      this.DragDrop += new DragEventHandler(Form1_DragDrop);
    }

    void Form1_DragEnter(object sender, DragEventArgs e) {
      if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
    }

    void Form1_DragDrop(object sender, DragEventArgs e) {
      string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
      foreach (string file in files) Console.WriteLine(file);
    }
  }