From WikiChip
Difference between revisions of "Module:microarchitecture"

Line 30: Line 30:
  
 
function uarch.uarch(frame)
 
function uarch.uarch(frame)
 +
 +
 +
    local origArgs
 +
    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')
  
Line 36: Line 45:
 
          
 
          
 
     -- header
 
     -- header
     if string.len(frame.args.name or '') == 0 then return 'ERROR: "name" is missing!' end
+
     if string.len(origArgs.name or '') == 0 then return 'ERROR: "name" is missing!' end
add_header_main(infobox, '[[codename::' .. frame.args.name .. '| ]][[name::' .. frame.args.name .. ']] µarch')
+
add_header_main(infobox, '[[codename::' .. origArgs.name .. '| ]][[name::' .. origArgs.name .. ']] µarch')
  
 
add_header(infobox, 'General Info')
 
add_header(infobox, 'General Info')
  
 
     -- arch type
 
     -- arch type
     if string.len(frame.args.atype or '') == 0 then return 'ERROR: "atype" is missing!' end
+
     if string.len(origArgs.atype or '') == 0 then return 'ERROR: "atype" is missing!' end
add_entry(infobox, 'Arch Type', frame.args.atype ..
+
add_entry(infobox, 'Arch Type', origArgs.atype ..
'[[microarchitecture type::' .. frame.args.atype .. '| ]]' ..
+
'[[microarchitecture type::' .. origArgs.atype .. '| ]]' ..
'[[Category:' .. string.lower(frame.args.atype) .. ' microarchitectures by ' .. string.lower(frame.args.designer) .. ']]')
+
'[[Category:' .. string.lower(origArgs.atype) .. ' microarchitectures by ' .. string.lower(origArgs.designer) .. ']]')
  
 
-- designer
 
-- designer
     if string.len(frame.args.designer or '') == 0 then return 'ERROR: "designer" is missing!' end
+
     if string.len(origArgs.designer or '') == 0 then return 'ERROR: "designer" is missing!' end
 
     local devs
 
     local devs
 
      
 
      
     devs = '[[designer::' .. string.lower(frame.args.designer) .. '| ]]' .. frame.args.designer
+
     devs = '[[designer::' .. string.lower(origArgs.designer) .. '| ]]' .. origArgs.designer
     devs = devs .. '[[Category:microarchitectures by ' .. string.lower(frame.args.designer) .. ']]'
+
     devs = devs .. '[[Category:microarchitectures by ' .. string.lower(origArgs.designer) .. ']]'
 
      
 
      
 
     for i = 2, 10 do
 
     for i = 2, 10 do
     if string.len(frame.args['designer_' .. i] or '') == 0 then break end
+
     if string.len(origArgs['designer_' .. i] or '') == 0 then break end
     devs = devs .. ', [[designer::' .. string.lower(frame.args['designer_' .. i]) .. '| ]]' ..
+
     devs = devs .. ', [[designer::' .. string.lower(origArgs['designer_' .. i]) .. '| ]]' ..
     frame.args.designer ..
+
     origArgs.designer ..
    '[[Category:microarchitectures by ' .. string.lower(frame.args['designer_' .. i]) .. ']]'
+
    '[[Category:microarchitectures by ' .. string.lower(origArgs['designer_' .. i]) .. ']]'
 
end
 
end
 
add_entry(infobox, 'Designer', devs)
 
add_entry(infobox, 'Designer', devs)
Line 64: Line 73:
 
 
 
-- manufacturer
 
-- manufacturer
     if string.len(frame.args.manufacturer or '') == 0 then return 'ERROR: "manufacturer" is missing!' end
+
     if string.len(origArgs.manufacturer or '') == 0 then return 'ERROR: "manufacturer" is missing!' end
 
     local devs
 
     local devs
 
      
 
      
     devs = '[[manufacturer::' .. string.lower(frame.args.manufacturer) .. '| ]]'
