From WikiChip
Difference between revisions of "Module:microarchitecture"
Line 89: | Line 89: | ||
− | -- | + | -- process |
if string.len(frame.args.process or '') > 0 then | if string.len(frame.args.process or '') > 0 then | ||
local proc | local proc | ||
Line 102: | Line 102: | ||
end | end | ||
add_entry(infobox, 'Process', proc) | add_entry(infobox, 'Process', proc) | ||
+ | end | ||
+ | |||
+ | |||
+ | -- cores | ||
+ | if string.len(frame.args.cores or '') > 0 then | ||
+ | local proc | ||
+ | |||
+ | proc = '[[core count::' .. frame.args.cores .. '| ]]' | ||
+ | .. '[[' .. frame.args.cores .. ' cores|' .. frame.args.cores .. ']]' | ||
+ | |||
+ | for i = 2, 10 do | ||
+ | if string.len(frame.args['cores_' .. i] or '') == 0 then break end | ||
+ | proc = proc .. ', [[core count::' ..frame.args['cores_' .. i] .. '| ]]' | ||
+ | .. '[[' .. frame.args['cores_' .. i] .. ' cores|' .. frame.args['cores_' .. i] .. ']]' | ||
+ | end | ||
+ | add_entry(infobox, 'Cores Configs', proc) | ||
end | end | ||
Revision as of 00:20, 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 infobox = mw.html.create('table')
infobox
:attr('class', 'infobox')
-- header
if string.len(frame.args.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(infobox, 'General Info')
-- arch type
if string.len(frame.args.atype or '') == 0 then return 'ERROR: "atype" is missing!' end
add_entry(infobox, 'Arch Type', frame.args.atype ..
'[[microarchitecture type::' .. frame.args.atype .. '| ]]' ..
'[[Category:' .. string.lower(frame.args.atype) .. ' microarchitectures by ' .. string.lower(frame.args.designer) .. ']]')
-- designer
if string.len(frame.args.designer or '') == 0 then return 'ERROR: "designer" is missing!' end
local devs
devs = '[[designer::' .. string.lower(frame.args.designer) .. '| ]]' .. frame.args.designer
devs = devs .. '[[Category:microarchitectures by ' .. string.lower(frame.args.designer) .. ']]'
for i = 2, 10 do
if string.len(frame.args['designer_' .. i] or '') == 0 then break end
devs = devs .. ', [[designer::' .. string.lower(frame.args['designer_' .. i]) .. '| ]]' ..
frame.args.designer ..
'[[Category:microarchitectures by ' .. string.lower(frame.args['designer_' .. i]) .. ']]'
end
add_entry(infobox, 'Designer', devs)
-- manufacturer
if string.len(frame.args.manufacturer or '') == 0 then return 'ERROR: "manufacturer" is missing!' end
local devs
devs = '[[manufacturer::' .. string.lower(frame.args.manufacturer) .. '| ]]'
.. frame.args.manufacturer
for i = 2, 10 do
if string.len(frame.args['manufacturer_' .. i] or '') == 0 then break end
devs = devs .. ', [[manufacturer::' .. string.lower(frame.args['manufacturer_' .. i]) .. '| ]]'
.. frame.args['manufacturer_' .. i]
end
add_entry(infobox, 'Manufacturer', devs)
-- intro
if string.len(frame.args.introduction or '') > 0 then
add_entry(infobox, 'Introduction', '[[first launched::' .. frame.args.introduction .. ']]')
end
-- phase-out
if string.len(frame.args.phase_out or '') > 0 then
add_entry(infobox, 'Phase-out', '[[phase-out::' .. frame.args.phase_out .. ']]')
end
-- process
if string.len(frame.args.process or '') > 0 then
local proc
proc = '[[process::' .. frame.args.process .. '| ]]' ..
'[[' .. frame.args.process .. ' process|' .. frame.args.process .. ']]'
for i = 2, 10 do
if string.len(frame.args['process_' .. i] or '') == 0 then break end
proc = proc .. ', [[process::' ..frame.args['process_' .. i] .. '| ]]'
.. '[['.. frame.args['process_' .. i] .. ' process|' .. frame.args['process_' .. i] .. ']]'
end
add_entry(infobox, 'Process', proc)
end
-- cores
if string.len(frame.args.cores or '') > 0 then
local proc
proc = '[[core count::' .. frame.args.cores .. '| ]]'
.. '[[' .. frame.args.cores .. ' cores|' .. frame.args.cores .. ']]'
for i = 2, 10 do
if string.len(frame.args['cores_' .. i] or '') == 0 then break end
proc = proc .. ', [[core count::' ..frame.args['cores_' .. i] .. '| ]]'
.. '[[' .. frame.args['cores_' .. i] .. ' cores|' .. frame.args['cores_' .. i] .. ']]'
end
add_entry(infobox, 'Cores Configs', proc)
end
return infobox
end
return uarch