技术控

    今日:130| 主题:49225
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Hitchhiker's Guide to the WaveDrom

[复制链接]
神马是浮云 发表于 2016-10-3 23:43:32
107 3

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
WaveDrom is a JavaScript application. WaveJSON is a format that describes Digital Timing Diagrams. WaveDrom renders the diagrams directly inside the browser. Element  "signal"is an array of WaveLanes. Each WaveLane has two mandatory fields:  "name"and  "wave".  Step 1. The Signal

Lets start with a quick example. Following code will create 1-bit signal named  "Alfa"that changes its state over time.
  1. { signal: [{ name: "Alfa", wave: "01.zx=ud.23.45" }] }
复制代码
Every character in the  "wave"string represents a single time period. Symbol  "."extends previous state for one more period. Here is how it looks:  Edit Me >>  Step 2. Adding Clock

Digital clock is a special type of signal. It changes twice per time period and can have positive or negative polarity. It also can have an optional marker on the working edge. The clock's blocks can be mixed with other signal states to create the clock gating effects. Here is the code:
  1. { signal: [
  2.   { name: "pclk", wave: 'p.......' },
  3.   { name: "Pclk", wave: 'P.......' },
  4.   { name: "nclk", wave: 'n.......' },
  5.   { name: "Nclk", wave: 'N.......' },
  6.   {},
  7.   { name: 'clk0', wave: 'phnlPHNL' },
  8.   { name: 'clk1', wave: 'xhlhLHl.' },
  9.   { name: 'clk2', wave: 'hpHplnLn' },
  10.   { name: 'clk3', wave: 'nhNhplPl' },
  11.   { name: 'clk4', wave: 'xlh.L.Hx' },
  12. ]}
复制代码
and the rendered diagram:  Edit Me >>  Step 3. Putting all together

Typical timing diagram would have the clock and signals (wires). Multi-bit signals will try to grab the labels from  "data"array.
  1. { signal: [
  2.   { name: "clk",  wave: "P......" },
  3.   { name: "bus",  wave: "x.==.=x", data: ["head", "body", "tail", "data"] },
  4.   { name: "wire", wave: "0.1..0." }
  5. ]}
复制代码
Edit Me >>  Step 4. Spacers and Gaps

  1. { signal: [
  2.   { name: "clk",         wave: "p.....|..." },
  3.   { name: "Data",        wave: "x.345x|=.x", data: ["head", "body", "tail", "data"] },
  4.   { name: "Request",     wave: "0.1..0|1.0" },
  5.   {},
  6.   { name: "Acknowledge", wave: "1.....|01." }
  7. ]}
复制代码
Edit Me >>  Step 5. The groups

WaveLanes can be united in named groups that are represented in form of arrays.  ['group name', {...}, {...}, ...]The first entry of array is the group's name. The groups can be nested.
  1. { signal: [
  2.   {    name: 'clk',   wave: 'p..Pp..P'},
  3.   ['Master',
  4.     ['ctrl',
  5.       {name: 'write', wave: '01.0....'},
  6.       {name: 'read',  wave: '0...1..0'}
  7.     ],
  8.     {  name: 'addr',  wave: 'x3.x4..x', data: 'A1 A2'},
  9.     {  name: 'wdata', wave: 'x3.x....', data: 'D1'   },
  10.   ],
  11.   {},
  12.   ['Slave',
  13.     ['ctrl',
  14.       {name: 'ack',   wave: 'x01x0.1x'},
  15.     ],
  16.     {  name: 'rdata', wave: 'x.....4x', data: 'Q2'},
  17.   ]
  18. ]}
复制代码
Edit Me >>  Step 6. Period and Phase

  "period"and  "phase"parameters can be used to adjust each WaveLane.  DDR Read transaction

  1. { signal: [
  2.   { name: "CK",   wave: "P.......",                                              period: 2  },
  3.   { name: "CMD",  wave: "x.3x=x4x=x=x=x=x", data: "RAS NOP CAS NOP NOP NOP NOP", phase: 0.5 },
  4.   { name: "ADDR", wave: "x.=x..=x........", data: "ROW COL",                     phase: 0.5 },
  5.   { name: "DQS",  wave: "z.......0.1010z." },
  6.   { name: "DQ",   wave: "z.........5555z.", data: "D0 D1 D2 D3" }
  7. ]}
复制代码
Edit Me >>  Step 7.The config{} property