+
     devs = '[[manufacturer::' .. string.lower(origArgs.manufacturer) .. '| ]]'
     .. frame.args.manufacturer
+
     .. origArgs.manufacturer
 
      
 
      
 
     for i = 2, 10 do
 
     for i = 2, 10 do
     if string.len(frame.args['manufacturer_' .. i] or '') == 0 then break end
+
     if string.len(origArgs['manufacturer_' .. i] or '') == 0 then break end
     devs = devs .. ', [[manufacturer::' .. string.lower(frame.args['manufacturer_' .. i]) .. '| ]]'
+
     devs = devs .. ', [[manufacturer::' .. string.lower(origArgs['manufacturer_' .. i]) .. '| ]]'
     .. frame.args['manufacturer_' .. i]
+
     .. origArgs['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 string.len(origArgs.introduction or '') > 0 then
add_entry(infobox, 'Introduction', '[[first launched::' .. frame.args.introduction .. ']]')
+
add_entry(infobox, 'Introduction', '[[first launched::' .. origArgs.introduction .. ']]')
 
end
 
end
 
 
 
     -- phase-out
 
     -- phase-out
     if string.len(frame.args.phase_out or '') > 0 then
+
     if string.len(origArgs.phase_out or '') > 0 then
add_entry(infobox, 'Phase-out', '[[phase-out::' .. frame.args.phase_out .. ']]')
+
add_entry(infobox, 'Phase-out', '[[phase-out::' .. origArgs.phase_out .. ']]')
 
end
 
end
 
 
Line 90: Line 99:
 
 
 
-- process
 
-- process
     if string.len(frame.args.process or '') > 0 then
+
     if string.len(origArgs.process or '') > 0 then
 
    local proc
 
    local proc
 
     
 
     
    proc = '[[process::' .. frame.args.process .. '| ]]' ..
+
    proc = '[[process::' .. origArgs.process .. '| ]]' ..
    '[[' ..  frame.args.process .. ' process|' ..  frame.args.process .. ']]'
+
    '[[' ..  origArgs.process .. ' process|' ..  origArgs.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] .. '| ]]'
+
    proc = proc .. ', [[process::' ..origArgs['process_' .. i] .. '| ]]'
    .. '[['..  frame.args['process_' .. i] .. ' process|' .. frame.args['process_' .. i] .. ']]'
+
    .. '[['..  origArgs['process_' .. i] .. ' process|' .. origArgs['process_' .. i] .. ']]'
 
end
 
end
 
add_entry(infobox, 'Process', proc)
 
add_entry(infobox, 'Process', proc)
Line 106: Line 115:
 
 
 
-- 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, 10 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 124: Line 133:
 
 
 
-- type
 
-- type
     if string.len(frame.args.ptype or '') > 0 then
+
     if string.len(origArgs.ptype or '') > 0 then
 
    local ptype
 
    local ptype
 
     
 
     
    ptype = frame.args.ptype
+
    ptype = origArgs.ptype
 
    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['ptype_' .. i] or '') == 0 then break end
    ptype = ptype .. ', ' .. frame.args['ptype_' .. i]
+
    ptype = ptype .. ', ' .. origArgs['ptype_' .. i]
 
end
 
end
 
add_entry(infobox, 'Type', ptype)
 
add_entry(infobox, 'Type', ptype)
Line 136: Line 145:
 
 
 
     -- 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
 
     -- reg_renaming
     if string.len(frame.args.reg_renaming or '') > 0 then
+
     if string.len(origArgs.reg_renaming or '') > 0 then
add_entry(infobox, 'Reg Renaming', frame.args.reg_renaming)
+
add_entry(infobox, 'Reg Renaming', origArgs.reg_renaming)
 
end
 
end
 
 
 
     -- pstage
 
     -- pstage
     if string.len(frame.args.pstage or '') > 0 then
+
     if string.len(origArgs.pstage or '') > 0 then
