From WikiChip
Module:chip
To add this template, simple add
{{chip}}to the page and save. The chip infobox will have a small
[Edit Values]
button at the top-right corner which can be used to add values using a form.
local p = {}
local origArgs
function p.add_file_prefix(str)
if string.match(string.lower(str), '^file:') then
return str
else
return 'File:' .. str
end
end
function p.add_separator(box, title)
box:tag('tr')
:tag('td')
:attr('class', 'header')
:attr('colspan', '2')
:wikitext(title)
end
function p.add_entry(value, right)
local e = mw.html.create('tr')
e:tag('td')
:attr('class', 'label')
:wikitext(value)
e:node(right)
return e
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 p.chip(frame)
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
else
origArgs = frame.args
end
local infobox = mw.html.create('table')
infobox
:attr('class', 'infobox')
-- header
if has_arg('name') then
infobox
:tag('tr')
:tag('td')
:attr('class', 'header-main')
:attr('colspan', '2')
:wikitext('[[name::' .. arg('name') .. ']]')
end
-- image
if has_arg('no image') then
infobox
:tag('tr')
:tag('td')
:attr('style', 'text-align: center;')
:attr('colspan', '2')
:wikitext('[[File:no photo (ic).svg|link=|200px]]')
elseif has_arg('image') then
local image = p.add_file_prefix(arg('image'))
local image_size = has_arg('image size') and arg('image size') or "200px"
infobox
:tag('tr')
:tag('td')
:attr('style', 'text-align: center;')
:attr('colspan', '2')
:wikitext('[[image::' .. image .. '| ]][[' .. image .. '|' .. image_size .. ']]')
-- add a caption, if provided
if has_arg('caption') then
infobox
:tag('tr')
:tag('td')
:attr('class', 'chip-infobox-pic-caption')
:attr('colspan', '2')
:wikitext('[[image capation::' .. arg('caption') .. ']]')
end
end
-- ####################################################################
-- some general info first
p.add_separator(infobox, 'General Info')
-- designer
if has_arg('designer') then
local designers = mw.html.create('td')
designers:wikitext('[[designer::' .. arg('designer') .. ']]' ..
'[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer')) .. ']]')
if has_arg('microarch') then
designers:wikitext('[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer')) ..
' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
end
for i = 2, 10 do
if not has_arg('designer ' .. i) then break end
designers:wikitext(', [[designer::' .. arg('designer ' .. i) .. ']]' ..
'[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer ' .. i)) .. ']]')
if has_arg('microarch') then
designers:wikitext('[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer ' .. i)) ..
' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
end
end
infobox:node(p.add_entry('Designer', designers))
end
-- manufacturer
if has_arg('manufacturer') then
local manufacturers = '[[manufacturer::' .. arg('manufacturer') .. ']]' ..
'[[category:microprocessor models by ' .. mw.ustring.lower(arg('manufacturer')) .. ']]'
for i = 2, 10 do
if not has_arg('manufacturer ' .. i) then break end
manufacturers = manufacturers .. ', [[manufacturer::' .. arg('manufacturer ' .. i) .. ']]' ..
'[[category:microprocessor models by ' .. mw.ustring.lower(arg('manufacturer ' .. i)) .. ']]'
end
infobox:node(p.add_entry('Manufacturer', mw.html.create('td'):wikitext(manufacturers)))
end
-- model number
if has_arg('model number') then
infobox:node(p.add_entry('Model Number', mw.html.create('td'):wikitext('[[model number::' .. arg('model number') .. ']]')))
end
-- part number
if has_arg('part number') then
local parts = '[[part number::' .. arg('part number') .. ']]'
for i = 1, 10 do
if not has_arg('part number ' .. i) then break end
parts = parts .. ', [[part number::' .. arg('part number ' .. i) .. ']]'
end
infobox:node(p.add_entry('Part Number', mw.html.create('td'):wikitext(parts)))
end
-- s-spec
if has_arg('s-spec') or has_arg('s-spec qs') then
local sspec
if has_arg('s-spec') then
sspec = '[[s-spec::' .. arg('s-spec') .. ']]'
for i = 2, 30 do
if not has_arg('s-spec ' .. i) then break end
sspec = sspec .. ', [[s-spec::' .. arg('s-spec ' .. i) .. ']]'
end
end
if has_arg('s-spec qs') then
if has_arg('s-spec') then sspec = sspec .. '<br>' end
sspec = sspec .. '[[s-spec (qs)::' .. arg('s-spec qs') .. ']] ([[qualification sample|QS]])'
for i = 2, 30 do
if not has_arg('s-spec qs ' .. i) then break end
sspec = sspec .. ', [[s-spec (qs)::' .. arg('s-spec qs ' .. i) .. ']]'
end
end
infobox:node(p.add_entry('S-Spec', mw.html.create('td'):wikitext(sspec)))
end
-- market segment
if has_arg('market') then
local markets = mw.html.create('td'):wikitext('[[market segment::' .. arg('market') .. ']]')
for i = 2, 5 do
if not has_arg('market ' .. i) then break end
markets:wikitext(', [[market segment::' .. arg('market ' .. i) .. ']]')
end
infobox:node(p.add_entry('Market', markets))
end
-- release date
if has_arg('first launched') or has_arg('first announced') then
local release = mw.html.create('td')
if has_arg('first announced') then
release:wikitext('[[first announced::' .. arg('first announced') .. ']] (announced)')
end
if has_arg('first launched') then
if has_arg('first announced') then
release:wikitext('<br>')
end
release:wikitext('[[first launched::' .. arg('first launched') .. ']] (launched)')
end
infobox:node(p.add_entry('Release', release))
end
-- EOL
if has_arg('last order') or has_arg('last shipment') then
local release = mw.html.create('td')
if has_arg('last order') then
release:wikitext('[[last order::' .. arg('last order') .. ']] (last order)')
end
if has_arg('last shipment') then
if has_arg('last order') then
release:wikitext('<br>')
end
release:wikitext('[[last shipment::' .. arg('last shipment') .. ']] (last shipment)')
end
infobox:node(p.add_entry('End-of-life', release))
end
-- release price
if has_arg('release price') then
infobox:node(p.add_entry('Release Price', mw.html.create('td'):wikitext('[[release price::' ..
arg('release price') .. '| ]]' .. arg('release price'))))
end
-- ####################################################################
-- some general specs
p.add_separator(infobox, 'General Specs')
-- family
if has_arg('family') then
infobox:node(p.add_entry('Family', mw.html.create('td'):wikitext('[[microprocessor family::' .. arg('family') .. ']]')))
end
-- series
if has_arg('series') then
infobox:node(p.add_entry('Series', mw.html.create('td'):wikitext('[[microprocessor series::' .. arg('series') .. ']]')))
end
-- locked?
if has_arg('locked') then
infobox:node(p.add_entry('Locked', mw.html.create('td'):wikitext('[[has locked clock multiplier::' .. arg('locked') .. ']]')))
end
-- frequency
if has_arg('frequency') then
local frequencies = mw.html.create('td'):wikitext('[[base frequency::' .. arg('frequency') .. '| ]]' .. arg('frequency'))
for i = 2, 10 do
if not has_arg('frequency ' .. i) then break end
frequencies:wikitext(', [[base frequency::' .. arg('frequency ' .. i) .. '| ]]' .. arg('frequency ' .. i))
end
infobox:node(p.add_entry('Frequency', frequencies))
end
-- turbo frequency
if has_arg('turbo frequency') then
local turbo = mw.html.create('td')
for i = 1, 30 do
--sometimes turbo is not specified for odd-cores, so skip 2 each time, so we can't break
--if not has_arg('turbo frequency' .. i) then break end
if has_arg('turbo frequency' .. i) then
local s = i > 1 and 's' or ''
local br = i > 1 and ',<br>' or ''
turbo:wikitext(br .. ' [[turbo frequency (' .. i .. ' core' .. s .. ')::' .. arg('turbo frequency' .. i) .. '| ]]' ..
arg('turbo frequency' .. i) .. ' (' .. i .. ' core' .. s .. ')')
end
end
infobox:node(p.add_entry('Turbo Frequency', turbo))
end
-- bus type
if has_arg('bus type') then
infobox:node(p.add_entry('Bus type', mw.html.create('td'):wikitext('[[bus type::' .. arg('bus type') .. ']]')))
end
-- bus speed
if has_arg('bus speed') then
infobox:node(p.add_entry('Bus speed', mw.html.create('td'):wikitext('[[bus speed::' .. arg('bus speed') .. '| ]]'
.. arg('bus speed'))))
end
-- bus rate
if has_arg('bus rate') then
local links = ''
if has_arg('bus links') then
links = '[[bus links::' .. arg('bus links') .. ']] × '
end
infobox:node(p.add_entry('Bus rate', mw.html.create('td'):wikitext(links .. '[[bus rate::' .. arg('bus rate') .. '| ]]'
.. arg('bus rate'))))
end
-- clock mult
if has_arg('clock multiplier') then
infobox:node(p.add_entry('Clock multiplier', mw.html.create('td'):wikitext('[[clock multiplier::' .. arg('clock multiplier') .. ']]')))
end
-- CPUID
if has_arg('cpuid') then
local cpuid = mw.html.create('td'):wikitext('[[cpuid::' .. arg('cpuid') .. ']]')
for i = 2, 10 do
if not has_arg('cpuid ' .. i) then break end
cpuid:wikitext(', [[cpuid::' .. arg('cpuid ' .. i) .. ']]')
end
infobox:node(p.add_entry('CPUID', cpuid))
end
-- ####################################################################
-- some general info first
p.add_separator(infobox, 'Microarchitecture')
-- ISA
if has_arg('isa') or has_arg('isa family') then
local isa = mw.html.create('td'):wikitext('[[isa::' .. arg('isa') .. ']]')
for i = 2, 10 do
if not has_arg('isa ' .. i) then break end
isa:wikitext(', [[isa::' .. arg('isa ' .. i) .. ']]')
end
if has_arg('isa family') then
isa:wikitext(' ([[isa family::' .. arg('isa family') .. ']])')
end
infobox:node(p.add_entry('ISA', isa))
end
-- microarch
if has_arg('microarch') then
local microarchs = mw.html.create('td')
microarchs:wikitext('[[microarchitecture::' .. arg('microarch') .. '| ]]')
microarchs:wikitext('[[' .. mw.ustring.lower(arg('designer')) .. '/microarchitectures/' ..
mw.ustring.lower(arg('microarch')) .. '|' .. arg('microarch') .. ']]')
for i = 2, 10 do
if not has_arg('microarch ' .. i) then break end
microarchs:wikitext(', [[microarchitecture::' .. arg('microarch ' .. i) .. ']]')
end
infobox:node(p.add_entry('µarch', microarchs))
end
-- platform
if has_arg('platform') then
infobox:node(p.add_entry('Platform', mw.html.create('td'):wikitext('[[platform::' .. arg('platform') .. ']]')))
end
-- chipset
if has_arg('chipset') then
local chipset = mw.html.create('td'):wikitext('[[chipset::' .. arg('chipset') .. ']]')
for i = 2, 10 do
if not has_arg('chipset ' .. i) then break end
chipset:wikitext(', [[chipset::' .. arg('chipset ' .. i) .. ']]')
end
infobox:node(p.add_entry('Chipset', chipset))
end
-- core name
if has_arg('core name') then
local core_name = mw.html.create('td'):wikitext('[[core name::' .. arg('core name') .. '| ]]' ..
'[[' .. mw.ustring.lower(arg('designer')) .. '/cores/' .. mw.ustring.lower(arg('core name')) .. '|' ..
arg('core name') .. ']]')
for i = 2, 10 do
if not has_arg('core name ' .. i) then break end
core_name:wikitext(', [[core name::' .. arg('core name ' .. i) .. ']]' ..
'[[' .. mw.ustring.lower(arg('designer')) .. '/cores/' .. mw.ustring.lower(arg('core name ' .. i)) .. '|' ..
arg('core name ' .. i) .. ']]')
end
infobox:node(p.add_entry('Core Name', core_name))
end
-- core family
if has_arg('core family') then
local corefam = mw.html.create('td'):wikitext('[[core family::' .. arg('core family') .. ']]')
for i = 2, 10 do
if not has_arg('core family ' .. i) then break end
corefam:wikitext(', [[core family::' .. arg('core family ' .. i) .. ']]')
end
infobox:node(p.add_entry('Core Family', corefam))
end
-- core model
if has_arg('core model') then
local coremodel = mw.html.create('td'):wikitext('[[core model::' .. arg('core model') .. ']]')
for i = 2, 10 do
if not has_arg('core model ' .. i) then break end
coremodel:wikitext(', [[core model::' .. arg('core model ' .. i) .. ']]')
end
infobox:node(p.add_entry('Core Model', coremodel))
end
-- core stepping
if has_arg('core stepping') then
local corestep = mw.html.create('td'):wikitext('[[core stepping::' .. arg('core stepping') .. ']]')
for i = 2, 10 do
if not has_arg('core stepping ' .. i) then break end
corestep:wikitext(', [[core stepping::' .. arg('core stepping ' .. i) .. ']]')
end
infobox:node(p.add_entry('Core Stepping', corestep))
end
-- process
if has_arg('process') then
local process = mw.html.create('td'):wikitext('[[process::' .. arg('process') .. ']]')
for i = 2, 10 do
if not has_arg('process ' .. i) then break end
process:wikitext(', [[process::' .. arg('process ' .. i) .. ']]')
end
infobox:node(p.add_entry('Process', process))
end
-- Transistors
if has_arg('transistors') then
infobox:node(p.add_entry('Transistors', mw.html.create('td'):wikitext('[[transistors::' .. arg('transistors') .. ']]')))
end
-- Technology
if has_arg('technology') then
infobox:node(p.add_entry('Technology', mw.html.create('td'):wikitext('[[technology::' .. arg('technology') .. ']]')))
end
-- die size
if has_arg('die area') or has_arg('die size') then
local die
if has_arg('die size') then
die = mw.html.create('td'):wikitext('[[die area::' .. arg('die size') .. ']]')
else
die = mw.html.create('td'):wikitext('[[die area::' .. arg('die area') .. ']]')
end
if has_arg('die length') and has_arg('die width') then
die:wikitext('<br>' .. '[[die length::' .. arg('die length') .. '| ]]' ..
arg('die length') .. ' × [[die width::' .. arg('die width') .. '| ]]' ..
arg('die width'))
end
end
-- word size
if has_arg('word size') then
infobox:node(p.add_entry('Word Size', mw.html.create('td'):wikitext('[[word size::' .. arg('word size') .. '| ]]' .. arg('word size'))))
end
-- core count
if has_arg('core count') then
infobox:node(p.add_entry('Cores', mw.html.create('td'):wikitext('[[core count::' .. arg('core count') .. ']]')))
end
-- thread count
if has_arg('thread count') then
infobox:node(p.add_entry('Threads', mw.html.create('td'):wikitext('[[thread count::' .. arg('thread count') .. ']]')))
end
-- max cpus
if has_arg('max cpus') then
infobox:node(p.add_entry('Max CPUs', mw.html.create('td'):wikitext('[[max cpu count::' .. arg('max cpus') .. ']]')))
end
-- max memory
if has_arg('max memory') then
infobox:node(p.add_entry('Max Memory', mw.html.create('td'):wikitext('[[max memory::' .. arg('max memory') .. '| ]]' .. arg('max memory'))))
end
-- max memory addr
if has_arg('max memory addr') then
infobox:node(p.add_entry('Max Address Mem', mw.html.create('td'):wikitext('[[max memory address::' .. arg('max memory addr') .. ']]')))
end
-- ####################################################################
-- Electrical
p.add_separator(infobox, 'Electrical')
-- power
if has_arg('power') then
infobox:node(p.add_entry('Power dissipation', mw.html.create('td'):wikitext('[[power dissipation::' .. arg('power') .. '| ]]' .. arg('power'))))
end
-- average power
if has_arg('average power') then
infobox:node(p.add_entry('power dissipation (average)', mw.html.create('td'):wikitext('[[power dissipation (average)::' .. arg('average power') .. ']]')))
end
-- power
if has_arg('idle power') then
infobox:node(p.add_entry('Power dissipation (idle)', mw.html.create('td'):wikitext('[[power dissipation (idle)::' .. arg('idle power') .. ']]')))
end
-- vcore
if has_arg('v core') then
local vcore = mw.html.create('td'):wikitext('[[core voltage::' .. arg('v core') .. ']]')
if has_arg('v core tolerance') then
vcore:wikitext(' ± [[core voltage tolerance::' .. arg('v core tolerance') .. ']]')
end
infobox:node(p.add_entry('V<sub>core</sub>', vcore))
end
if has_arg('v core min') then
infobox:node(p.add_entry('V<sub>core</sub>', mw.html.create('td'):wikitext('[[core voltage (min)::' .. arg('v core min') .. ']]-' ..
'[[core voltage (max)::' .. arg('v core max') .. ']]')))
end
-- io
if has_arg('v io') then
local vcore = mw.html.create('td'):wikitext('[[io voltage::' .. arg('v io') .. ']]')
if has_arg('v io tolerance') then
vcore:wikitext(' ± [[io voltage tolerance::' .. arg('v io tolerance') .. ']]')
end
for i = 2, 10 do
if not has_arg('v io ' .. i) then break end
corestep:wikitext(', [[io voltage::' .. arg('v io ' .. i) .. ']]')
end
infobox:node(p.add_entry('V<sub>I/O</sub>', vcore))
end
-- sdp
if has_arg('sdp') then
infobox:node(p.add_entry('<abbr title="Scenario Design Power">SDP</abbr>', mw.html.create('td'):wikitext('[[sdp::' .. arg('sdp') .. ']]')))
end
-- tdp
if has_arg('tdp') then
infobox:node(p.add_entry('<abbr title="Thermal Design Power">TDP</abbr>', mw.html.create('td'):wikitext('[[tdp::' .. arg('tdp') .. ']]')))
end
-- tdp typical
if has_arg('tdp typical') then
infobox:node(p.add_entry('<abbr title="Thermal Design Power">TDP</abbr> (Typical)', mw.html.create('td'):wikitext('[[tdp (typical)::' .. arg('tdp typical') .. ']]')))
end
-- ctdp down
if has_arg('ctdp down') then
infobox:node(p.add_entry('cTDP down', mw.html.create('td'):wikitext('[[tdp down::' .. arg('ctdp down') .. ']]')))
end
-- ctdp down
if has_arg('ctdp down frequency') then
infobox:node(p.add_entry('cTDP down frequency', mw.html.create('td'):wikitext('[[tdp down frequency::' .. arg('ctdp down frequency') .. ']]')))
end
-- ctdp up
if has_arg('ctdp up') then
infobox:node(p.add_entry('cTDP up', mw.html.create('td'):wikitext('[[tdp up::' .. arg('ctdp up') .. ']]')))
end
-- ctdp up
if has_arg('ctdp up frequency') then
infobox:node(p.add_entry('cTDP up frequency', mw.html.create('td'):wikitext('[[tdp up frequency::' .. arg('ctdp up frequency') .. ']]')))
end
-- temp min
if has_arg('temp min') then
infobox:node(p.add_entry('OP Temperature', mw.html.create('td'):wikitext('[[min operating temperature::' .. arg('temp min') .. ']] – ' ..
'[[max operating temperature::' .. arg('temp max') .. ']]')))
end
-- tjunc min
if has_arg('tjunc min') then
infobox:node(p.add_entry('T<sub>junction</sub>', mw.html.create('td'):wikitext('[[min junction temperature::' .. arg('tjunc min') .. ']] – ' ..
'[[max junction temperature::' .. arg('tjunc max') .. ']]')))
end
-- tcase min
if has_arg('tcase min') then
infobox:node(p.add_entry('T<sub>case</sub>', mw.html.create('td'):wikitext('[[min case temperature::' .. arg('tcase min') .. ']] – ' ..
'[[max case temperature::' .. arg('tcase max') .. ']]')))
end
-- tstorage min
if has_arg('tstorage min') then
infobox:node(p.add_entry('T<sub>storage</sub>', mw.html.create('td'):wikitext('[[min storage temperature::' .. arg('tstorage min') .. ']] – ' ..
'[[max storage temperature::' .. arg('tstorage max') .. ']]')))
end
-- tambient min
if has_arg('tambient min') then
infobox:node(p.add_entry('T<sub>ambient</sub>', mw.html.create('td'):wikitext('[[min ambient temperature::' .. arg('tambient min') .. ']] – ' ..
'[[max ambient temperature::' .. arg('tambient max') .. ']]')))
end
-- ####################################################################
-- Packaging
if has_arg('package module 1') then
p.add_separator(infobox, 'Packaging')
for i = 1, 10 do
if has_arg('package module ' .. i) then
infobox
:tag('tr'):tag('td'):attr('colspan', '2')
:wikitext(frame:preprocess(arg('package module ' .. i)))
end
end
end
if has_arg('packaging') or has_arg('package 0') then
infobox:wikitext('[[Category:Articles with invalid parameter in template]]')
end
infobox:wikitext('[[Category:all microprocessor models]]')
infobox:wikitext('[[full page name::' .. frame:preprocess('{{FULLPAGENAME}}') .. '| ]]')
if has_arg('future') and
(string.lower(arg('future')) == 'yes' or string.lower(arg('future')) == 'true') then
infobox:wikitext('[[Category:future microprocessor models]][[ldate::3000| ]]')
elseif has_arg('first launched') then
infobox:wikitext('[[ldate::' .. arg('first launched') .. '| ]]')
end
return infobox
end
return p