From WikiChip
Difference between revisions of "Module:microarchitecture"

(added PE configs)
 
(47 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
local uarch = {}
 
local uarch = {}
 +
local origArgs
  
 
function add_header_main(box, str)
 
function add_header_main(box, str)
Line 27: Line 28:
 
         :attr('class', 'value')
 
         :attr('class', 'value')
 
         :wikitext(value)
 
         :wikitext(value)
 +
end
 +
 +
function has_arg(name)
 +
-- The argument can exist and be empty or not exist at all
 +
return string.len(origArgs[name] or '') > 0
 +
end
 +
 +
function arg(name)
 +
return origArgs[name]
 +
end
 +
 +
function uarch.set_val(prop, val)
 +
uarch.frame:preprocess('{{#set: ' .. prop .. '=' .. val .. '}}')
 
end
 
end
  
 
function uarch.uarch(frame)
 
function uarch.uarch(frame)
 +
 +
uarch.frame = frame
 +
    if frame == mw.getCurrentFrame() then
 +
        origArgs = frame:getParent().args
 +
    else
 +
        origArgs = frame
 +
    end
 +
 
     local infobox = mw.html.create('table')
 
     local infobox = mw.html.create('table')
  
 
     infobox
 
     infobox
 
         :attr('class', 'infobox')
 
         :attr('class', 'infobox')
 +
       
 +
    infobox
 +
    :tag('tr')
 +
:tag('td'):attr('colspan', '2')
 +
:tag('small'):attr('style', 'float: right; font-weight: bold;')
 +
            :wikitext('[[Special:FormEdit/microarchitecture/' .. frame:preprocess('{{FULLPAGENAME}}') .. '|<i class="fa fa-edit"></i>Edit Values]]')
 
          
 
          
 
     -- header
 
     -- header
     if string.len(frame.args.name or '') == 0 then return 'ERROR: "name" is missing!' end
+
     if not has_arg('name') then return tostring(infobox) .. '[[Category:Articles with invalid parameter in template]]<strong>* ERROR: "name" is missing!</strong>' end
add_header_main(infobox, '[[codename::' .. frame.args.name .. '| ]][[name::' .. frame.args.name .. ']] µarch')
+
   
 +
    uarch.set_val('name', arg('name'))
 +
    uarch.set_val('codename',  arg('name'))
 +
add_header_main(infobox, arg('name') .. ' µarch')
  
 
add_header(infobox, 'General Info')
 
add_header(infobox, 'General Info')
 +
 +
    if not has_arg('atype') then return tostring(infobox) .. '[[Category:Articles with invalid parameter in template]]<strong>ERROR: "atype" is missing!</strong>' end
 +
    if not has_arg('designer') then return tostring(infobox) .. '[[Category:Articles with invalid parameter in template]]<strong>ERROR: "designer" is missing!</strong>' end
  
 
     -- arch type
 
     -- arch type
    if string.len(frame.args.atype or '') == 0 then return 'ERROR: "atype" is missing!' end
+
add_entry(infobox, 'Arch Type', arg('atype') ..
add_entry(infobox, 'Arch Type', frame.args.atype ..
+
'[[Category:' .. string.lower(arg('atype')) .. ' microarchitectures by ' .. string.lower(arg('designer')) .. ']]')
'[[microarchitecture type::' .. frame.args.atype .. '| ]]' ..
+
    uarch.set_val('microarchitecture type',  arg('atype'))
'[[Category:' .. string.lower(frame.args.atype) .. ' microarchitectures by ' .. string.lower(frame.args.designer) .. ']]')
 
  
 
-- designer
 
-- designer
    if string.len(frame.args.designer or '') == 0 then return 'ERROR: "designer" is missing!' end
 
 
     local devs
 
     local devs
 
      
 
      
     devs = '[[designer::' .. string.lower(frame.args.designer) .. '| ]]' .. frame.args.designer
+
     uarch.set_val('designer',  arg('designer'))
     devs = devs .. '[[Category:microarchitectures by ' .. string.lower(frame.args.designer) .. ']]'
+
     devs = arg('designer') .. '[[Category:microarchitectures by ' .. string.lower(arg('designer')) .. ']]'
 
      
 
      
 
     for i = 2, 10 do
 
     for i = 2, 10 do
     if string.len(frame.args['designer_' .. i] or '') == 0 then break end
+
     if not has_arg('designer ' .. i) then break end
     devs = devs .. ', [[designer::' .. string.lower(frame.args['designer_' .. i]) .. '| ]]' ..
+
    uarch.set_val('designer',  arg('designer ' .. i))
    frame.args.designer ..
+
     devs = devs .. ', ' .. arg('designer ' .. i) ..
    '[[Category:microarchitectures by ' .. string.lower(frame.args['designer_' .. i]) .. ']]'
+
    '[[Category:microarchitectures by ' .. string.lower(arg('designer ' .. i)) .. ']]'
 +
    devs = devs ..
 +
    '[[Category:' .. string.lower(arg('atype')) .. ' microarchitectures by ' .. string.lower(arg('designer ' .. i)) .. ']]'
 
end
 
end
 
add_entry(infobox, 'Designer', devs)
 
add_entry(infobox, 'Designer', devs)
Line 64: Line 98:
 
 
 
-- manufacturer
 
-- manufacturer
     if string.len(frame.args.manufacturer or '') == 0 then return 'ERROR: "manufacturer" is missing!' end
+
     if not has_arg('manufacturer') then return '[[Category:Articles with invalid parameter in template]]ERROR: "manufacturer" is missing!' end
     local devs
+
uarch.set_val('manufacturer',  arg('manufacturer'))
   
+
     local devs = '[[manufacturer::' .. arg('manufacturer') .. ']]'
    devs = '[[manufacturer::' .. string.lower(frame.args.manufacturer) .. '| ]]'
 
    .. frame.args.manufacturer
 
   
 
 
     for i = 2, 10 do
 
     for i = 2, 10 do
     if string.len(frame.args['manufacturer_' .. i] or '') == 0 then break end
+
     if not has_arg('manufacturer ' .. i) then break end
     devs = devs .. ', [[manufacturer::' .. string.lower(frame.args['manufacturer_' .. i]) .. '| ]]'
+
    uarch.set_val('manufacturer',  arg('manufacturer ' .. i))
    .. frame.args['manufacturer_' .. i]
+
     devs = devs .. ', [[manufacturer::' .. arg('manufacturer ' .. i) .. ']]'
 
end
 
end
 
add_entry(infobox, 'Manufacturer', devs)
 
add_entry(infobox, 'Manufacturer', devs)
 
 
 
     -- intro
 
     -- intro
     if string.len(frame.args.introduction or '') > 0 then
+
     if has_arg('introduction') then
add_entry(infobox, 'Introduction', '[[first launched::' .. frame.args.introduction .. ']]')
+
    uarch.set_val('first launched',  arg('introduction'))
 +
add_entry(infobox, 'Introduction', arg('introduction'))
 
end
 
end
 
 
 
     -- phase-out
 
     -- phase-out
     if string.len(frame.args.phase_out or '') > 0 then
+
     if has_arg('phase-out') then
add_entry(infobox, 'Phase-out', '[[phase-out::' .. frame.args.phase_out .. ']]')
+
    uarch.set_val('phase-out',  arg('phase-out'))
 +
add_entry(infobox, 'Phase-out', arg('phase-out'))
 
end
 
end
 
 
Line 90: Line 123:
 
 
 
-- process
 
-- process
     if string.len(frame.args.process or '') > 0 then
+
     if has_arg('process') then
 
    local proc
 
    local proc
 
     
 
     
    proc = '[[process::' .. frame.args.process .. '| ]]' ..
+
    uarch.set_val('process',  arg('process'))
    '[[' ..  frame.args.process .. ' process|' ..  frame.args.process .. ']]'
+
    proc = '[[' ..  arg('process') .. ' process|' ..  arg('process') .. ']]'
 
     
 
     
 
    for i = 2, 10 do
 
    for i = 2, 10 do
    if string.len(frame.args['process_' .. i] or '') == 0 then break end
+
    if string.len(origArgs['process ' .. i] or '') == 0 then break end
    proc = proc .. ', [[process::' ..frame.args['process_' .. i] .. '| ]]'
+
    uarch.set_val('process',  arg('process ' .. i))
    .. '[['..  frame.args['process_' .. i] .. ' process|' .. frame.args['process_' .. i] .. ']]'
+
    proc = proc .. ', [['..  arg('process ' .. i) .. ' process|' .. arg('process ' .. i) .. ']]'
 
end
 
end
 
add_entry(infobox, 'Process', proc)
 
add_entry(infobox, 'Process', proc)
Line 106: Line 139:
 
 
 
-- cores
 
-- cores
     if string.len(frame.args.cores or '') > 0 then
+
     if string.len(origArgs.cores or '') > 0 then
 
    local core
 
    local core
 
     
 
     
    core = '[[core count::' .. frame.args.cores .. '| ]]'
+
    core = '[[core count::' .. origArgs.cores .. '| ]]'
    .. '[[' .. frame.args.cores .. ' cores|' .. frame.args.cores .. ']]'
+
    .. '[[' .. origArgs.cores .. ' cores|' .. origArgs.cores .. ']]'
 
     
 
     
    for i = 2, 10 do
+
    for i = 2, 20 do
    if string.len(frame.args['cores_' .. i] or '') == 0 then break end
+
    if string.len(origArgs['cores ' .. i] or '') == 0 then break end
    core = core .. ', [[core count::' ..frame.args['cores_' .. i] .. '| ]]'
+
    core = core .. ', [[core count::' ..origArgs['cores ' .. i] .. '| ]]'
    .. '[[' .. frame.args['cores_' .. i] .. ' cores|' .. frame.args['cores_' .. i] .. ']]'
+
    .. '[[' .. origArgs['cores ' .. i] .. ' cores|' .. origArgs['cores ' .. i] .. ']]'
 
end
 
end
 
add_entry(infobox, 'Core Configs', core)
 
add_entry(infobox, 'Core Configs', core)
Line 121: Line 154:
 
 
 
 
add_header(infobox, 'Pipeline')
+
-- processing elements
 +
    if has_arg('processing elements') then
 +
    local pe
 +
   
 +
    pe = '[[processing element count::' .. arg('processing elements') .. '| ]]'
 +
    .. arg('processing elements')
 +
   
 +
    for i = 2, 20 do
 +
    if not has_arg('processing elements ' .. i) then break end
 +
    pe = pe .. ', [[processing element count::' .. arg('processing elements ' .. i) .. '| ]]'
 +
    .. arg('processing elements ' .. i)
 +
end
 +
add_entry(infobox, 'PE Configs', pe)
 +
end
 +
 +
if has_arg('type') or has_arg('oooe') or has_arg('speculative')
 +
or has_arg('renaming') or has_arg('stages') or has_arg('stages min')
 +
or has_arg('decode') then
 +
add_header(infobox, 'Pipeline')
 +
end
 
 
 
-- type
 
-- type
     if string.len(frame.args.ptype or '') > 0 then
+
     if string.len(origArgs['type'] or '') > 0 then
 
    local ptype
 
    local ptype
 
     
 
     
    ptype = frame.args.ptype
+
    ptype = origArgs['type']
 
    for i = 2, 10 do
 
    for i = 2, 10 do
    if string.len(frame.args['ptype_' .. i] or '') == 0 then break end
+
    if string.len(origArgs['type ' .. i] or '') == 0 then break end
    ptype = ptype .. ', ' .. frame.args['ptype_' .. i]
+
    ptype = ptype .. ', ' .. origArgs['type ' .. i]
 
end
 
end
 
add_entry(infobox, 'Type', ptype)
 
add_entry(infobox, 'Type', ptype)
Line 136: Line 188:
 
 
 
     -- oooe
 
     -- oooe
     if string.len(frame.args.oooe or '') > 0 then
+
     if string.len(origArgs.oooe or '') > 0 then
add_entry(infobox, 'OoOE', frame.args.oooe)
+
add_entry(infobox, 'OoOE', origArgs.oooe)
 
end
 
end
 
 
 
     -- speculative
 
     -- speculative
     if string.len(frame.args.speculative or '') > 0 then
+
     if string.len(origArgs.speculative or '') > 0 then
add_entry(infobox, 'Speculative', frame.args.speculative)
+
add_entry(infobox, 'Speculative', origArgs.speculative)
 
end
 
end
 
 
     -- reg_renaming
+
     -- renaming
     if string.len(frame.args.reg_renaming or '') > 0 then
+
     if string.len(origArgs.renaming or '') > 0 then
add_entry(infobox, 'Reg Renaming', frame.args.reg_renaming)
+
add_entry(infobox, 'Reg Renaming', origArgs.renaming)
 
end
 
end
 
 
     -- pstage
+
     -- stages
     if string.len(frame.args.pstage or '') > 0 then
+
     if string.len(origArgs.stages or '') > 0 then
add_entry(infobox, 'Stages', '[[pipeline stages::' .. frame.args.pstage .. ']]')
+
add_entry(infobox, 'Stages', '[[pipeline stages::' .. origArgs.stages .. ']]')
 
end
 
end
 
 
     -- pstage min/max
+
     -- stages min/max
     if string.len(frame.args.pstages_min or '') > 0 then
+
     if string.len(origArgs['stages min'] or '') > 0 then
 
add_entry(infobox, 'Stages',
 
add_entry(infobox, 'Stages',
'[[pipeline stages (min)::' .. frame.args.pstages_min .. ']]'
+
'[[pipeline stages (min)::' .. origArgs['stages min'] .. ']]'
.. '-[[pipeline stages (max)::' .. frame.args.pstages_max .. ']]')
+
.. '-[[pipeline stages (max)::' .. origArgs['stages max'] .. ']]')
 
end
 
end
 
 
 
     -- decode
 
     -- decode
     if string.len(frame.args.decode or '') > 0 then
+
     if string.len(origArgs.decode or '') > 0 then
add_entry(infobox, 'Decode', frame.args.decode)
+
add_entry(infobox, 'Decode', origArgs.decode)
 
end
 
end
 
 
 
 
add_header(infobox, 'Instructions')
+
    if has_arg('isa') or has_arg('features') or has_arg('extension') then
 +
add_header(infobox, 'Instructions')
 +
end
 
 
 
-- ISA
 
-- ISA
     if string.len(frame.args.isa or '') > 0 then
+
     if string.len(origArgs.isa or '') > 0 then
 
    local isa
 
    local isa
 
     
 
     
    isa = '[[instruction set architecture::' .. frame.args.isa .. ']]'
+
    isa = '[[instruction set architecture::' .. origArgs.isa .. ']]'
 
    for i = 2, 10 do
 
    for i = 2, 10 do
    if string.len(frame.args['isa_' .. i] or '') == 0 then break end
+
    if string.len(origArgs['isa ' .. i] or '') == 0 then break end
    isa = isa .. ', ' .. '[[instruction set architecture::' .. frame.args['isa_' .. i] .. ']]'
+
    isa = isa .. ', ' .. '[[instruction set architecture::' .. origArgs['isa ' .. i] .. ']]'
 
end
 
end
 
add_entry(infobox, 'ISA', isa)
 
add_entry(infobox, 'ISA', isa)
Line 183: Line 237:
 
 
 
-- features
 
-- features
     if string.len(frame.args.features or '') > 0 then
+
     if string.len(origArgs.features or '') > 0 then
 
    local features
 
    local features
 
     
 
     
    features = frame.args.features
+
    features = origArgs.features
 
    for i = 2, 10 do
 
    for i = 2, 10 do
    if string.len(frame.args['features_' .. i] or '') == 0 then break end
+
    if string.len(origArgs['features ' .. i] or '') == 0 then break end
    features = features .. ', ' .. frame.args['features_' .. i]
+
    features = features .. ', ' .. origArgs['features ' .. i]
 
end
 
end
 
add_entry(infobox, 'Features', features)
 
add_entry(infobox, 'Features', features)
Line 195: Line 249:
 
 
 
-- extensions
 
-- extensions
     if string.len(frame.args.extensions or '') > 0 then
+
     if string.len(origArgs.extension or '') > 0 then
    local extensions
+
    local extension
 
     
 
     
    extensions = frame.args.extensions
+
    extension = origArgs.extension
 
    for i = 2, 40 do
 
    for i = 2, 40 do
    if string.len(frame.args['extensions_' .. i] or '') == 0 then break end
+
    if string.len(origArgs['extension ' .. i] or '') == 0 then break end
    extensions = extensions .. ', ' .. frame.args['extensions_' .. i]
+
    extension = extension .. ', ' .. origArgs['extension ' .. i]
 
end
 
end
add_entry(infobox, 'Extensions', extensions)
+
add_entry(infobox, 'Extensions', extension)
 
end
 
end
 
 
add_header(infobox, 'Cache')
+
 +
 +
 +
if has_arg('l1') or has_arg('l1i') or has_arg('l1d') or
 +
has_arg('l2') or has_arg('l3') or has_arg('l3') or
 +
has_arg('side cache') then
 +
add_header(infobox, 'Cache')
 +
end
 
 
 
     -- L1i
 
     -- L1i
     if string.len(frame.args.l1i or '') > 0 then
+
     if string.len(origArgs.l1i or '') > 0 then
     local li = frame.args.l1i
+
     local li = origArgs.l1i
     if string.len(frame.args.l1i_per or '') > 0 then
+
     if string.len(origArgs['l1i per'] or '') > 0 then
     li = li .. '/' .. frame.args.l1i_per
+
     li = li .. '/' .. origArgs['l1i per']
 
end
 
end
     if string.len(frame.args.l1i_desc or '') > 0 then
+
     if string.len(origArgs['l1i desc'] or '') > 0 then
     li = li .. '<br>' .. frame.args.l1i_desc
+
     li = li .. '<br>' .. origArgs['l1i desc']
 
end
 
end
 
add_entry(infobox, 'L1I Cache',  li)
 
add_entry(infobox, 'L1I Cache',  li)
Line 221: Line 282:
 
 
 
     -- L1d
 
     -- L1d
     if string.len(frame.args.l1d or '') > 0 then
+
     if string.len(origArgs.l1d or '') > 0 then
     local li = frame.args.l1d
+
     local li = origArgs.l1d
     if string.len(frame.args.l1d_per or '') > 0 then
+
     if string.len(origArgs['l1d per'] or '') > 0 then
     li = li .. '/' .. frame.args.l1d_per
+
     li = li .. '/' .. origArgs['l1d per']
 
end
 
end
     if string.len(frame.args.l1d_desc or '') > 0 then
+
     if string.len(origArgs['l1d desc'] or '') > 0 then
     li = li .. '<br>' .. frame.args.l1d_desc
+
     li = li .. '<br>' .. origArgs['l1d desc']
 
end
 
end
 
add_entry(infobox, 'L1D Cache',  li)
 
add_entry(infobox, 'L1D Cache',  li)
 +
end
 +
 +
    -- L1, Unified
 +
    if string.len(origArgs.l1 or '') > 0 then
 +
    local li = origArgs.l1
 +
    if string.len(origArgs['l1 per'] or '') > 0 then
 +
    li = li .. '/' .. origArgs['l1 per']
 +
end
 +
    if string.len(origArgs['l1 desc'] or '') > 0 then
 +
    li = li .. '<br>' .. origArgs['l1 desc']
 +
end
 +
add_entry(infobox, 'L1 Cache',  li)
 
end
 
end
 
 
 
     -- L2
 
     -- L2
     if string.len(frame.args.l2 or '') > 0 then
+
     if string.len(origArgs.l2 or '') > 0 then
     local l2 = frame.args.l2
+
     local l2 = origArgs.l2
     if string.len(frame.args.l2_per or '') > 0 then
+
     if string.len(origArgs['l2 per'] or '') > 0 then
     l2 = l2 .. '/' .. frame.args.l2_per
+
     l2 = l2 .. '/' .. origArgs['l2 per']
 
end
 
end
     if string.len(frame.args.l2_desc or '') > 0 then
+
     if string.len(origArgs['l2 desc'] or '') > 0 then
     l2 = l2 .. '<br>' .. frame.args.l2_desc
+
     l2 = l2 .. '<br>' .. origArgs['l2 desc']
 
end
 
end
 
add_entry(infobox, 'L2 Cache',  l2)
 
add_entry(infobox, 'L2 Cache',  l2)
Line 245: Line 318:
 
 
 
     -- L3
 
     -- L3
     if string.len(frame.args.l3 or '') > 0 then
+
     if string.len(origArgs.l3 or '') > 0 then
     local l3 = frame.args.l3
+
     local l3 = origArgs.l3
     if string.len(frame.args.l3_per or '') > 0 then
+
     if string.len(origArgs['l3 per'] or '') > 0 then
     l3 = l3 .. '/' .. frame.args.l3_per
+
     l3 = l3 .. '/' .. origArgs['l3 per']
 
end
 
end
     if string.len(frame.args.l3_desc or '') > 0 then
+
     if string.len(origArgs['l3 desc'] or '') > 0 then
     l3 = l3 .. '<br>' .. frame.args.l3_desc
+
     l3 = l3 .. '<br>' .. origArgs['l3 desc']
 
end
 
end
 
add_entry(infobox, 'L3 Cache',  l3)
 
add_entry(infobox, 'L3 Cache',  l3)
Line 257: Line 330:
 
 
 
     -- L4
 
     -- L4
     if string.len(frame.args.l4 or '') > 0 then
+
     if string.len(origArgs.l4 or '') > 0 then
     local l4 = frame.args.l4
+
     local l4 = origArgs.l4
     if string.len(frame.args.l4_per or '') > 0 then
+
     if string.len(origArgs['l4 per'] or '') > 0 then
     l4 = l4 .. '/' .. frame.args.l4_per
+
     l4 = l4 .. '/' .. origArgs['l4 per']
 
end
 
end
     if string.len(frame.args.l4_desc or '') > 0 then
+
     if string.len(origArgs['l4 desc'] or '') > 0 then
     l4 = l4 .. '<br>' .. frame.args.l4_desc
+
     l4 = l4 .. '<br>' .. origArgs['l4 desc']
 
end
 
end
 
add_entry(infobox, 'L4 Cache',  l4)
 
add_entry(infobox, 'L4 Cache',  l4)
 
end
 
end
 
 
     -- Size $
+
     -- Side $
     if string.len(frame.args.sizecache or '') > 0 then
+
     if has_arg('side cache') then
     local sizecache = frame.args.sizecache
+
     local sidecache = arg('side cache')
     if string.len(frame.args.sizecache_per or '') > 0 then
+
     if has_arg('side cache per') then
     sizecache = sizecache .. '/' .. frame.args.sizecache_per
+
     sidecache = sidecache .. '/' .. arg('side cache per')
 
end
 
end
     if string.len(frame.args.sizecache_desc or '') > 0 then
+
     if has_arg('side cache desc') then
     sizecache = sizecache .. '<br>' .. frame.args.sizecache_desc
+
     sidecache = sidecache .. '<br>' .. arg('side cache desc')
 
end
 
end
add_entry(infobox, 'Size Cache',  sizecache)
+
add_entry(infobox, 'Side Cache',  sidecache)
 
end
 
end
 
 
add_header(infobox, 'Cores')
 
 
 
 
 
 
-- cores
 
-- cores
     if string.len(frame.args.core_name or '') > 0 then
+
     if has_arg('core name') then
    local cores
+
add_header(infobox, 'Cores')
   
+
    cores = frame.args.core_name
+
    local cores = arg('core name')
 
    for i = 2, 10 do
 
    for i = 2, 10 do
    if string.len(frame.args['core_name_' .. i] or '') == 0 then break end
+
    if not has_arg('core name ' .. i) then break end
    cores = cores .. ', ' .. frame.args['core_name_' .. i]
+
    cores = cores .. ',<br>' .. arg('core name ' .. i)
 
end
 
end
add_entry(infobox, 'Core Names', features)
+
add_entry(infobox, 'Core Names', cores)
 
end
 
end
 
 
if string.len(frame.args.successor or '') > 0
+
if has_arg('successor') or has_arg('predecessor') then
or string.len(frame.args.predecessor or '') > 0 then
 
 
add_header(infobox, 'Succession')
 
add_header(infobox, 'Succession')
 
 
 
local s = infobox:tag('tr')
 
local s = infobox:tag('tr')
local d1 = s:tag('td'):tag('div'):attr('style', 'display: inline-flex;')
+
local td = s:tag('td'):attr('colspan', '2')
local d2 = s:tag('td'):tag('div'):attr('style', 'display: inline-flex; float: right;')
+
local d1 = td:tag('div'):attr('style', 'display: inline-flex;')
if string.len(frame.args.predecessor or '') > 0 then
+
local d2 = td:tag('div'):attr('style', 'display: inline-flex; float: right;')
 +
if has_arg('predecessor') then
 
 
 
    local list
 
    local list
    if string.len(frame.args.predecessor_link or '') > 0 then
+
    if has_arg('predecessor link') then
list = '[[' .. frame.args.predecessor_link .. '|' .. frame.args.predecessor .. ']]'
+
list = '[[' .. arg('predecessor link') .. '|' .. arg('predecessor') .. ']]'
 
else
 
else
list = '[[' .. frame.args.predecessor .. ']]'
+
list = '[[' .. arg('predecessor') .. ']]'
 
end
 
end
 
    for i = 2, 10 do
 
    for i = 2, 10 do
    if string.len(frame.args['predecessor_' .. i] or '') == 0 then break end
+
    if not has_arg('predecessor ' .. i) then break end
    if string.len(frame.args['predecessor_link_' .. i] or '') then
+
    if has_arg('predecessor ' .. i .. ' link') then
    list = list .. '[[' .. frame.args['predecessor_link_' .. i] .. '|' ..
+
    list = list .. '<br>[[' .. arg('predecessor ' .. i .. ' link') .. '|' .. arg('predecessor ' .. i) .. ']]'
    frame.args['predecessor_' .. i] .. ']]'
 
 
    else
 
    else
    list = list .. '[[' .. frame.args['predecessor_' .. i] .. ']]'
+
    list = list .. '<br>[[' .. arg('predecessor ' .. i) .. ']]'
 
     end
 
     end
 
end
 
end
Line 328: Line 397:
 
:wikitext(list)
 
:wikitext(list)
 
end
 
end
if string.len(frame.args.successor or '') > 0 then
+
if has_arg('successor') then
 
local list
 
local list
    if string.len(frame.args.successor_link or '') > 0 then
+
    if has_arg('successor link') then
list = '[[' .. frame.args.successor_link .. '|' .. frame.args.successor .. ']]'
+
list = '[[' .. arg('successor link') .. '|' .. arg('successor') .. ']]'
 
else
 
else
list = '[[' .. frame.args.successor .. ']]'
+
list = '[[' .. arg('successor') .. ']]'
 
end
 
end
 
    for i = 2, 10 do
 
    for i = 2, 10 do
    if string.len(frame.args['successor_' .. i] or '') == 0 then break end
+
    if not has_arg('successor ' .. i) then break end
    if string.len(frame.args['successor_link_' .. i] or '') then
+
    if has_arg('successor ' .. i .. ' link') then
    list = list .. '[[' .. frame.args['successor_link_' .. i] .. '|' ..
+
    list = list .. '<br>[[' .. arg('successor ' .. i .. ' link') .. '|' ..
    frame.args['successor_' .. i] .. ']]'
+
    arg('successor ' .. i) .. ']]'
 
    else
 
    else
    list = list .. '[[' .. frame.args['successor_' .. i] .. ']]'
+
    list = list .. '<br>[[' .. arg('successor ' .. i) .. ']]'
 
     end
 
     end
 
end
 
end
Line 347: Line 416:
 
d2:tag('div')
 
d2:tag('div')
 
:attr('style', 'float: left;')
 
:attr('style', 'float: left;')
:wikitext('[[test]]')
+
:wikitext(list)
 
d2:tag('div')
 
d2:tag('div')
 
:attr('style', 'float: right; padding-left: 10px; margin: auto 5px;')
 
:attr('style', 'float: right; padding-left: 10px; margin: auto 5px;')
 
:wikitext('<i class="fa fa-chevron-right"></i>')
 
:wikitext('<i class="fa fa-chevron-right"></i>')
 
end
 
end
 +
end
 +
    -- Contemporary
 +
if has_arg('contemporary') then
 +
add_header(infobox, 'Contemporary')
 +
 +
local s = infobox:tag('tr')
 +
local td = s:tag('td'):attr('colspan', '2')
 +
 +
td:attr('style', 'text-align: center;')
 +
 +
    local list
 +
    if has_arg('contemporary link') then
 +
list = '[[' .. arg('contemporary link') .. '|' .. arg('contemporary') .. ']]'
 +
else
 +
list = '[[' .. arg('contemporary') .. ']]'
 +
end
 +
    for i = 2, 10 do
 +
    if not has_arg('contemporary ' .. i) then break end
 +
    if has_arg('contemporary ' .. i .. ' link') then
 +
    list = list .. '<br>[[' .. arg('contemporary ' .. i .. ' link') .. '|' .. arg('contemporary ' .. i) .. ']]'
 +
    else
 +
    list = list .. '<br>[[' .. arg('contemporary ' .. i) .. ']]'
 +
end
 +
end
 +
 +
td:wikitext(list)
 
end
 
end
 
              
 
              
 
     infobox:wikitext('[[Category:all microarchitectures]]')
 
     infobox:wikitext('[[Category:all microarchitectures]]')
     infobox:wikitext('[[full page name::{{FULLPAGENAME}}| ]]')
+
     infobox:wikitext('[[full page name::' .. frame:preprocess('{{FULLPAGENAME}}') .. '| ]]')
 
     infobox:wikitext('[[instance of::microarchitecture| ]]')
 
     infobox:wikitext('[[instance of::microarchitecture| ]]')
 
 

Latest revision as of 20:47, 15 April 2019

Documentation for this module may be created at Module:microarchitecture/doc

local uarch = {}
local origArgs

function add_header_main(box, str)
      box
        :tag('tr')
          :tag('td')
            :attr('class', 'header-main')
            :attr('colspan', '2')
            :wikitext(str)
end
function add_header(box, str)
      box
        :tag('tr')
          :tag('td')
            :attr('class', 'header')
            :attr('colspan', '2')
            :wikitext(str)
end
function add_entry(box, label, value)
      local tag = box:tag('tr')
      
      tag:tag('td')
        :attr('class', 'label')
        :wikitext(label)
        
      tag:tag('td')
        :attr('class', 'value')
        :wikitext(value)
end

function has_arg(name)
	-- The argument can exist and be empty or not exist at all
	return string.len(origArgs[name] or '') > 0
end

function arg(name)
	return origArgs[name]
end

function uarch.set_val(prop, val)
	uarch.frame:preprocess('{{#set: ' .. prop .. '=' .. val .. '}}')	
end

function uarch.uarch(frame)

	uarch.frame = frame
    if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame
    end

    local infobox = mw.html.create('table')

    infobox
        :attr('class', 'infobox')
        
    infobox
    	:tag('tr')
			:tag('td'):attr('colspan', '2')
			:tag('small'):attr('style', 'float: right; font-weight: bold;')
            :wikitext('[[Special:FormEdit/microarchitecture/' .. frame:preprocess('{{FULLPAGENAME}}') .. '|<i class="fa fa-edit"></i>Edit Values]]')
        
    -- header
    if not has_arg('name') then return tostring(infobox) .. '[[Category:Articles with invalid parameter in template]]<strong>* ERROR: "name" is missing!</strong>' end
    
    uarch.set_val('name',  arg('name'))
    uarch.set_val('codename',  arg('name'))
	add_header_main(infobox, arg('name') .. ' µarch')

	add_header(infobox, 'General Info')
	
    if not has_arg('atype') then return tostring(infobox) .. '[[Category:Articles with invalid parameter in template]]<strong>ERROR: "atype" is missing!</strong>' end
    if not has_arg('designer') then return tostring(infobox) .. '[[Category:Articles with invalid parameter in template]]<strong>ERROR: "designer" is missing!</strong>' end

    -- arch type
	add_entry(infobox, 'Arch Type', arg('atype') ..
		'[[Category:' .. string.lower(arg('atype')) .. ' microarchitectures by ' .. string.lower(arg('designer')) .. ']]')
    uarch.set_val('microarchitecture type',  arg('atype'))

	-- designer
    local devs
    
    uarch.set_val('designer',  arg('designer'))
    devs = arg('designer') .. '[[Category:microarchitectures by ' .. string.lower(arg('designer')) .. ']]'
    
    for i = 2, 10 do
    	if not has_arg('designer ' .. i) then break end
    	uarch.set_val('designer',  arg('designer ' .. i))
    	devs = devs .. ', ' .. arg('designer ' .. i) ..
	    		'[[Category:microarchitectures by ' .. string.lower(arg('designer ' .. i)) .. ']]'
    	devs = devs ..
	    		'[[Category:' .. string.lower(arg('atype')) .. ' microarchitectures by ' .. string.lower(arg('designer ' .. i)) .. ']]'
	end
	add_entry(infobox, 'Designer', devs)
	
	
	-- manufacturer
    if not has_arg('manufacturer') then return '[[Category:Articles with invalid parameter in template]]ERROR: "manufacturer" is missing!' end
	uarch.set_val('manufacturer',  arg('manufacturer'))
    local devs = '[[manufacturer::' .. arg('manufacturer') .. ']]'
    for i = 2, 10 do
    	if not has_arg('manufacturer ' .. i) then break end
    	uarch.set_val('manufacturer',  arg('manufacturer ' .. i))
    	devs = devs .. ', [[manufacturer::' .. arg('manufacturer ' .. i) .. ']]'
	end
	add_entry(infobox, 'Manufacturer', devs)
	
    -- intro
    if has_arg('introduction') then
    	uarch.set_val('first launched',  arg('introduction'))
		add_entry(infobox, 'Introduction', arg('introduction'))
	end
	
    -- phase-out
    if has_arg('phase-out') then
    	uarch.set_val('phase-out',  arg('phase-out'))
		add_entry(infobox, 'Phase-out', arg('phase-out'))
	end
	
	
	
	-- process
    if has_arg('process') then
	    local proc
	    
    	uarch.set_val('process',  arg('process'))
	    proc = '[[' ..  arg('process') .. ' process|' ..  arg('process') .. ']]'
	    
	    for i = 2, 10 do
	    	if string.len(origArgs['process ' .. i] or '') == 0 then break end
    		uarch.set_val('process',  arg('process ' .. i))
	    	proc = proc .. ', [['..  arg('process ' .. i) .. ' process|' .. arg('process ' .. i) .. ']]'
		end
		add_entry(infobox, 'Process', proc)
	end	
	
	
	-- cores
    if string.len(origArgs.cores or '') > 0 then
	    local core
	    
	    core = '[[core count::' .. origArgs.cores .. '| ]]'
	    	.. '[[' .. origArgs.cores .. ' cores|' .. origArgs.cores .. ']]'
	    
	    for i = 2, 20 do
	    	if string.len(origArgs['cores ' .. i] or '') == 0 then break end
	    	core = core .. ', [[core count::' ..origArgs['cores ' .. i] .. '| ]]'
	    		.. '[[' .. origArgs['cores ' .. i] .. ' cores|' .. origArgs['cores ' .. i] .. ']]'
		end
		add_entry(infobox, 'Core Configs', core)
	end
	
	
	-- processing elements
    if has_arg('processing elements') then
	    local pe
	    
	    pe = '[[processing element count::' .. arg('processing elements') .. '| ]]'
	    	.. arg('processing elements')
	    
	    for i = 2, 20 do
	    	if not has_arg('processing elements ' .. i) then break end
	    	pe = pe .. ', [[processing element count::' .. arg('processing elements ' .. i) .. '| ]]'
	    		.. arg('processing elements ' .. i)
		end
		add_entry(infobox, 'PE Configs', pe)
	end
	
	if has_arg('type') or has_arg('oooe') or has_arg('speculative')
		or has_arg('renaming') or has_arg('stages') or has_arg('stages min')
		or has_arg('decode') then
		add_header(infobox, 'Pipeline')
	end
	
	-- type
    if string.len(origArgs['type'] or '') > 0 then
	    local ptype
	    
	    ptype = origArgs['type']
	    for i = 2, 10 do
	    	if string.len(origArgs['type ' .. i] or '') == 0 then break end
	    	ptype = ptype .. ', ' .. origArgs['type ' .. i]
		end
		add_entry(infobox, 'Type', ptype)
	end
	
    -- oooe
    if string.len(origArgs.oooe or '') > 0 then
		add_entry(infobox, 'OoOE', origArgs.oooe)
	end
	
    -- speculative
    if string.len(origArgs.speculative or '') > 0 then
		add_entry(infobox, 'Speculative', origArgs.speculative)
	end
	
    -- renaming
    if string.len(origArgs.renaming or '') > 0 then
		add_entry(infobox, 'Reg Renaming', origArgs.renaming)
	end
	
    -- stages
    if string.len(origArgs.stages or '') > 0 then
		add_entry(infobox, 'Stages', '[[pipeline stages::' .. origArgs.stages .. ']]')
	end
	
    -- stages min/max
    if string.len(origArgs['stages min'] or '') > 0 then
		add_entry(infobox, 'Stages',
			'[[pipeline stages (min)::' .. origArgs['stages min'] .. ']]'
			.. '-[[pipeline stages (max)::' .. origArgs['stages max'] .. ']]')
	end
	
    -- decode
    if string.len(origArgs.decode or '') > 0 then
		add_entry(infobox, 'Decode', origArgs.decode)
	end
	
	
    if has_arg('isa') or has_arg('features') or has_arg('extension') then
		add_header(infobox, 'Instructions')
	end
	
	-- ISA
    if string.len(origArgs.isa or '') > 0 then
	    local isa
	    
	    isa = '[[instruction set architecture::' .. origArgs.isa .. ']]'
	    for i = 2, 10 do
	    	if string.len(origArgs['isa ' .. i] or '') == 0 then break end
	    	isa = isa .. ', ' .. '[[instruction set architecture::' .. origArgs['isa ' .. i] .. ']]'
		end
		add_entry(infobox, 'ISA', isa)
	end
	
	-- features
    if string.len(origArgs.features or '') > 0 then
	    local features
	    
	    features = origArgs.features
	    for i = 2, 10 do
	    	if string.len(origArgs['features ' .. i] or '') == 0 then break end
	    	features = features .. ', ' .. origArgs['features ' .. i]
		end
		add_entry(infobox, 'Features', features)
	end
	
	-- extensions
    if string.len(origArgs.extension or '') > 0 then
	    local extension
	    
	    extension = origArgs.extension
	    for i = 2, 40 do
	    	if string.len(origArgs['extension ' .. i] or '') == 0 then break end
	    	extension = extension .. ', ' .. origArgs['extension ' .. i]
		end
		add_entry(infobox, 'Extensions', extension)
	end
	
	
	
	
	if has_arg('l1') or has_arg('l1i') or has_arg('l1d') or
		has_arg('l2') or has_arg('l3') or has_arg('l3') or
		has_arg('side cache') then
		add_header(infobox, 'Cache')
	end
	
    -- L1i
    if string.len(origArgs.l1i or '') > 0 then
    	local li = origArgs.l1i
    	if string.len(origArgs['l1i per'] or '') > 0 then
    		li = li .. '/' .. origArgs['l1i per']
		end
    	if string.len(origArgs['l1i desc'] or '') > 0 then
    		li = li .. '<br>' .. origArgs['l1i desc']
		end
		add_entry(infobox, 'L1I Cache',  li)
	end
	
    -- L1d
    if string.len(origArgs.l1d or '') > 0 then
    	local li = origArgs.l1d
    	if string.len(origArgs['l1d per'] or '') > 0 then
    		li = li .. '/' .. origArgs['l1d per']
		end
    	if string.len(origArgs['l1d desc'] or '') > 0 then
    		li = li .. '<br>' .. origArgs['l1d desc']
		end
		add_entry(infobox, 'L1D Cache',  li)
	end
	
    -- L1, Unified
    if string.len(origArgs.l1 or '') > 0 then
    	local li = origArgs.l1
    	if string.len(origArgs['l1 per'] or '') > 0 then
    		li = li .. '/' .. origArgs['l1 per']
		end
    	if string.len(origArgs['l1 desc'] or '') > 0 then
    		li = li .. '<br>' .. origArgs['l1 desc']
		end
		add_entry(infobox, 'L1 Cache',  li)
	end
	
    -- L2
    if string.len(origArgs.l2 or '') > 0 then
    	local l2 = origArgs.l2
    	if string.len(origArgs['l2 per'] or '') > 0 then
    		l2 = l2 .. '/' .. origArgs['l2 per']
		end
    	if string.len(origArgs['l2 desc'] or '') > 0 then
    		l2 = l2 .. '<br>' .. origArgs['l2 desc']
		end
		add_entry(infobox, 'L2 Cache',  l2)
	end
	
    -- L3
    if string.len(origArgs.l3 or '') > 0 then
    	local l3 = origArgs.l3
    	if string.len(origArgs['l3 per'] or '') > 0 then
    		l3 = l3 .. '/' .. origArgs['l3 per']
		end
    	if string.len(origArgs['l3 desc'] or '') > 0 then
    		l3 = l3 .. '<br>' .. origArgs['l3 desc']
		end
		add_entry(infobox, 'L3 Cache',  l3)
	end
	
    -- L4
    if string.len(origArgs.l4 or '') > 0 then
    	local l4 = origArgs.l4
    	if string.len(origArgs['l4 per'] or '') > 0 then
    		l4 = l4 .. '/' .. origArgs['l4 per']
		end
    	if string.len(origArgs['l4 desc'] or '') > 0 then
    		l4 = l4 .. '<br>' .. origArgs['l4 desc']
		end
		add_entry(infobox, 'L4 Cache',  l4)
	end
	
    -- Side $
    if has_arg('side cache') then
    	local sidecache = arg('side cache')
    	if has_arg('side cache per') then
    		sidecache = sidecache .. '/' .. arg('side cache per')
		end
    	if has_arg('side cache desc') then
    		sidecache = sidecache .. '<br>' .. arg('side cache desc')
		end
		add_entry(infobox, 'Side Cache',  sidecache)
	end
	
	
	-- cores
    if has_arg('core name') then
		add_header(infobox, 'Cores')
		
	    local cores = arg('core name')
	    for i = 2, 10 do
	    	if not has_arg('core name ' .. i) then break end
	    	cores = cores .. ',<br>' .. arg('core name ' .. i)
		end
		add_entry(infobox, 'Core Names', cores)
	end
	
	if has_arg('successor') or has_arg('predecessor') then
		add_header(infobox, 'Succession')
		
		local s = infobox:tag('tr')
		local td = s:tag('td'):attr('colspan', '2')
		local d1 = td:tag('div'):attr('style', 'display: inline-flex;')
		local d2 = td:tag('div'):attr('style', 'display: inline-flex; float: right;')
		if has_arg('predecessor') then
			
		    local list
		    if has_arg('predecessor link') then
				list = '[[' .. arg('predecessor link') .. '|' .. arg('predecessor') .. ']]'
			else
				list = '[[' .. arg('predecessor') .. ']]'
			end
		    for i = 2, 10 do
		    	if not has_arg('predecessor ' .. i) then break end
		    	if has_arg('predecessor ' .. i .. ' link') then
		    		list = list .. '<br>[[' .. arg('predecessor ' .. i .. ' link') .. '|' .. arg('predecessor ' .. i) .. ']]'
	    		else
		    		list = list .. '<br>[[' .. arg('predecessor ' .. i) .. ']]'
    			end
			end
			
			d1:tag('div')
				:attr('style', 'float: left; padding-right: 10px; margin: auto 5px;')
				:wikitext('<i class="fa fa-chevron-left"></i>')
			d1:tag('div')
				:attr('style', 'float: left;')
				:wikitext(list)
		end
		if has_arg('successor') then
			local list
		    if has_arg('successor link') then
				list = '[[' .. arg('successor link') .. '|' .. arg('successor') .. ']]'
			else
				list = '[[' .. arg('successor') .. ']]'
			end
		    for i = 2, 10 do
		    	if not has_arg('successor ' .. i) then break end
		    	if has_arg('successor ' .. i .. ' link') then
		    		list = list .. '<br>[[' .. arg('successor ' .. i .. ' link') .. '|' ..
		    			arg('successor ' .. i) .. ']]'
	    		else
		    		list = list .. '<br>[[' .. arg('successor ' .. i) .. ']]'
    			end
			end
			
			d2:tag('div')
				:attr('style', 'float: left;')
				:wikitext(list)
			d2:tag('div')
				:attr('style', 'float: right; padding-left: 10px; margin: auto 5px;')
				:wikitext('<i class="fa fa-chevron-right"></i>')
		end
	end
    -- Contemporary
	if has_arg('contemporary') then
		add_header(infobox, 'Contemporary')
		
		local s = infobox:tag('tr')
		local td = s:tag('td'):attr('colspan', '2')
		
		td:attr('style', 'text-align: center;')

	    local list
	    if has_arg('contemporary link') then
			list = '[[' .. arg('contemporary link') .. '|' .. arg('contemporary') .. ']]'
		else
			list = '[[' .. arg('contemporary') .. ']]'
		end
	    for i = 2, 10 do
	    	if not has_arg('contemporary ' .. i) then break end
	    	if has_arg('contemporary ' .. i .. ' link') then
	    		list = list .. '<br>[[' .. arg('contemporary ' .. i .. ' link') .. '|' .. arg('contemporary ' .. i) .. ']]'
    		else
	    		list = list .. '<br>[[' .. arg('contemporary ' .. i) .. ']]'
			end
		end
		
		td:wikitext(list)
	end
            
    infobox:wikitext('[[Category:all microarchitectures]]')
    infobox:wikitext('[[full page name::' .. frame:preprocess('{{FULLPAGENAME}}') .. '| ]]')
    infobox:wikitext('[[instance of::microarchitecture| ]]')
	
	return infobox
end

return uarch