add_entry(infobox, 'Stages', '[[pipeline stages::' .. frame.args.pstage .. ']]')
+
add_entry(infobox, 'Stages', '[[pipeline stages::' .. origArgs.pstage .. ']]')
 
end
 
end
 
 
 
     -- pstage min/max
 
     -- pstage min/max
     if string.len(frame.args.pstages_min or '') > 0 then
+
     if string.len(origArgs.pstages_min or '') > 0 then
 
add_entry(infobox, 'Stages',
 
add_entry(infobox, 'Stages',
'[[pipeline stages (min)::' .. frame.args.pstages_min .. ']]'
+
'[[pipeline stages (min)::' .. origArgs.pstages_min .. ']]'
.. '-[[pipeline stages (max)::' .. frame.args.pstages_max .. ']]')
+
.. '-[[pipeline stages (max)::' .. origArgs.pstages_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
 
 
Line 171: Line 180:
 
 
 
-- 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 192:
 
 
 
-- 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 204:
 
 
 
-- extensions
 
-- extensions
     if string.len(frame.args.extensions or '') > 0 then
+
     if string.len(origArgs.extensions or '') > 0 then
 
    local extensions
 
    local extensions
 
     
 
     
    extensions = frame.args.extensions
+
    extensions = origArgs.extensions
 
    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['extensions_' .. i] or '') == 0 then break end
    extensions = extensions .. ', ' .. frame.args['extensions_' .. i]
+
    extensions = extensions .. ', ' .. origArgs['extensions_' .. i]
 
end
 
end
 
add_entry(infobox, 'Extensions', extensions)
 
add_entry(infobox, 'Extensions', extensions)
Line 209: Line 218:
 
 
 
     -- 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 230:
 
 
 
     -- 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)
Line 233: Line 242:
 
 
 
     -- 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 254:
 
 
 
     -- 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 266:
 
 
 
     -- 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)
Line 269: Line 278:
 
 
 
     -- Size $
 
     -- Size $
     if string.len(frame.args.sizecache or '') > 0 then
+
     if string.len(origArgs.sizecache or '') > 0 then
     local sizecache = frame.args.sizecache
+
     local sizecache = origArgs.sizecache
     if string.len(frame.args.sizecache_per or '') > 0 then
+
     if string.len(origArgs.sizecache_per or '') > 0 then
     sizecache = sizecache .. '/' .. frame.args.sizecache_per
+
     sizecache = sizecache .. '/' .. origArgs.sizecache_per
 
end
 
end
     if string.len(frame.args.sizecache_desc or '') > 0 then
+
     if string.len(origArgs.sizecache_desc or '') > 0 then
     sizecache = sizecache .. '<br>' .. frame.args.sizecache_desc
+
     sizecache = sizecache .. '<br>' .. origArgs.sizecache_desc
 
end
 
end
 
add_entry(infobox, 'Size Cache',  sizecache)
 
add_entry(infobox, 'Size Cache',  sizecache)
Line 285: Line 294:
 
 
 
-- cores
 
-- cores
     if string.len(frame.args.core_name or '') > 0 then
+
     if string.len(origArgs.core_name or '') > 0 then
 
    local cores
 
    local cores
 
     
 
     
    cores = frame.args.core_name
+
    cores = origArgs.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 string.len(origArgs['core_name_' .. i] or '') == 0 then break end
    cores = cores .. ', ' .. frame.args['core_name_' .. i]
+
    cores = cores .. ', ' .. origArgs['core_name_' .. i]
 
end
 
end
 
add_entry(infobox, 'Core Names', features)
 
add_entry(infobox, 'Core Names', features)
 
end
 
end
 
 
if string.len(frame.args.successor or '') > 0
+
if string.len(origArgs.successor or '') > 0
or string.len(frame.args.predecessor or '') > 0 then
+
or string.len(origArgs.predecessor or '') > 0 then
 
add_header(infobox, 'Succession')
 
add_header(infobox, 'Succession')
 
 
Line 303: Line 312:
 
