2017-02-26 69 views
1

我正在學習模型檢查和NuSMV爲我的教育。我可以編輯和運行NuSMV代碼,並且對UART的功能和功能有一個公正的理解。在NuSMV中構建UART的正式模型?

我的任務是使用NuSMV正式模擬UART,但此時我不知道該怎麼做。我明白,UART傳輸一個字節爲八個連續的位,但我怎樣才能建模?

我有一個互斥代碼爲出發點:

>NuSMV.exe mutex.smv 
*** This is NuSMV 2.6.0 (compiled on Wed Oct 14 15:37:51 2015) 
*** Enabled addons are: compass 
*** For more information on NuSMV see <http://nusmv.fbk.eu> 
*** or email to <[email protected]>. 
*** Please report bugs to <Please report bugs to <[email protected]>> 

*** Copyright (c) 2010-2014, Fondazione Bruno Kessler 

*** This version of NuSMV is linked to the CUDD library version 2.4.1 
*** Copyright (c) 1995-2004, Regents of the University of Colorado 

*** This version of NuSMV is linked to the MiniSat SAT solver. 
*** See http://minisat.se/MiniSat.html 
*** Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 
*** Copyright (c) 2007-2010, Niklas Sorensson 

-- specification EF (state1 = c1 & state2 = c2) is false 
-- as demonstrated by the following execution sequence 
Trace Description: CTL Counterexample 
Trace Type: Counterexample 
    -> State: 1.1 <- 
    state1 = n1 
    state2 = n2 
    turn = 1 
-- specification AG (state1 = t1 -> AF state1 = c1) is true 
-- specification AG (state2 = t2 -> AF state2 = c2) is true 

代碼

MODULE main 


VAR 

state1: {n1, t1, c1}; 

ASSIGN 

init(state1) := n1; 

next(state1) := 
case 
    (state1 = n1) & (state2 = t2): t1; 
    (state1 = n1) & (state2 = n2): t1; 
    (state1 = n1) & (state2 = c2): t1; 
    (state1 = t1) & (state2 = n2): c1; 
    (state1 = t1) & (state2 = t2) & (turn = 1): c1; 
    (state1 = c1): n1; 
    TRUE : state1; 
esac; 




VAR 

state2: {n2, t2, c2}; 

ASSIGN 

init(state2) := n2; 

next(state2) := 
case 
    (state2 = n2) & (state1 = t1): t2; 
    (state2 = n2) & (state1 = n1): t2; 
    (state2 = n2) & (state1 = c1): t2; 
    (state2 = t2) & (state1 = n1): c2; 
    (state2 = t2) & (state1 = t1) & (turn = 2): c2; 
    (state2 = c2): n2; 
    TRUE : state2; 
esac; 


VAR 

turn: {1, 2}; 

ASSIGN 

init(turn) := 1; 

next(turn) := 
case 
    (state1 = n1) & (state2 = t2): 2; 
    (state2 = n2) & (state1 = t1): 1; 
    TRUE : turn; 
esac; 

SPEC 

EF((state1 = c1) & (state2 = c2)) 

SPEC 

AG((state1 = t1) -> AF (state1 = c1)) 

SPEC 

AG((state2 = t2) -> AF (state2 = c2)) 

回答

2

跳進SMV模型之前,你需要了解的詳細程度你有興趣爲UART組件建模。首先以不同的形式主義對組件進行建模可能會有所幫助,以免出現語法問題。組件的輸入是什麼?什麼是輸出?有內部狀態嗎?內部狀態如何隨着時間而改變,特別是一步到位?

如果您熟悉硬件描述語言(例如Verilog和VHDL),這將是一個非常好的起點,因爲SMV中的轉換可以看作是時鐘節拍。如果你不知道這些語言,你可以嘗試寫一段軟件。這將有助於你理解系統的輸入/輸出,但是轉換成SMV不會那麼直接。

對於非常有狀態的組件,手動繪製相應的自動機可能會有幫助。