2014年10月17日 星期五

Install wxpython on raspberry pi

Reference:
http://wiki.wxpython.org/InstallingOnUbuntuOrDebian

sudo apt-get update

sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n libwxgtk2.8-dev libgtk2.0-dev



restart raspberry pi

Raspberry pi with samba

Raspberry pi with samba

Reference
http://raspberrywebserver.com/serveradmin/share-your-raspberry-pis-files-and-folders-across-a-network.html

先安裝samba
sudo apt-get install samba

備份原本的smb.conf
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.org

打開smb.conf編輯
sudo leafpad /etc/samba/smb.conf &

將smb.conf中的Global Settings下的兩個變數做改變
workgroup = your work group
wins support = yes

在smb.conf最後加入這段
[Share]
comment = share
path = /home/pi/
read only = no
locking = no
guest ok = yes
force user = pi
writeable = yes
only guest = yes
create mask = 0777
directory mask = 0777

儲存以後重新開啟smaba就可以在網路芳鄰上看到raspberry pi 了
sudo service samba restart

上面的設定是沒有設定使用者人稱密碼
也可以用 smbpasswd來設定名稱為pi,之後會要求輸入兩次密碼
smbpasswd -a pi

如果是-an則只有名稱不用密碼


2014年10月15日 星期三

Microblaze axi monitor

Reference : http://www.dc.uba.ar/materias/CoDisenio/2013/c2/descargas/lab6.pdf
Spartan-6 LX9 MicroBoard Embedded Tutorial J50_EDK05-Chipscope_Debugging_13_1_1%20(1).pdf

一直想要試試看這個功能
剛好配合上最近要研究一下AXI這個bus

在Microblaze上面先預留周邊的DIP跟LED來測試BUS
Debug → Debug Configuration → Add Chipscope peripheral → Adding axu monitor

選擇要觀察的模組 LED

在microblaze上會出現兩個新的模組,在確定一次是不是接到LED BUS

打開mdm跟chipscope_icon_0 確定兩個的BSCAN不是重複的user 名稱,不然之後PR會有error

在chipscope_axi_monitor中打開改下面設定




之後產生top layer hdl and generate bit file

打開SDK 建立peripheral的application project
在main中無限迴圈讀寫LED來方便觀察chipscope




打開chipscope , open cable
然後import 在project下面的microblaze\implementation\chipscope_axi_monitor_0_wrapper\chipscope_axi_monitor_0.cdc


就會看到列好的訊號在trigger與wareform中



然後在SDK下program FPGA (與elf file一起)
在chipscope上按下T! , 就會看到即時在BUS上的訊號,chipscope不用再重新configure bit file

除了先燒進去ELF即時看以外,也可以在SDK中先不燒入elf,然後執行Debug
在chipscope下面設定trigger的條件來觀察bus

Debug Configuration → Xilinx C/C++ ELF→ Debug



但是奇怪的是如果用debug的方式我看不到ready,valid 那些信號改變




2014年10月14日 星期二

8 Bits Sequence Detector

練習寫了一個Sequence Detector
網路上的範例大多都是四個bit
我練習寫了一個8 bit
對於每個state的轉換,其實不是百分之百的確定
只是寫了一些變化的testbench來測
如果遇到其他多元化的情形,FSM一定是需要再修改的

Sequence 10101100


VHDL
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity seq_det is
port(
clk   : in std_logic;  
reset : in std_logic;
enable : in std_logic;
seq_in   : in std_logic;    
seq_detected : out std_logic);  
end seq_det;
---- Pattern 10101100---------

architecture Behavioral of seq_det is

type state_type is (IDLE,S1,S2,S3,S4,S5,S6,S7,S8,S9);
signal cur_state, nxt_state : state_type;
signal seq_det,seq_det_w : std_logic;
begin

seq_detected <= seq_det;



