Lec01 Introduction
Lec01 Introduction
Prerequisites
Basic *igital *esign (&posure to "asic %icroarchitectures) pipelining' 0-1s' *ata an* control paths' 2 one so%e co*ing in ,T! 3.erilog or .H !4 one so%e verification of ,T! $ware of typical flow) architecture e&ploration' *esign' verification' physical *esign 5ot assu%ing any prior e&posure to -yste%.erilog
Copyright Bluespec Inc. 2005
$rchitecture e&ploration an* verification are not in*epen*ent of the H !) a "etter H ! will spee* those activities
7The .erification pro"le% is a esign pro"le%8 9ith powerful a"straction %echanis%s' a single H ! can "e use* for "oth arch. e&ploration as well as for *esign
$"straction is goo*' provi*e* it *oes not negatively i%pact H9 3quality' visi"ility' pre*icta"ility' controlla"ility4
Copyright Bluespec Inc. 2005
o not try to force+fit' into an H !' constructs that %ay "e fine for tra*itional -9 co%puting "ut inappropriate for H9 *escription 0reely e&ploit a"straction %echanis%s that %ay have "een *evelope* in the -9 space "ut are perfectly applica"le to H9 *escription
-i%ulation is the servant of natural+an*+intuitive H9 *escription' not the other way aroun*
!o
esign closer to specification Co%pati"le with current %etho*ologies Can :eep up with changing specifications (na"les architectural e&ploration
,e*uces "ugs an* therefore verification ti%e -i%plifies verification an* *e"ugging (ases changes for ti%ing closure (ases changes for physical *esign Pro%otes reuse
Copyright Bluespec Inc. 2005
& $e
)hat $ollo s are a $e small e'amples to illustrate hat is possi#le in BSV Please hold o$$ on detailed technical questions until later* don+t orry i$ these are not $ully understanda#le no
This is ,ust the -overture music.( to #athe you in the leitmoti$s( the idioms( the themes( as you settle com$orta#ly into your seats leaving #ehind the stresses o$ the street The plot o$ the opera ill #e revealed to you as e progress through the tutorial/
ill die/
>
0ultiplier 1'ample
-i%ple "inary %ultiplication)
@00@ AA * B 6<*C 0@0@ AA r B 6<*5 @00@ AA * DD 0 3since rE0F BB @4 0000 AA 0 DD @ 3since rE@F BB 04 @00@ AA * DD 2 3since rE2F BB @4 AA 0 DD / 3since rE/F BB 04 0000 0@0@@0@ AA pro*uct 3su% of a"ove4 B 65 &
0ultiplier 1'ample
%o*ule %:Test 34H ,egI3int4 state D+ %:,eg304H 1ultGifc % D+ %:1ult@34H rule go 3state BB 04H %.start 3C' 54H state DB @H en*rule rule finish 3state BB @4H J*isplay 37Pro*uct B K*8'%.result344H state DB 2H en*rule en*%o*ule) %:Test interface 1ultGifcH %etho* $ction start 3Tin &' Tin y4H %etho* Tout result 34H en*interface) 1ultGifc %o*ule %:1ult@ 31ultGifc4H ,egI3Tout4 pro*uct D+ %:,eg304H ,egI3Tout4 * D+ %:,eg304H ,egI3Tin4 r D+ %:,eg304H rule cycle 3r LB 04H if 3rE0F BB @4 pro*uct DB pro*uct M *H * DB * DD @H r DB r NN @H en*rule %etho* $ction start 3&'y4 if 3r BB 04H * DB &H r DB yH en*%etho* %etho* result 34 if 3r BB 04H return pro*uctH en*%etho* en*%o*ule) %:1ult@
Copyright Bluespec Inc. 2005
1
cond1
51
61
'
Process 0 incre%ents register x un*er so%e con*ition cond0 Process @ transfers a unit fro% register x to register y un*er cond1 Process 2 *ecre%ents register y un*er so%e con*ition cond2 (ach register can only "e up*ate* "y one process on each cloc:.
Priority) 2 N @ N 0
This is an a"straction of so%e real applications) Ban: account) 0B*eposit' @Btransfer to savings' 2 B with*raw fro% savings Pac:et processor) 0 B pac:et arrives' @ B pac:et is processe*' 2 B pac:et *eparts 2
@0
1
cond1
51
61
'
y
if ((!cond1 || cond2) && cond0)
always O3pose*ge C!P4 AA process 0 if 3Lcon*@ QQ con*04 & DB & M @H always O3pose*ge C!P4 AA process @ if 3Lcon*2 QQ con*@4 "egin y DB y M @H & DB & R @H &peration'centric en* (not synthesizable) always O3pose*ge C!P4 AA process 2 if 3con*24 y DB y R @H
always O3pose*ge C!P4 "egin if 3Lcon*2 QQ con*@4 & DB & R @H else if 3con*04 & DB & M @H if 3con*24 y DB y R @H else if 3con*@4 y DB y M @H en*
*tate'centric (further from spec$ but synthesizable) Is it o"vious that con*itions for &+@ an* yM@ are i*entical#
Which of these solutions are correct, if any? Whats required to verify that theyre correct What if another priority is required ! cond1 " cond2 " cond0 #nd$ %hat if the processes are in different modules
Copyright Bluespec Inc. 2005
@@
1
cond1
51
61
'
y
if (((not cond1) or cond2) && cond0) then
process3C!P4 "egin AA process 0 if 3C!P B S@< an* C!P<event4 then if 33not con*@4 an* con*04 then & DB & M @H en* ifH en* ifH en*processH process3C!P4 "egin AA process @ if 3C!P B S@< an* C!P<event4 then if 33not con*24 an* con*@4 then & DB & R @H y DB y M @H en* ifH en* ifH en*processH process3C!P4 "egin AA process 2 if 3C!P B S@< an* C!P<event4 then if 3con*24 then y DB y + @H en* ifH en* ifH en*processH
process3C!P4 "egin if 3C!P B S@< an* C!P<event4 then if 3con*2 an* con*@4 & DB & R @H else if 3con*04 then & DB & M @H en* ifH if 3con*24 then y DB y R @H else if 3con*@4 then y DB y M @H en* ifH en* ifH en* processH
@2
51
61
51
61
'
cond1
3T *escen*ingGurgency B 7proc2' proc@' proc08 T4 rule proc0 3con*04H & DB & M @H en*rule rule proc@ 3con*@4H y DB y M @H & DB & R @H en*rule rule proc2 3con*24H y DB y R @H en*rule
+unctional correctness follo%s directly from rule semantics ,elated actions are -rouped naturally %ith their conditions.easy to chan-e /nteractions bet%een rules are mana-ed by the compiler (schedulin-$ muxin-$ control) *ame hard%are as the 0erilo- 1 0234 ,54
Copyright Bluespec Inc. 2005
@/
00 0@
@0 @@
@6
interface XBar #(type t); interface List#(P t#(t)) interface List#("et#(t)) endinterface
@5
Si9e parameter: logn 2om#: circuit parameter: destinationOf 0odule parameter: mkMerge2x1
@=
&r#itrary ela#oration
@>
Butter$ly s itch
-u%%ary) + $*vance* para%eteriUation + $*vance* ela"oration + The switch itself) D =0 lines of B-. co*e + 0irst wor:ing 3teste*4 prototype) D @ *ay 3inclu*ing si%ple test"ench4 + 0ully synthesiUa"le) + synthesiUe* to netlist 31ag%a' ts%c0.@?u' 500 1HU4
7 hitepaper availa#le ith $ull code and commentary8
@?
Rules and Rule-based Interfaces 0or co%ple& concurrency an* control' across %ultiple share* resources' across %o*ule "oun*aries
High-level abstract types Powerful static checking Powerful parameterization Powerful static elaboration Advanced clock management
6ehavioral
.H !A.erilogA-yste%.erilogA-yste%C
Copyright Bluespec Inc. 2005
*tructural
@C
Broad6#rush di$$erences #et een BSV and 3TL and System2: "escri#ing #ehavior
!o
#ehavior is descri#ed:
3TL and System2 use S)6li<e process notation: Processes are synchroni9ed using S)6li<e events BSV uses 3ules: guarded atomic state transitions: Synchroni9ation is implicit in atomic semantics: Sequential #ehaviors are #uilt #y composing 3ules( ritten manually or generated automatically
20
Broad6#rush di$$erences #et een BSV and 3TL and System2: =peration6centric vs: State6centric Speci$ications are usually operation6centric 7state transitions8:
->nder condition c1( change s1,s2 in the $ollo ing under c2, change s1,s3 in the $ollo ing ay.
ay*
-i$6then6else descri#ing all updates to s1 i$6then6else descri#ing all updates to s2 i$6then6else descri#ing all updates to s3.
BSV: Rules remain operation6centric( remaining closer to the spec and easier to maintain correctly
Copyright Bluespec Inc. 2005
2@
Broad6#rush di$$erences #et een BSV and 3TL and System2: BSV is not simulation6centric
3TL and System2 are simulation6centric -Synthesi9a#le su#sets. ere de$ined later 0any concepts?constructs are a consequence o$ this S)6process6 li<e simulation vie : 1:g:(
1'ecution o$ a process has a program6counter6li<e -locus o$ control. Varia#les have the semantics o$ updata#le memory locations( updated hen -e'ecution reaches this statement. Sensitivity lists -I$ e'ecution reaches this statement( the ire is driven ith the value o$ the right6hand side. @unctions?procedures get called( e'ecute( and return 7stac< li<e semantics8
Aone o$ these are particularly meaning$ul $rom a !) point o$ vie : the tail 7simulation8 is agging the dog 7!) description8 BSV is not simulation6centric( and in these respects( BSV is closer to traditional !) vie
Copyright Bluespec Inc. 2005
22
Broad6#rush di$$erences #et een BSV and 3TL and System2: &re sequential processes a good starting point% People o$ten say: -I+m descri#ing the algorithm o$ my !) #loc< using 2?255 or Behavioral 3TL. &ctually( they+re descri#ing the function( not the algorithm & function spec o$ I?= #ehavior( ithout consideration $or implementa#ility( and in particular ithout consideration $or cost in space 7circuitry8 or time 7per$ormance8 &n algorithm a speci$ic implementation !ith a "articular cost model
"i$$erent computation models( ith di$$erent cost models( usually require radically di$$erent algorithms $or implementing the same $unction
Copyright Bluespec Inc. 2005
2/
Broad6#rush di$$erences #et een BSV and 3TL and System2: &re sequential processes a good starting point%
Thus( sequential speci$ications 7e:g:( 2?2558( hile $ine $or descri#ing desired $unctionality( are usually not a good starting point $or descri#ing desired microarchitectures? algorithms In BSV( you thin< directly and constantly in parallel (Rules), $rom a#stract models to implementations
Copyright Bluespec Inc. 2005
26
Broad6#rush di$$erences #et een BSV and 3TL and System2: In$luences and inspirations
herever it
Identi$iers( constants( operators( e'pressions( comments( types( modules( inter$aces( instantiation( parameteri9ation( varia#le declaration( assignments( conditionals( loops( $unctions
BSV departs $rom SystemVerilog notation in ,ust those places here it ma<es sense:
1'press #ehavior using Rules and Rule#$ased %nterface Methods 7instead o$ processes?events8 0ore general parameteri9ation
Copyright Bluespec Inc. 2005
25
Broad6#rush di$$erences #et een BSV and 3TL and System2: 0odule hierarchy BSV has e'actly the same notion o$ module hierarchy as 3TL
In $act( more stringently so: e&en registers are modules 7at the leaves o$ the hierarchy8: In BSV( ordinary varia#les ne&er represent registers: Thus( designers e'ercise precise control over microarchitecture -I$ so( ho
0icroarchitecture is the creative 7and $un8 part o$ !) design* it distinguishes good designs $rom #ad: The designer should remain involved in this: 2omple' concurrency and control is the hard and tedious part o$ !) design* it+s here most errors arise: BSV+s Rules dramatically simpli$y and automate this:
Copyright Bluespec Inc. 2005
2=
Broad6#rush di$$erences #et een BSV and 3TL and System2: "atapaths and control paths
)ith BSV you don+t thin< separately a#out datapaths and control 1ach Rule speci$ies the part o$ the datapath relevant $or its #ehavior( and the control conditions under hich the path is traversed The Bluespec compiler com$ines these speci$ications to generate the $inal datapaths and control circuitry
2>
Broad6#rush di$$erences #et een BSV and 3TL and System2: Inter$ace #ehavior In 3TL and synthesi9a#le System2( inter$aces are merely port lists
Behavior speci$ied in ad hoc accompanying te't and?or timing diagrams In$le'i#le( tedious( source o$ many errors
Broups o$ ports capturing a complete microprotocol( involving signals in #oth directions BSV also $ormali9es scheduling constraints across inter$ace transactions:
2?
Broad6#rush di$$erences #et een BSV and 3TL and System2: @unctional vs: Per$ormance 2orrectness BSV+s Rule semantics provides a $ollo ing:
ay to separate the
@unctional correctness 7-is the result value correct%.8 Per$ormance correctness 7-is the result produced quic<ly%.8
@actori9es veri$ication into separately managea#le su#6 pro#lems Rule semantics provide a #asis to systematically alter the implementation $or $aster per$ormance ithout #rea<ing $unctional correctness 7re$inement8
2C
Broad6#rush di$$erences #et een BSV and 3TL and System2: Integrating Behavior and Static 1la#oration &ll !"Ls have some -punning. to descri#e static ela#oration and #ehavior: 1:g:(
& loop can #e used to statically e'press a linear repeated hard are structure 7-generate.8 & loop can #e used to e'press iterative #ehavior
In BSV( the static ela#oration language is very po er$ul 7Turing complete8( ith assignments( conditionals( loops( $unctions( recursion( etc:( and integrated cleanly and smoothly
Copyright Bluespec Inc. 2005
/0
Setting your e'pectations a#out hat you ill learn $rom a $e days o$ training
7arn your 8h.3. from home in 9ust : months; <all toll'free no%;
3spa% 4
1apping an i*ea or specification into B-. har*ware' an* using a"straction well' ta:es training an* practice) one can<t "eco%e an e&pert overnightL However' even after these few *ays of training' you will "e a"le to *esign using B-.' an* still e&pect at least a 2& i%prove%ent in your pro*uctivity
The "asics are easyL (ven easier than .erilogA.H !' we "elieve' "ecause of the *irect' natural way to *escri"e H9 that is H9+centric an* not si%ulation+ centric (&perience in previous training sessions has "orne this out ti%e an* againL 7$haL I get it nowL 9owL 9hy woul* I ever go "ac: to ,T!#8
Copyright Bluespec Inc. 2005
/@
Bluespec @lo
Bluespec SystemVerilog source
T0
=ther Verilog?V!"L
Verilog sim
3TL synthesis
V2" output
(egend files Blues"ec tools 3rd "art' tools
gates
/2
Bluespec is the only (-! solution that a**resses Control' Co%ple& atapaths an* $lgorith%s
$% cache ctlr
RA# ctlr
(etwork proc )ueuing engines orting *ueue Arbiter IP lookup 'ebug controller
Co%ple& Co%ple& atapaths atapaths 3e.g. 3e.g. processorA processorA controller4 controller4
Control Control
I%!
/IR filter
//
1nd o$ Lecture