local d1 = s:tag('td'):tag('div'):attr('style', 'display: inline-flex;')
 
local d1 = s:tag('td'):tag('div'):attr('style', 'display: inline-flex;')
 
local d2 = s:tag('td'):tag('div'):attr('style', 'display: inline-flex; float: right;')
 
local d2 = s:tag('td'):tag('div'):attr('style', 'display: inline-flex; float: right;')
if string.len(frame.args.predecessor or '') > 0 then
+
if string.len(origArgs.predecessor or '') > 0 then
 
 
 
    local list
 
    local list
    if string.len(frame.args.predecessor_link or '') > 0 then
+
    if string.len(origArgs.predecessor_link or '') > 0 then
list = '[[' .. frame.args.predecessor_link .. '|' .. frame.args.predecessor .. ']]'
+
list = '[[' .. origArgs.predecessor_link .. '|' .. origArgs.predecessor .. ']]'
 
else
 
else
list = '[[' .. frame.args.predecessor .. ']]'
+
list = '[[' .. origArgs.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 string.len(origArgs['predecessor_' .. i] or '') == 0 then break end
    if string.len(frame.args['predecessor_link_' .. i] or '') then
+
    if string.len(origArgs['predecessor_link_' .. i] or '') then
    list = list .. '[[' .. frame.args['predecessor_link_' .. i] .. '|' ..
+
    list = list .. '[[' .. origArgs['predecessor_link_' .. i] .. '|' ..
    frame.args['predecessor_' .. i] .. ']]'
+
    origArgs['predecessor_' .. i] .. ']]'
 
    else
 
    else
    list = list .. '[[' .. frame.args['predecessor_' .. i] .. ']]'
+
    list = list .. '[[' .. origArgs['predecessor_' .. i] .. ']]'
 
     end
 
     end
 
end
 
end
Line 328: Line 337:
 
:wikitext(list)
 
:wikitext(list)
 
end
 
end
if string.len(frame.args.successor or '') > 0 then
+
if string.len(origArgs.successor or '') > 0 then
 
local list
 
local list
    if string.len(frame.args.successor_link or '') > 0 then
+
    if string.len(origArgs.successor_link or '') > 0 then
list = '[[' .. frame.args.successor_link .. '|' .. frame.args.successor .. ']]'
+
list = '[[' .. origArgs.successor_link .. '|' .. origArgs.successor .. ']]'
 
else
 
else
list = '[[' .. frame.args.successor .. ']]'
+
list = '[[' .. origArgs.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 string.len(origArgs['successor_' .. i] or '') == 0 then break end
    if string.len(frame.args['successor_link_' .. i] or '') then
+
    if string.len(origArgs['successor_link_' .. i] or '') then
    list = list .. '[[' .. frame.args['successor_link_' .. i] .. '|' ..
+
    list = list .. '[[' .. origArgs['successor_link_' .. i] .. '|' ..
    frame.args['successor_' .. i] .. ']]'
+
    origArgs['successor_' .. i] .. ']]'
 
    else
 
    else
    list = list .. '[[' .. frame.args['successor_' .. i] .. ']]'
+
    list = list .. '[[' .. origArgs['successor_' .. i] .. ']]'
 
     end
 
     end
 
end
 
end

Revision as of 04:57, 25 May 2017

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