process(clk)
begin
    if( reset = '1' ) then              
        cur_state <= IDLE;
 seq_det <= '0';
    elsif (clk'event and clk = '1') then
        cur_state <= nxt_state;
 seq_det <= seq_det_w;
    end if;
end process;


Process(cur_state,seq_in,enable)
    begin
        case cur_state is

            when IDLE =>                    
                seq_det_w <= '0';
 if( enable = '1') then
if ( seq_in = '1' ) then
nxt_state <= S1;
else  
nxt_state <= IDLE;
end if;
else
       nxt_state <= IDLE;
end if;

            when S1 => -- 1
                seq_det_w <= seq_det;
                if ( seq_in = '0' ) then
                    nxt_state <= S2;
                else  
                    nxt_state <= S1;
                end if;

            when S2 => -- 0
                seq_det_w <= seq_det;
                if ( seq_in = '1' ) then
                    nxt_state <= S3;
                else  
                    nxt_state <= IDLE;
                end if;
-
            when S3 => -- 1
                seq_det_w <= seq_det;
                if (seq_in = '0' ) then
                    nxt_state <= S4;
                else  
                    nxt_state <= S1;
                end if;

            when S4 => -- 0
                seq_det_w <= seq_det;
                if ( seq_in = '1' ) then
                    nxt_state <= S5;
                else  
                    nxt_state <= IDLE;
                end if;

when S5 => -- 1
                seq_det_w <= seq_det;
                if ( seq_in = '1' ) then
                    nxt_state <= S6;
                else  
                    nxt_state <= S4;
                end if;

when S6 => -- 1
                seq_det_w <= seq_det;
                if ( seq_in = '0' ) then
                    nxt_state <= S7;
                else  
                    nxt_state <= S1;
                end if;

when S7 => -- 0
                seq_det_w <= seq_det;
                if ( seq_in = '0' ) then
                    nxt_state <= S8;
                else  
                    nxt_state <= S3;
                end if;

when S8 => -- 0
                seq_det_w <= '1';
                if ( seq_in = '1' ) then
                    nxt_state <= S1;
                else  
                    nxt_state <= IDLE;
                end if;


            when others =>
                NULL;
        end case;
end process;  


end Behavioral;





2014年10月10日 星期五

VHDL 觀念釐清

hardware.html
http://www.synthworks.com/papers/vhdl_math_tricks_mapld_2003.pdf
http://www.csd.nutn.edu.tw/VHDL/CH4.pdf

RTL (Register Transfer level)
Rising_edge(clk) & clk'event and clk = '1'
如果clk正常工作的話兩個都可以正常使用,但是如果clk在低電位時為unknown,使用clk'event and clk = '1' 會造成沒有訊號,而Rising_edge(clk)正常,rising_edge has a few extra checks built-in to make sure that you actually have an edge.,Use Rising_edge(clk) instead of clk'event and clk = '1'


std_logic,std_logic_vector & bit,bit_vector
bit : 只能用來代表'0' or '1'
std_logic : 可以用來代表七種資料型態,包括
’U’(Uninitialized)、
’X’(Forcing Unknown)、
’0’(Forcing 0)、
’1’(Forcing 1)、
’Z’(High Impedance)、
’W’(Weak Unkonwn)、
’L’(Weak 0)、
’H’(Weak 1)
’-‘(Don’t Care)

所以在程式中當確定訊號只會為0或是1的時候即可以用bit,在某些shift operator中無法使用
std_logic_vector,所以可以使用下列的函式來轉換,不用另外加library,已經在std_logic_1164 內

"To_bit"
"To_bitvector"
"To_StdLogic"
"To_StdLogicvector"
"To_StdULogic"
"To_StdULogicvector"

integer,signed,unsigned 轉換(Xilinx)

use IEEE.NUMERIC_STD.ALL;
<signed_sig> = TO_SIGNED(<int_sig>, <integer_size>); – integer to signed
<unsigned_sig> = TO_UNSIGNED(<int_sig>, <integer_size>); – integer to unsigned
<int_sig> = TO_INTEGER(<signed_sig>); – signed to integer
<int_sig> = TO_INTEGER(<unsigned_sig>); – unsigned to integer

Delay

Delta Delay
In VHDL simulations, all signal assignments occur with some infinitesimal delay, known as delta delay. Technically, delta delay is of no measurable unit, but from a hardware design perspective one should think of delta delay as being the smallest time unit one could measure, such as a femtosecond (fs).
這是每級預設的最小延遲
慣性延遲(inertial delay model)
可以用在程式當中,但是synthesis後會被optimized, Inertial delay is basically a default component delay
a <= b after 1ns;
wait for time expressions
wait on signal
wait until condition
wait;
這些都是不能合成的,最好只用在testbench裡面
傳遞延遲
通常用在testbench的輸入輸出,Transport delay basically represents a wire delay.

a <= transport b after 1ns;

Concurrent & Sequential Statements


Concurrent為共時性敘述,每個process與block之間為Concurrent
Sequential 為順序性敘述,在process內的為Sequential



Signal & Variable


signal assignment statement Target物件 <= 表示式;
variable assignment statement Target物件 := 表示式;

Signal 與variable都可以指定初始值



Signal 不可以重複設定,可以用在package,entity,architecture,ports
Signal只有在process,procedure,function順時執行到時才會改變資料



variable可以重複設定,可以用在process,procedure,function
variable資料隨時可被更新
模擬時無法看到variable的waveform

Subtypes

次資料型別係用來表示一個資料型別的子集合 (Sub-Sets)

subtype SUBTYPE_NAME is TYPE_NAME [範圍宣告];

次資料型別的宣告,由一個關鍵字subtype或SUBTYPE來表示。之後的識別字為次資料型別
的名稱。關鍵字的後面的識別字用來表示所使用的原始資料型別。最後所宣告的範圍限制,
乃是對次資料型別所局限的範圍做一個定義

SUBTYPE First_ten IS INTEGER RANGE 0 to 9;

有兩種場合,需要使用到次資料型別:
(1)在訊號指定或Case指定的命令列中加以限制其資料的範圍,以控制電路合成的結果。
(2)建立一個解值(Resolved)的資料型別。


Function & Procedure
function可以用來做一些常用的數學運算,但是只能回傳一個值
Procedure 與function最大的差別在於它可以回傳一個以上的值,而且可以不同型態

array and records types

array types,一組資料物件
陣列資料物件中的元素,可以使用陣列的指標(Index) 來指定陣列中指定位置的元素
type BYTE is array (0 to 7) of bit;
陣列資料型別,通常使用在線性結構的一組資料中,也可以用來表示多維的陣列資料型別
也可以在使用的時候,不宣告其元素的方式來使用,增加程式設計上的彈性

records types,一組不同的資料物件所組合而成
記錄資料型別,係由一組不同的資料物件所組合而成的資料型別,而陣列中的每一個元素可
以是任意的資料型別。
# 在記錄型別內的每一個元素,都可以用一個名稱來加入設定或指定。
# 在VHDL電路設計語言中的記錄資料型別類似於C語言中的結構(Structure)。記錄資料型別
內的每一個元素,可以是任意的資料型別,也包含陣列資料型別與記錄資料型別均可用來當
作記錄資料型別內的元素。

type OPTYPE is (ADD, SUB, JMP);
type INSTRUCT is
record
OPCODE: OPTYPE;
SOURCE: integer;
DESTINATION: integer;
end record;




2014年10月9日 星期四

ML605 configuration with sysace

Ml605 configuration with sysace
ISE 14.4

終於需要compact flash來做它的正途了
先做一個小測試建立八個bits file ,每個bit file 內包含不同的led燈亮

先把CF Card format,如果之前已經做過了,就直接把卡片裡面的東西刪掉就好
注意現在要把CF卡與電腦連接,不是放在板子上
在impact中, file → new project





Name可以自己隨便取,但是位置要選CF卡的槽


有幾個bit file要燒進去就放幾個,名字可以另外取

接下來會跳出視窗要選擇bit file的位置,然後會問要不要放其它file在同一個address,要選No



選好以後按左邊的Generate file,然後確定跳出來的視窗是你剛剛輸入的名子,impact就會開始寫資料進入你的CF卡,寫入大概需要幾分鐘的時間,寫完以後會看到完成的畫面


把CF卡放入ml605,在板子上有個4 pole的S1 switch, 第四個pole為mode, 如果為ON,系統開機時會自動去讀CF卡內的bit file,如果為off則不會

前三個為address,一打開電源系統就會自動去讀cf卡還有switch上的address,如果要換成另一個bit file, 必須要關掉電源重開,只改address不重開電源是不會重燒的!




這邊的address 012 跟燒入的bit file對應關係為

Addr 0 | Addr 1 | Addr 2
Bit file
000
0
100
1
010
2
110
3
001
4
101
5
011
6
111
7




2014年10月8日 星期三

save tera term log

先在電腦上建立一個資料夾Tera
在Tera Term上Setup → Additional Settings


然後Setup → Save Setup

重開Tera term
File → Log
將teradem存在tera 資料夾中,可以選擇要續寫或是其他功能



如果之前已經設過log放在其他地方,就需要relay log