The  config:{...}property controls different aspects of rendering.  hscale

  config:{hscale:#}property controls the horizontal scale of the diagram. User can put any integer number greater than 0.
  1. { signal: [
  2.   { name: "clk",     wave: "p...." },
  3.   { name: "Data",    wave: "x345x",  data: ["head", "body", "tail"] },
  4.   { name: "Request", wave: "01..0" }
  5.   ],
  6.   config: { hscale: 1 }
  7. }
复制代码
hscale = 1 (default)

  Edit Me >>  hscale = 2

  Edit Me >>  hscale = 3

  Edit Me >>  skin

  config:{skin:'...'}property can be used to select the  WaveDrom skin. The property works only inside the first timing diagram on the page.WaveDrom Editorincludes two standard skins:    'default'and    'narrow'    head/foot

    head:{...}and    foot:{...}properties define the content of the area above and below the timing diagram.    tick

-adds timeline labels aligned to vertical markers.    tock

-adds timeline labels between the vertical markers.    text

-adds title / caption text.   
  1. {signal: [
  2.   {name:'clk',         wave: 'p....' },
  3.   {name:'Data',        wave: 'x345x', data: 'a b c' },
  4.   {name:'Request',     wave: '01..0' }
  5. ],
  6. head:{
  7.    text:'WaveDrom example',
  8.    tick:0,
  9. },
  10. foot:{
  11.    text:'Figure 100',
  12.    tock:9
  13. },
  14. }
复制代码
   Edit Me >>      head/    foottext has all properties of SVG text. Standard SVG    tspanattributes can be used to modify default properties of text.    JsonMLmarkup language used to represent SVG text content. Several predefined styles can be used and intermixed:  
      h1    h2    h3    h4    h5    h6-- predefined font sizes.  
      muted    warning    error    info    success-- font color styles.  
  Other SVG    tspanattributes can be used in freestyle as shown below.  
  1. {signal: [
  2.   {name:'clk', wave: 'p.....PPPPp....' },
  3.   {name:'dat', wave: 'x....2345x.....', data: 'a b c d' },
  4.   {name:'req', wave: '0....1...0.....' }
  5. ],
  6. head: {text:
  7.   ['tspan',
  8.     ['tspan', {class:'error h1'}, 'error '],
  9.     ['tspan', {class:'warning h2'}, 'warning '],
  10.     ['tspan', {class:'info h3'}, 'info '],
  11.     ['tspan', {class:'success h4'}, 'success '],
  12.     ['tspan', {class:'muted h5'}, 'muted '],
  13.     ['tspan', {class:'h6'}, 'h6 '],
  14.     'default ',
  15.     ['tspan', {fill:'pink', 'font-weight':'bold', 'font-style':'italic'}, 'pink-bold-italic']
  16.   ]
  17. },
  18. foot: {text:
  19.   ['tspan', 'E=mc',
  20.     ['tspan', {dy:'-5'}, '2'],
  21.     ['tspan', {dy: '5'}, '. '],
  22.     ['tspan', {'font-size':'25'}, 'B '],
  23.     ['tspan', {'text-decoration':'overline'},'over '],
  24.     ['tspan', {'text-decoration':'underline'},'under '],
  25.     ['tspan', {'baseline-shift':'sub'}, 'sub '],
  26.     ['tspan', {'baseline-shift':'super'}, 'super ']
  27.   ],tock:-5
  28. }
  29. }
复制代码
Edit Me >>  Step 8. Arrows

  Splines

  1. ~    -~
  2. <~>  <-~>
  3. ~>   -~>  ~->
复制代码
  1. { signal: [
  2.   { name: "pclk", wave: 'p.......' },
  3.   { name: "Pclk", wave: 'P.......' },
  4.   { name: "nclk", wave: 'n.......' },
  5.   { name: "Nclk", wave: 'N.......' },
  6.   {},
  7.   { name: 'clk0', wave: 'phnlPHNL' },
  8.   { name: 'clk1', wave: 'xhlhLHl.' },
  9.   { name: 'clk2', wave: 'hpHplnLn' },
  10.   { name: 'clk3', wave: 'nhNhplPl' },
  11.   { name: 'clk4', wave: 'xlh.L.Hx' },
  12. ]}0
复制代码
Edit Me >>  Sharp lines

  1. { signal: [
  2.   { name: "pclk", wave: 'p.......' },
  3.   { name: "Pclk", wave: 'P.......' },
  4.   { name: "nclk", wave: 'n.......' },
  5.   { name: "Nclk", wave: 'N.......' },
  6.   {},
  7.   { name: 'clk0', wave: 'phnlPHNL' },
  8.   { name: 'clk1', wave: 'xhlhLHl.' },
  9.   { name: 'clk2', wave: 'hpHplnLn' },
  10.   { name: 'clk3', wave: 'nhNhplPl' },
  11.   { name: 'clk4', wave: 'xlh.L.Hx' },
  12. ]}1
复制代码
  1. { signal: [
  2.   { name: "pclk", wave: 'p.......' },
  3.   { name: "Pclk", wave: 'P.......' },
  4.   { name: "nclk", wave: 'n.......' },
  5.   { name: "Nclk", wave: 'N.......' },
  6.   {},
  7.   { name: 'clk0', wave: 'phnlPHNL' },
  8.   { name: 'clk1', wave: 'xhlhLHl.' },
  9.   { name: 'clk2', wave: 'hpHplnLn' },
  10.   { name: 'clk3', wave: 'nhNhplPl' },
  11.   { name: 'clk4', wave: 'xlh.L.Hx' },
  12. ]}2
复制代码
Edit Me >>  Step 9. Some code

  1. { signal: [
  2.   { name: "pclk", wave: 'p.......' },
  3.   { name: "Pclk", wave: 'P.......' },
  4.   { name: "nclk", wave: 'n.......' },
  5.   { name: "Nclk", wave: 'N.......' },
  6.   {},
  7.   { name: 'clk0', wave: 'phnlPHNL' },
  8.   { name: 'clk1', wave: 'xhlhLHl.' },
  9.   { name: 'clk2', wave: 'hpHplnLn' },
  10.   { name: 'clk3', wave: 'nhNhplPl' },
  11.   { name: 'clk4', wave: 'xlh.L.Hx' },
  12. ]}3
复制代码
友荐云推荐




上一篇:Runtime Introspection of Flow Types in JS
下一篇:C Is Not Reasonable
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

程彬航 发表于 2016-10-4 00:58:25
楼主,楼主你真好,此贴必定火三年。
回复 支持 反对

使用道具 举报

刘洪 发表于 2016-10-4 02:31:15
神马是浮云是男的还是女的?
回复 支持 反对

使用道具 举报

tywgv9trsf 发表于 2016-10-25 00:11:05
围观 围观 沙发在哪里!!!
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表