local uarch = {}

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 uarch.uarch(frame)


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

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

    infobox
        :attr('class', 'infobox')
        
    -- header
    if string.len(origArgs.name or '') == 0 then return 'ERROR: "name" is missing!' end
	add_header_main(infobox, '[[codename::' .. origArgs.name .. '| ]][[name::' .. origArgs.name .. ']] µarch')

	add_header(infobox, 'General Info')

    -- arch type
    if string.len(origArgs.atype or '') == 0 then return 'ERROR: "atype" is missing!' end
	add_entry(infobox, 'Arch Type', origArgs.atype ..
		'[[microarchitecture type::' .. origArgs.atype .. '| ]]' ..
		'[[Category:' .. string.lower(origArgs.atype) .. ' microarchitectures by ' .. string.lower(origArgs.designer) .. ']]')

	-- designer
    if string.len(origArgs.designer or '') == 0 then return 'ERROR: "designer" is missing!' end
    local devs
    
    devs = '[[designer::' .. string.lower(origArgs.designer) .. '| ]]' .. origArgs.designer
    devs = devs .. '[[Category:microarchitectures by ' .. string.lower(origArgs.designer) .. ']]'
    
    for i = 2, 10 do
    	if string.len(origArgs['designer_' .. i] or '') == 0 then break end
    	devs = devs .. ', [[designer::' .. string.lower(origArgs['designer_' .. i]) .. '| ]]' ..
    			origArgs.designer ..
	    		'[[Category:microarchitectures by ' .. string.lower(origArgs['designer_' .. i]) .. ']]'
	end
	add_entry(infobox, 'Designer', devs)
	
	
	-- manufacturer
    if string.len(origArgs.manufacturer or '') == 0 then return 'ERROR: "manufacturer" is missing!' end
    local devs
    
    devs = '[[manufacturer::' .. string.lower(origArgs.manufacturer) .. '| ]]'
    		.. origArgs.manufacturer
    
    for i = 2, 10 do
    	if string.len(origArgs['manufacturer_' .. i] or '') == 0 then break end
    	devs = devs .. ', [[manufacturer::' .. string.lower(origArgs['manufacturer_' .. i]) .. '| ]]'
    			.. origArgs['manufacturer_' .. i]
	end
	add_entry(infobox, 'Manufacturer', devs)
	
    -- intro
    if string.len(origArgs.introduction or '') > 0 then
		add_entry(infobox, 'Introduction', '[[first launched::' .. origArgs.introduction .. ']]')
	end
	
    -- phase-out
    if string.len(origArgs.phase_out or '') > 0 then
		add_entry(infobox, 'Phase-out', '[[phase-out::' .. origArgs.phase_out .. ']]')
	end
	
	
	
	-- process
    if string.len(origArgs.process or '') > 0 then
	    local proc
	    
	    proc = '[[process::' .. origArgs.process .. '| ]]' ..
	    		'[[' ..  origArgs.process .. ' process|' ..  origArgs.process .. ']]'
	    
	    for i = 2, 10 do
	    	if string.len(origArgs['process_' .. i] or '') == 0 then break end
	    	proc = proc .. ', [[process::' ..origArgs['process_' .. i] .. '| ]]'
	    			.. '[['..  origArgs['process_' .. i] .. ' process|' .. origArgs['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, 10 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
	
	
	add_header(infobox, 'Pipeline')
	
	-- type
    if string.len(origArgs.ptype or '') > 0 then
	    local ptype
	    
	    ptype = origArgs.ptype
	    for i = 2, 10 do
	    	if string.len(origArgs['ptype_' .. i] or '') == 0 then break end
	    	ptype = ptype .. ', ' .. origArgs['ptype_' .. 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
	
    -- reg_renaming
    if string.len(origArgs.reg_renaming or '') > 0 then
		add_entry(infobox, 'Reg Renaming', origArgs.reg_renaming)
	end
	
    -- pstage
    if string.len(origArgs.pstage or '') > 0 then
		add_entry(infobox, 'Stages', '[[pipeline stages::' .. origArgs.pstage .. ']]')
	end
	
    -- pstage min/max
    if string.len(origArgs.pstages_min or '') > 0 then
		add_entry(infobox, 'Stages',
			'[[pipeline stages (min)::' .. origArgs.pstages_min .. ']]'
			.. '-[[pipeline stages (max)::' .. origArgs.pstages_max .. ']]')
	end
	
    -- decode
    if string.len(origArgs.decode or '') > 0 then
		add_entry(infobox, 'Decode', origArgs.decode)
	end
	
	
	add_header(infobox, 'Instructions')
	
	-- 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.extensions or '') > 0 then
	    local extensions
	    
	    extensions = origArgs.extensions
	    for i = 2, 40 do
	    	if string.len(origArgs['extensions_' .. i] or '') == 0 then break end
	    	extensions = extensions .. ', ' .. origArgs['extensions_' .. i]
		end
		add_entry(infobox, 'Extensions', extensions)
	end
	
	add_header(infobox, 'Cache')
	
    -- 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
	
    -- 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
	
    -- Size $
    if string.len(origArgs.sizecache or '') > 0 then
    	local sizecache = origArgs.sizecache
    	if string.len(origArgs.sizecache_per or '') > 0 then
    		sizecache = sizecache .. '/' .. origArgs.sizecache_per
		end
    	if string.len(origArgs.sizecache_desc or '') > 0 then
    		sizecache = sizecache .. '<br>' .. origArgs.sizecache_desc
		end
		add_entry(infobox, 'Size Cache',  sizecache)
	end
	
	
	add_header(infobox, 'Cores')
	
	
	-- cores
    if string.len(origArgs.core_name or '') > 0 then
	    local cores
	    
	    cores = origArgs.core_name
	    for i = 2, 10 do
	    	if string.len(origArgs['core_name_' .. i] or '') == 0 then break end
	    	cores = cores .. ', ' .. origArgs['core_name_' .. i]
		end
		add_entry(infobox, 'Core Names', features)
	end
	
	if string.len(origArgs.successor or '') > 0
	or string.len(origArgs.predecessor or '') > 0 then
		add_header(infobox, 'Succession')
		
		local s = infobox:tag('tr')
		local d1 = s:tag('td'):tag('div'):attr('style', 'display: inline-flex;')
		local d2 = s:tag('td'):tag('div'):attr('style', 'display: inline-flex; float: right;')
		if string.len(origArgs.predecessor or '') > 0 then
			
		    local list
		    if string.len(origArgs.predecessor_link or '') > 0 then
				list = '[[' .. origArgs.predecessor_link .. '|' .. origArgs.predecessor .. ']]'
			else
				list = '[[' .. origArgs.predecessor .. ']]'
			end
		    for i = 2, 10 do
		    	if string.len(origArgs['predecessor_' .. i] or '') == 0 then break end
		    	if string.len(origArgs['predecessor_link_' .. i] or '') then
		    		list = list .. '[[' .. origArgs['predecessor_link_' .. i] .. '|' ..
		    			origArgs['predecessor_' .. i] .. ']]'
	    		else
		    		list = list .. '[[' .. origArgs['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 string.len(origArgs.successor or '') > 0 then
			local list
		    if string.len(origArgs.successor_link or '') > 0 then
				list = '[[' .. origArgs.successor_link .. '|' .. origArgs.successor .. ']]'
			else
				list = '[[' .. origArgs.successor .. ']]'
			end
		    for i = 2, 10 do
		    	if string.len(origArgs['successor_' .. i] or '') == 0 then break end
		    	if string.len(origArgs['successor_link_' .. i] or '') then
		    		list = list .. '[[' .. origArgs['successor_link_' .. i] .. '|' ..
		    			origArgs['successor_' .. i] .. ']]'
	    		else
		    		list = list .. '[[' .. origArgs['successor_' .. i] .. ']]'
    			end
			end
			
			d2:tag('div')
				:attr('style', 'float: left;')
				:wikitext('[[test]]')
			d2:tag('div')
				:attr('style', 'float: right; padding-left: 10px; margin: auto 5px;')
				:wikitext('<i class="fa fa-chevron-right"></i>')
		end
	end
            
    infobox:wikitext('[[Category:all microarchitectures]]')
    infobox:wikitext('[[full page name::{{FULLPAGENAME}}| ]]')
    infobox:wikitext('[[instance of::microarchitecture| ]]')
	
	return infobox
end

return uarch