From WikiChip
Difference between revisions of "Module:chip"

(Fixes and removed pdata survey.)
 
(117 intermediate revisions by 5 users not shown)
Line 33: Line 33:
  
 
function arg(name)
 
function arg(name)
return origArgs[name]
+
if has_arg(name) then
 +
return origArgs[name]
 +
end
 +
return ''
 +
end
 +
 
 +
function p.set_val(prop, val)
 +
p.frame:preprocess('{{#set: ' .. prop .. '=' .. val .. '}}')
 +
end
 +
 
 +
local function append_packaging_data(infobox, arg_name, pdata, add_space)
 +
    local package_name = origArgs[arg_name]
 +
    if not package_name or package_name == '' then return add_space end
 +
 
 +
    local need_space = add_space
 +
    local function may_add_space()
 +
        need_space = true
 +
        if add_space then
 +
            infobox:tag('tr'):tag('td'):attr('colspan', '2'):tag('hr')
 +
            add_space = false
 +
        end
 +
    end
 +
 
 +
    local function show_error(text)
 +
        infobox:wikitext('[[Category:Articles with invalid parameter in template]]')
 +
        may_add_space()
 +
        local e = mw.html.create('tr')
 +
        e:tag('td')
 +
            :attr('colspan', '2')
 +
            :attr('style', 'color: #c00;')
 +
            :wikitext(text)
 +
        infobox:node(e)
 +
    end
 +
 
 +
    -- Reject unexpected input, esp. smw.ask operators []:|?*~
 +
    if mw.ustring.find(package_name, '[^%w %-+._,/]') then
 +
        show_error('Invalid package name')
 +
        return need_space
 +
    end
 +
 
 +
    local package_location, info, result = {}
 +
    local page_name = package_name
 +
    for field in string.gmatch(package_name, "([^,]+),?") do
 +
        table.insert(package_location, field)
 +
    end
 +
    if #package_location > 1 then
 +
        page_name = package_location[1] .. '/packages/' .. package_location[2]
 +
        if pdata['packages'][package_location[1]] then
 +
            info = pdata['packages'][package_location[1]][package_location[2]]
 +
        end
 +
    end
 +
    if mw.smw then
 +
        result = mw.smw.ask('[[Category:all ic packages]][[' .. page_name .. ']]' ..
 +
            '|?package|?package type|?package contacts#-|?package pitch#-' ..
 +
            '|?package length#-|?package width#-|?package height#-|?socket')
 +
    end
 +
    local dim_props = {'package length', 'package width', 'package height'}
 +
    if type(result) == 'table' and #result >= 1 and result[1]['package'] then
 +
        info = result[1]
 +
    else
 +
        if not info then
 +
            show_error('Unknown package "' .. package_name .. '"')
 +
            return need_space
 +
        end
 +
        page_name = nil
 +
        for i, name in ipairs(dim_props)
 +
            do info[name] = info.p_size and info.p_size[i] or nil end
 +
    end
 +
 
 +
    local function tabled(x) return type(x) == 'table' and x or { x } end
 +
    local function show(label, text)
 +
        if not text or text == '' then return end
 +
        may_add_space()
 +
        infobox:node(p.add_entry(label, mw.html.create('td'):wikitext(text)))
 +
    end
 +
    local function param(a)
 +
        local prop_names = unpack(a)
 +
        local text, sep = '', ''
 +
        for i, prop_name in ipairs(tabled(prop_names)) do
 +
            local values = info[prop_name] -- single value or table
 +
            if values then
 +
                local n_values = 0
 +
                for j, value in ipairs(tabled(values)) do
 +
                    if value and value ~= '' then
 +
                        if a.set_prop then p.set_val(a.set_prop, value) end
 +
                        text = text .. sep .. value
 +
                        sep = a.sep or ', '
 +
                        n_values = n_values + 1
 +
                        if n_values >= (a.max_values or 1) then break end
 +
                    end
 +
                end
 +
            end
 +
        end
 +
        return text
 +
    end
 +
    local p_type_text, p_type_abbr = param{{'package type', 'p_type'}}, ''
 +
    if p_type_text ~= '' and mw.ustring.len(p_type_text) <= 10 then
 +
        p_type_abbr = ' (' .. p_type_text .. ')'
 +
        p_type_text = ''
 +
    end
 +
    local p_name = param{{'package', 'p_name'}, set_prop='package', max_values=10}
 +
    if p_name ~= '' then
 +
        if page_name then p_name = '[[' .. page_name .. '|' .. p_name .. ']]' end
 +
        show('Package', p_name .. p_type_abbr)
 +
    end
 +
    show('Package Type', p_type_text)
 +
    show('Dimension', param{dim_props, sep=' × '})
 +
    show('Pitch', param{{'package pitch', 'p_pitch'}, max_values=2, sep=' × '})
 +
    show('Contacts', param{{'package contacts', 'p_contacts'}})
 +
    show('Socket', param{{'socket', 'p_socket'}, set_prop='socket', max_values=10})
 +
    return need_space
 
end
 
end
  
 
function p.chip(frame)
 
function p.chip(frame)
 
 
 +
p.frame = frame
 
     if frame == mw.getCurrentFrame() then
 
     if frame == mw.getCurrentFrame() then
 
         origArgs = frame:getParent().args
 
         origArgs = frame:getParent().args
Line 43: Line 154:
 
         origArgs = frame.args
 
         origArgs = frame.args
 
     end
 
     end
 +
   
 +
   
 +
    local infobox = mw.html.create('table')
 +
   
 +
    -- by default it's a microprocessor
 +
    local chip_type = 'microprocessor'
 +
    if has_arg('chip type') then
 +
chip_type = arg('chip type')
 +
end
 +
 +
-- define it as an instance of that chip
 +
p.set_val('instance of', chip_type)
 
 
 +
-- same for category
 +
    infobox:wikitext('[[Category:all ' .. chip_type .. ' models]]')
 
 
    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: left; font-weight: bold;')
 +
            :wikitext('[[Special:FormEdit/chip/' .. frame:preprocess('{{FULLPAGENAME}}') .. '|<i class="fa fa-edit"></i>Edit Values]]')
  
 
     -- header
 
     -- header
 
     if has_arg('name') then
 
     if has_arg('name') then
      infobox
+
infobox
        :tag('tr')
+
:tag('tr')
          :tag('td')
+
:tag('td')
            :attr('class', 'header-main')
+
:attr('class', 'header-main')
            :attr('colspan', '2')
+
:attr('colspan', '2')
            :wikitext('[[name::' .. arg('name') .. ']]')
+
:wikitext(arg('name'))
 +
p.set_val('name', arg('name'))
 
     end
 
     end
  
 
     -- image
 
     -- image
    if has_arg('no image') then
+
if 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')
 +
    -- make sure it's the ogimage
 +
    :wikitext('[[' .. image .. '|link=|class=wikichip_ogimage|' .. image_size .. ']]')
 +
 +
p.set_val('main image', image)
 +
 
 +
      -- add a caption, if provided
 +
      if has_arg('caption') then
 +
infobox
 +
:tag('tr')
 +
:tag('td')
 +
:attr('style', 'text-align: center;')
 +
:attr('colspan', '2')
 +
:wikitext(arg('caption'))
 +
p.set_val('main image caption', arg('caption'))
 +
      end
 +
elseif not has_arg('no image') then
 
       infobox
 
       infobox
 
         :tag('tr')
 
         :tag('tr')
Line 68: Line 222:
 
             :attr('colspan', '2')
 
             :attr('colspan', '2')
 
             :wikitext('[[File:no photo (ic).svg|link=|200px]]')
 
             :wikitext('[[File:no photo (ic).svg|link=|200px]]')
elseif has_arg('image') then
+
    end
      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
+
    -- image
      if has_arg('caption') then
+
if has_arg('image 2') then
        infobox
+
local image = p.add_file_prefix(arg('image 2'))
          :tag('tr')
+
local image_size = has_arg('image 2 size') and arg('image 2 size') or "200px"
            :tag('td')
+
infobox
              :attr('class', 'chip-infobox-pic-caption')
+
:tag('tr')
              :attr('colspan', '2')
+
  :tag('td')
              :wikitext('[[image capation::' .. arg('caption') .. ']]')
+
    :attr('style', 'text-align: center;')
      end
+
    :attr('colspan', '2')
    end
+
    -- make sure it's the ogimage
 +
    :wikitext('[[' .. image .. '|link=|' .. image_size .. ']]')
 +
end
  
 
     -- ####################################################################
 
     -- ####################################################################
Line 95: Line 245:
 
     -- designer
 
     -- designer
 
     if has_arg('designer') then
 
     if has_arg('designer') then
       local designers = mw.html.create('td')
+
       local designers = mw.html.create('td'):attr('style', 'width: 99%;')
       designers:wikitext('[[designer::' .. arg('designer') .. '| ]][[' .. arg('designer') .. ']]' ..
+
       p.set_val('designer', arg('designer'))
       '[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer')) .. ']]')
+
      designers:wikitext('[[' .. arg('designer') .. ']]' ..
 +
       '[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer')) .. ']]')
 
if has_arg('microarch') then
 
if has_arg('microarch') then
designers:wikitext('[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer')) ..
+
designers:wikitext('[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer')) ..
 
' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
 
' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
 +
end
 +
 +
for i = 2, 10 do
 +
if has_arg('microarch ' .. i) then
 +
designers:wikitext('[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer')) ..
 +
  ' based on ' .. mw.ustring.lower(arg('microarch ' .. i)) .. ']]')
 +
end
 
end
 
end
 
        
 
        
 
       for i = 2, 10 do
 
       for i = 2, 10 do
 
       if not has_arg('designer ' .. i) then break end
 
       if not has_arg('designer ' .. i) then break end
       designers:wikitext(', [[designer::' .. arg('designer ' .. i) .. ']][[' .. arg('designer ' .. i) .. ']]' ..
+
      p.set_val('designer', arg('designer ' .. i))
      '[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer ' .. i)) .. ']]')
+
       designers:wikitext(',<br>[[' .. arg('designer ' .. i) .. ']]' ..
  if has_arg('microarch') then
+
      '[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer ' .. i)) .. ']]')
designers:wikitext('[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer ' .. i)) ..
+
     
  ' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
+
if has_arg('microarch') then
  end
+
designers:wikitext('[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer ' .. i)) ..
 +
' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
 +
end
 +
 +
for j = 2, 10 do
 +
if has_arg('microarch ' .. j) then
 +
designers:wikitext('[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer ' .. i)) ..
 +
  ' based on ' .. mw.ustring.lower(arg('microarch ' .. j)) .. ']]')
 +
end
 +
end
 
       end
 
       end
 
     infobox:node(p.add_entry('Designer', designers))
 
     infobox:node(p.add_entry('Designer', designers))
Line 117: Line 284:
 
     -- manufacturer
 
     -- manufacturer
 
     if has_arg('manufacturer') then
 
     if has_arg('manufacturer') then
       local manufacturers = '[[manufacturer::' .. arg('manufacturer') .. '| ]][[' .. arg('manufacturer') .. ']]' ..
+
       local manufacturers = '[[' .. arg('manufacturer') .. ']]' ..
      '[[category:microprocessor models by ' .. mw.ustring.lower(arg('manufacturer')) .. ']]'
+
      '[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('manufacturer')) .. ']]'
 +
  p.set_val('manufacturer', arg('manufacturer'))
 
      
 
      
 
       for i = 2, 10 do
 
       for i = 2, 10 do
 
       if not has_arg('manufacturer ' .. i) then break end
 
       if not has_arg('manufacturer ' .. i) then break end
       manufacturers = manufacturers .. ', [[manufacturer::' .. arg('manufacturer ' .. i) .. ']][[' .. arg('manufacturer ' .. i) .. ']]' ..
+
       manufacturers = manufacturers .. ', [[' .. arg('manufacturer ' .. i) .. ']]' ..
      '[[category:microprocessor models by ' .. mw.ustring.lower(arg('manufacturer ' .. i)) .. ']]'
+
      '[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('manufacturer ' .. i)) .. ']]'
 +
  p.set_val('manufacturer', arg('manufacturer ' .. i))
 
       end
 
       end
 
        
 
        
Line 131: Line 300:
 
-- model number
 
-- model number
 
if has_arg('model number') then
 
if has_arg('model number') then
  infobox:node(p.add_entry('Model Number', mw.html.create('td'):wikitext('[[model number::' .. arg('model number') .. ']]')))
+
p.set_val('model number', arg('model number'))
 +
  infobox:node(p.add_entry('Model Number', mw.html.create('td'):attr('style', 'width: 99%;'):wikitext(arg('model number'))))
 
end
 
end
 
      
 
      
 
     -- part number
 
     -- part number
 
     if has_arg('part number') then
 
     if has_arg('part number') then
      local parts = '[[part number::' .. arg('part number') .. ']]'
+
p.set_val('part number', arg('part number'))
      for i = 1, 10 do
+
local parts = arg('part number')
      if not has_arg('part number ' .. i) then break end
+
for i = 2, 10 do
      parts = parts .. ', [[part number::' .. arg('part number ' .. i) .. ']]'
+
if not has_arg('part number ' .. i) then break end
      end
+
p.set_val('part number', arg('part number ' .. i))
    infobox:node(p.add_entry('Part Number', mw.html.create('td'):wikitext(parts)))
+
parts = parts .. ',<br> ' .. arg('part number ' .. i)
 +
end
 +
infobox:node(p.add_entry('Part Number', mw.html.create('td'):wikitext(parts)))
 
end
 
end
 
      
 
      
 
     -- s-spec
 
     -- s-spec
 
     if has_arg('s-spec') or has_arg('s-spec qs') then
 
     if has_arg('s-spec') or has_arg('s-spec qs') then
       local sspec  
+
       local sspec = ''
 
       if has_arg('s-spec') then
 
       if has_arg('s-spec') then
        sspec = '[[s-spec::' .. arg('s-spec') .. ']]'
+
      p.set_val('s-spec', arg('s-spec'))
 +
        sspec = arg('s-spec')
 
         for i = 2, 30 do
 
         for i = 2, 30 do
 
         if not has_arg('s-spec ' .. i) then break end
 
         if not has_arg('s-spec ' .. i) then break end
         sspec = sspec .. ', [[s-spec::' .. arg('s-spec ' .. i) .. ']]'
+
      p.set_val('s-spec', arg('s-spec ' .. i))
 +
         sspec = sspec .. ', ' .. arg('s-spec ' .. i)
 
         end
 
         end
 
       end
 
       end
 
       if has_arg('s-spec qs') then
 
       if has_arg('s-spec qs') then
 
       if has_arg('s-spec') then sspec = sspec .. '<br>' end
 
       if has_arg('s-spec') then sspec = sspec .. '<br>' end
        sspec = sspec .. '[[s-spec (qs)::' .. arg('s-spec qs') .. ']] ([[qualification sample|QS]])'
+
      p.set_val('s-spec (qs)', arg('s-spec qs'))
 +
        sspec = sspec .. arg('s-spec qs') .. ' ([[qualification sample|QS]])'
 
         for i = 2, 30 do
 
         for i = 2, 30 do
 
         if not has_arg('s-spec qs ' .. i) then break end
 
         if not has_arg('s-spec qs ' .. i) then break end
         sspec = sspec .. ', [[s-spec (qs)::' .. arg('s-spec qs ' .. i) .. ']]'
+
      p.set_val('s-spec (qs)', arg('s-spec qs ' .. i))
 +
         sspec = sspec .. ', ' .. arg('s-spec qs ' .. i) .. ' ([[qualification sample|QS]])'
 
         end
 
         end
 
       end
 
       end
Line 167: Line 343:
 
-- market segment
 
-- market segment
 
     if has_arg('market') then
 
     if has_arg('market') then
      local markets = mw.html.create('td'):wikitext('[[market segment::' .. arg('market') .. ']]')
+
p.set_val('market segment', arg('market'))
      for i = 2, 5 do
+
      local markets = mw.html.create('td'):wikitext(arg('market'))
      if not has_arg('market ' .. i) then break end
+
      for i = 2, 5 do
      markets:wikitext(', [[market segment::' .. arg('market ' .. i) .. ']]')
+
  if not has_arg('market ' .. i) then break end
      end
+
p.set_val('market segment', arg('market ' .. i))
    infobox:node(p.add_entry('Market', markets))
+
      markets:wikitext(', ' .. arg('market ' .. i))
 +
      end
 +
    infobox:node(p.add_entry('Market', markets))
 
end
 
end
 
 
Line 179: Line 357:
 
  local release = mw.html.create('td')
 
  local release = mw.html.create('td')
 
  if has_arg('first announced') then
 
  if has_arg('first announced') then
    release:wikitext('[[first announced::' .. arg('first announced') .. ']] (announced)')
+
  p.set_val('first announced', arg('first announced'))
 +
    release:wikitext(arg('first announced') .. ' (announced)')
 
  end
 
  end
 
  if has_arg('first launched') then
 
  if has_arg('first launched') then
Line 185: Line 364:
 
    release:wikitext('<br>')
 
    release:wikitext('<br>')
 
   end
 
   end
    release:wikitext('[[first launched::' .. arg('first launched') .. ']] (launched)')
+
  p.set_val('first launched', arg('first launched'))
 +
    release:wikitext(arg('first launched') .. ' (launched)')
 
  end
 
  end
  infobox:node(p.add_entry('Release', release))
+
  infobox:node(p.add_entry('Introduction', release))
 
end
 
end
 
 
Line 194: Line 374:
 
  local release = mw.html.create('td')
 
  local release = mw.html.create('td')
 
  if has_arg('last order') then
 
  if has_arg('last order') then
    release:wikitext('[[last order::' .. arg('last order') .. ']] (last order)')
+
  p.set_val('last order', arg('last order'))
 +
    release:wikitext(arg('last order') .. ' (last order)')
 
  end
 
  end
 
  if has_arg('last shipment') then
 
  if has_arg('last shipment') then
Line 200: Line 381:
 
    release:wikitext('<br>')
 
    release:wikitext('<br>')
 
   end
 
   end
    release:wikitext('[[last shipment::' .. arg('last shipment') .. ']] (last shipment)')
+
  p.set_val('last shipment', arg('last shipment'))
 +
    release:wikitext(arg('last shipment') .. ' (last shipment)')
 
  end
 
  end
 
  infobox:node(p.add_entry('End-of-life', release))
 
  infobox:node(p.add_entry('End-of-life', release))
Line 206: Line 388:
 
 
 
-- release price
 
-- release price
if has_arg('release price') then
+
if has_arg('release price') or has_arg('release price (box)') or has_arg('release price (tray)') then
  infobox:node(p.add_entry('Release Price', mw.html.create('td'):wikitext('[[release price::' ..
+
local release_price = ''
  arg('release price') .. '| ]]' .. arg('release price'))))
+
 +
if has_arg('release price') then
 +
release_price = arg('release price')
 +
p.set_val('release price', arg('release price'))
 +
end
 +
if has_arg('release price (tray)') then
 +
if release_price ~= "" then release_price = release_price .. '<br>' end
 +
release_price = release_price .. arg('release price (tray)') .. ' (tray)'
 +
p.set_val('release price (tray)', arg('release price (tray)'))
 +
p.set_val('release price', arg('release price (tray)')) --add it there as well
 +
end
 +
if has_arg('release price (box)') then
 +
if release_price ~= "" then release_price = release_price .. '<br>' end
 +
release_price = release_price .. arg('release price (box)') .. ' (box)'
 +
p.set_val('release price (box)', arg('release price (box)'))
 +
p.set_val('release price', arg('release price (box)')) --add it there as well
 +
end
 +
 +
infobox:node(p.add_entry('Release Price', mw.html.create('td'):wikitext(release_price)))
 +
end
 +
 +
-- Shop links
 +
if has_arg('designer') and has_arg('name') then
 +
if string.len(string.match(string.lower(arg('designer')), '^intel') or '') > 0
 +
or string.len(string.match(string.lower(arg('designer')), '^amd') or '') > 0 then
 +
 +
local name = string.gsub(arg('designer') .. ' ' .. arg('name'), " ", "%%20")
 +
local link = '[https://www.amazon.com/gp/search?ie=UTF8&tag=wikichip-20&linkCode=ur2&linkId=aed902a15f809f6661ea2887020a7a0e&camp=1789&creative=9325&index=electronics&keywords=' .. name .. ' Amazon]'
 +
infobox:node(p.add_entry('Shop', mw.html.create('td'):wikitext(link)))
 +
end
 
end
 
end
 
 
Line 215: Line 426:
  
 
     -- ####################################################################
 
     -- ####################################################################
 +
    -- Generla Specs
 +
   
 +
    -- early checks
 +
    local hasTurbo = false
 +
    for i = 1, 42 do
 +
    if has_arg('turbo frequency' .. i) then hasTurbo = true break end
 +
end
 +
 +
 
     -- some general specs
 
     -- some general specs
    p.add_separator(infobox, 'General Specs')
+
if has_arg('family') or has_arg('series') or has_arg('locked') or
 +
has_arg('frequency') or hasTurbo or has_arg('turbo frequency') or
 +
has_arg('bus type') or has_arg('bus speed') or has_arg('bus rate') or
 +
has_arg('clock multiplier') or has_arg('cpuid') then
 +
    p.add_separator(infobox, 'General Specs')
 +
    end
 
 
 
-- family
 
-- family
 
if has_arg('family') then
 
if has_arg('family') then
  infobox:node(p.add_entry('Family', mw.html.create('td'):wikitext('[[microprocessor family::' .. arg('family') .. '| ]]' ..
+
local families = mw.html.create('td')
  '[[' .. mw.ustring.lower(arg('designer') .. '/' .. arg('family')) .. '|' .. arg('family') .. ']]')))
+
 +
p.set_val('family', arg('family'))
 +
families:wikitext(
 +
  '[[' .. mw.ustring.lower(arg('designer') .. '/' .. arg('family')) .. '|' .. arg('family') .. ']]')
 +
 
 +
for i = 2, 10 do
 +
if not has_arg('family ' .. i) then break end
 +
p.set_val('family', arg('family ' .. i))
 +
 +
families:wikitext(
 +
  ', [[' .. mw.ustring.lower(arg('designer') .. '/' .. arg('family ' .. i)) .. '|' .. arg('family ' .. i) .. ']]')
 +
end
 +
 +
 +
infobox:node(p.add_entry('Family', families))
 
end
 
end
 
 
 
-- series
 
-- series
 
if has_arg('series') then
 
if has_arg('series') then
  infobox:node(p.add_entry('Series', mw.html.create('td'):wikitext('[[microprocessor series::' .. arg('series') .. ']]')))
+
p.set_val('series', arg('series'))
 +
  infobox:node(p.add_entry('Series', mw.html.create('td'):wikitext(arg('series'))))
 
end
 
end
 
 
 
-- locked?
 
-- locked?
 
if has_arg('locked') then
 
if has_arg('locked') then
  infobox:node(p.add_entry('Locked', mw.html.create('td'):wikitext('[[has locked clock multiplier::' .. arg('locked') .. ']]')))
+
p.set_val('has locked clock multiplier', arg('locked'))
 +
infobox:node(p.add_entry('Locked', mw.html.create('td'):wikitext(arg('locked'))))
 
end
 
end
 
      
 
      
 
     -- frequency
 
     -- frequency
 
     if has_arg('frequency') then
 
     if has_arg('frequency') then
      local frequencies = mw.html.create('td'):wikitext('[[base frequency::' .. arg('frequency') .. '| ]]' .. arg('frequency'))
+
p.set_val('base frequency', arg('frequency'))
      for i = 2, 10 do
+
local frequencies = mw.html.create('td'):wikitext( arg('frequency'))
      if not has_arg('frequency ' .. i) then break end
+
for i = 2, 10 do
      frequencies:wikitext(', [[base frequency::' .. arg('frequency ' .. i) .. '| ]]' .. arg('frequency ' .. i))
+
if not has_arg('frequency ' .. i) then break end
      end
+
p.set_val('base frequency', arg('frequency ' .. i))
    infobox:node(p.add_entry('Frequency', frequencies))
+
frequencies:wikitext(', ' .. arg('frequency ' .. i))
 +
end
 +
infobox:node(p.add_entry('Frequency', frequencies))
 
end
 
end
 
      
 
      
 +
    -- lone turbo
 +
    if has_arg('turbo frequency') then
 +
local turbo = mw.html.create('td')
 +
p.set_val('turbo frequency', arg('turbo frequency'))
 +
turbo:wikitext(arg('turbo frequency'))
 +
infobox:node(p.add_entry('Turbo Frequency', turbo))
 +
end
 +
 
     -- turbo frequency
 
     -- turbo frequency
     if has_arg('turbo frequency') then
+
     if hasTurbo then
 
       local turbo = mw.html.create('td')
 
       local turbo = mw.html.create('td')
       for i = 1, 30 do
+
      local sep = ''
 +
       for i = 1, 42 do
 
       --sometimes turbo is not specified for odd-cores, so skip 2 each time, so we can't break
 
       --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 not has_arg('turbo frequency' .. i) then break end
 
         if has_arg('turbo frequency' .. i) then
 
         if has_arg('turbo frequency' .. i) then
 
         local s = i > 1 and 's' or ''
 
         local s = i > 1 and 's' or ''
         local br = i > 1 and ',<br>' or ''
+
         p.set_val('turbo frequency (' .. i .. ' core' .. s .. ')', arg('turbo frequency' .. i))
turbo:wikitext(br .. ' [[turbo frequency (' .. i .. ' core' .. s .. ')::' .. arg('turbo frequency' .. i) .. '| ]]' ..
+
turbo:wikitext(sep .. arg('turbo frequency' .. i) .. ' (' .. i .. ' core' .. s .. ')')
          arg('turbo frequency' .. i) .. ' (' .. i .. ' core' .. s .. ')')
+
        sep = ',<br>'
 
       end
 
       end
 
       end
 
       end
Line 262: Line 514:
 
-- bus type
 
-- bus type
 
if has_arg('bus type') then
 
if has_arg('bus type') then
  infobox:node(p.add_entry('Bus type', mw.html.create('td'):wikitext('[[bus type::' .. arg('bus type') .. ']]')))
+
p.set_val('bus type', arg('bus type'))
 +
infobox:node(p.add_entry('Bus type', mw.html.create('td'):wikitext(arg('bus type'))))
 
end
 
end
 
 
 
-- bus speed
 
-- bus speed
 
if has_arg('bus speed') then
 
if has_arg('bus speed') then
  infobox:node(p.add_entry('Bus speed', mw.html.create('td'):wikitext('[[bus speed::' .. arg('bus speed') .. '| ]]'
+
p.set_val('bus speed', arg('bus speed'))
  .. arg('bus speed'))))
+
infobox:node(p.add_entry('Bus speed', mw.html.create('td'):wikitext(arg('bus speed'))))
 
end
 
end
 
 
Line 274: Line 527:
 
if has_arg('bus rate') then
 
if has_arg('bus rate') then
 
local links = ''
 
local links = ''
  if has_arg('bus links') then
+
if has_arg('bus links') then
    links = '[[bus links::' .. arg('bus links') .. ']]&nbsp;×&nbsp;'
+
p.set_val('bus links', arg('bus links'))
  end
+
links = arg('bus links') .. '&nbsp;×&nbsp;'
  infobox:node(p.add_entry('Bus rate', mw.html.create('td'):wikitext(links .. '[[bus rate::' .. arg('bus rate') .. '| ]]'
+
end
  .. arg('bus rate'))))
+
p.set_val('bus rate', arg('bus rate'))
 +
infobox:node(p.add_entry('Bus rate', mw.html.create('td'):wikitext(links .. arg('bus rate'))))
 
end
 
end
 
 
 
-- clock mult
 
-- clock mult
 
if has_arg('clock multiplier') then
 
if has_arg('clock multiplier') then
  infobox:node(p.add_entry('Clock multiplier', mw.html.create('td'):wikitext('[[clock multiplier::' .. arg('clock multiplier') .. ']]')))
+
p.set_val('clock multiplier', arg('clock multiplier'))
 +
infobox:node(p.add_entry('Clock multiplier', mw.html.create('td'):wikitext(arg('clock multiplier'))))
 
end
 
end
 
 
 
-- CPUID
 
-- CPUID
 
     if has_arg('cpuid') then
 
     if has_arg('cpuid') then
      local cpuid = mw.html.create('td'):wikitext('[[cpuid::' .. arg('cpuid') .. ']]')
+
p.set_val('cpuid', arg('cpuid'))
      for i = 2, 10 do
+
local cpuid = mw.html.create('td'):wikitext(arg('cpuid'))
      if not has_arg('cpuid ' .. i) then break end
+
for i = 2, 10 do
      cpuid:wikitext(', [[cpuid::' .. arg('cpuid ' .. i) .. ']]')
+
if not has_arg('cpuid ' .. i) then break end
      end
+
p.set_val('cpuid', arg('cpuid ' .. i))
 +
cpuid:wikitext(', ' .. arg('cpuid ' .. i))
 +
end
 
     infobox:node(p.add_entry('CPUID', cpuid))
 
     infobox:node(p.add_entry('CPUID', cpuid))
 +
end
 +
 +
 +
    -- ####################################################################
 +
    -- Neuromorphic Chip
 +
   
 +
    -- some general specs
 +
if has_arg('neuron count') or has_arg('synapse count') then
 +
    p.add_separator(infobox, 'Neuromorphic Specs')
 +
    end
 +
   
 +
-- neurons count
 +
if has_arg('neuron count') then
 +
p.set_val('neuron count', arg('neuron count'))
 +
  infobox:node(p.add_entry('Neurons', mw.html.create('td'):wikitext(arg('neuron count'))))
 +
end
 +
 +
-- synapse count
 +
if has_arg('synapse count') then
 +
p.set_val('synapse count', arg('synapse count'))
 +
  infobox:node(p.add_entry('Synapses', mw.html.create('td'):wikitext(arg('synapse count'))))
 
end
 
end
  
Line 302: Line 580:
 
-- ISA
 
-- ISA
 
     if has_arg('isa') or has_arg('isa family') then
 
     if has_arg('isa') or has_arg('isa family') then
      local isa = mw.html.create('td'):wikitext('[[isa::' .. arg('isa') .. ']]')
+
  p.set_val('isa', arg('isa'))
      for i = 2, 10 do
+
      local isa = mw.html.create('td'):wikitext(arg('isa'))
      if not has_arg('isa ' .. i) then break end
+
if has_arg('isa family') then
      isa:wikitext(', [[isa::' .. arg('isa ' .. i) .. ']]')
+
p.set_val('isa family', arg('isa family'))
      end
+
isa:wikitext('&nbsp;(' .. arg('isa family') .. ')')
      if has_arg('isa family') then
+
end
        isa:wikitext('&nbsp;([[isa family::' .. arg('isa family') .. ']])')
+
      for i = 2, 10 do
    end
+
      if not has_arg('isa ' .. i) then break end
 +
      p.set_val('isa', arg('isa ' .. i))
 +
      isa:wikitext(', ' .. arg('isa ' .. i))
 +
if has_arg('isa ' .. i .. ' family') then
 +
p.set_val('isa family', arg('isa ' .. i .. ' family'))
 +
isa:wikitext('&nbsp;(' .. arg('isa ' .. i .. ' family') .. ')')
 +
end
 +
      end
 
     infobox:node(p.add_entry('ISA', isa))
 
     infobox:node(p.add_entry('ISA', isa))
 
end
 
end
Line 316: Line 601:
 
     if has_arg('microarch') then
 
     if has_arg('microarch') then
 
       local microarchs = mw.html.create('td')
 
       local microarchs = mw.html.create('td')
       microarchs:wikitext('[[microarchitecture::' .. arg('microarch') .. '| ]]')
+
       p.set_val('microarchitecture', arg('microarch'))
 
       microarchs:wikitext('[[' .. mw.ustring.lower(arg('designer')) .. '/microarchitectures/' ..
 
       microarchs:wikitext('[[' .. mw.ustring.lower(arg('designer')) .. '/microarchitectures/' ..
 
       mw.ustring.lower(arg('microarch')) .. '|' .. arg('microarch') .. ']]')
 
       mw.ustring.lower(arg('microarch')) .. '|' .. arg('microarch') .. ']]')
 
       for i = 2, 10 do
 
       for i = 2, 10 do
 
       if not has_arg('microarch ' .. i) then break end
 
       if not has_arg('microarch ' .. i) then break end
       microarchs:wikitext(', [[microarchitecture::' .. arg('microarch ' .. i) .. ']]')
+
       p.set_val('microarchitecture', arg('microarch ' .. i))
 +
        microarchs:wikitext(', [[' .. mw.ustring.lower(arg('designer')) .. '/microarchitectures/' ..
 +
      mw.ustring.lower(arg('microarch ' .. i)) .. '|' .. arg('microarch ' .. i) .. ']]')
 
       end
 
       end
     infobox:node(p.add_entry('µarch', microarchs))
+
     infobox:node(p.add_entry('Microarchitecture', microarchs))
 
end
 
end
 
 
 
-- platform
 
-- platform
 
if has_arg('platform') then
 
if has_arg('platform') then
  infobox:node(p.add_entry('Platform', mw.html.create('td'):wikitext('[[platform::' .. arg('platform') .. ']]')))
+
p.set_val('platform', arg('platform'))
 +
infobox:node(p.add_entry('Platform', mw.html.create('td'):wikitext(arg('platform'))))
 
end
 
end
 
 
 
-- chipset
 
-- chipset
 
     if has_arg('chipset') then
 
     if has_arg('chipset') then
      local chipset = mw.html.create('td'):wikitext('[[chipset::' .. arg('chipset') .. ']]')
+
p.set_val('chipset', arg('chipset'))
      for i = 2, 10 do
+
local chipset = mw.html.create('td'):wikitext(arg('chipset'))
      if not has_arg('chipset ' .. i) then break end
+
for i = 2, 10 do
      chipset:wikitext(', [[chipset::' .. arg('chipset ' .. i) .. ']]')
+
if not has_arg('chipset ' .. i) then break end
      end
+
p.set_val('chipset', arg('chipset ' .. i))
    infobox:node(p.add_entry('Chipset', chipset))
+
chipset:wikitext(', ' .. arg('chipset ' .. i))
 +
      end
 +
infobox:node(p.add_entry('Chipset', chipset))
 
end
 
end
 
 
 
-- core name
 
-- core name
 
     if has_arg('core name') then
 
     if has_arg('core name') then
      local core_name = mw.html.create('td'):wikitext('[[core name::' .. arg('core name') .. '| ]]' ..
+
p.set_val('core name', arg('core name'))
 +
      local core_name = mw.html.create('td'):wikitext(
 
       '[[' .. mw.ustring.lower(arg('designer')) .. '/cores/' .. mw.ustring.lower(arg('core name')) .. '|' ..
 
       '[[' .. mw.ustring.lower(arg('designer')) .. '/cores/' .. mw.ustring.lower(arg('core name')) .. '|' ..
 
       arg('core name') .. ']]')
 
       arg('core name') .. ']]')
 
       for i = 2, 10 do
 
       for i = 2, 10 do
 
       if not has_arg('core name ' .. i) then break end
 
       if not has_arg('core name ' .. i) then break end
       core_name:wikitext(', [[core name::' .. arg('core name ' .. i) .. ']]' ..
+
       p.set_val('core name', arg('core name ' .. i))
 +
      core_name:wikitext(', ' ..
 
       '[[' .. mw.ustring.lower(arg('designer')) .. '/cores/' .. mw.ustring.lower(arg('core name ' .. i)) .. '|' ..
 
       '[[' .. mw.ustring.lower(arg('designer')) .. '/cores/' .. mw.ustring.lower(arg('core name ' .. i)) .. '|' ..
 
       arg('core name ' .. i) .. ']]')
 
       arg('core name ' .. i) .. ']]')
Line 357: Line 649:
 
-- core family
 
-- core family
 
     if has_arg('core family') then
 
     if has_arg('core family') then
      local corefam = mw.html.create('td'):wikitext('[[core family::' .. arg('core family') .. ']]')
+
    p.set_val('core family', arg('core family'))
 +
      local corefam = mw.html.create('td'):wikitext(arg('core family'))
 
       for i = 2, 10 do
 
       for i = 2, 10 do
 
       if not has_arg('core family ' .. i) then break end
 
       if not has_arg('core family ' .. i) then break end
       corefam:wikitext(', [[core family::' .. arg('core family ' .. i) .. ']]')
+
      p.set_val('core family', arg('core family ' .. i))
 +
       corefam:wikitext(', ' .. arg('core family ' .. i))
 
       end
 
       end
 
     infobox:node(p.add_entry('Core Family', corefam))
 
     infobox:node(p.add_entry('Core Family', corefam))
Line 367: Line 661:
 
-- core model
 
-- core model
 
     if has_arg('core model') then
 
     if has_arg('core model') then
      local coremodel = mw.html.create('td'):wikitext('[[core model::' .. arg('core model') .. ']]')
+
    p.set_val('core model', arg('core model'))
      for i = 2, 10 do
+
local coremodel = mw.html.create('td'):wikitext(arg('core model'))
      if not has_arg('core model ' .. i) then break end
+
for i = 2, 10 do
      coremodel:wikitext(', [[core model::' .. arg('core model ' .. i) .. ']]')
+
if not has_arg('core model ' .. i) then break end
      end
+
    p.set_val('core model', arg('core model ' .. i))
    infobox:node(p.add_entry('Core Model', coremodel))
+
coremodel:wikitext(', ' .. arg('core model ' .. i))
 +
end
 +
infobox:node(p.add_entry('Core Model', coremodel))
 
end
 
end
 
 
 
-- core stepping
 
-- core stepping
 
     if has_arg('core stepping') then
 
     if has_arg('core stepping') then
      local corestep = mw.html.create('td'):wikitext('[[core stepping::' .. arg('core stepping') .. ']]')
+
    p.set_val('core stepping', arg('core stepping'))
      for i = 2, 10 do
+
local corestep = mw.html.create('td'):wikitext(arg('core stepping'))
      if not has_arg('core stepping ' .. i) then break end
+
for i = 2, 10 do
      corestep:wikitext(', [[core stepping::' .. arg('core stepping ' .. i) .. ']]')
+
if not has_arg('core stepping ' .. i) then break end
      end
+
    p.set_val('core stepping', arg('core stepping ' .. i))
    infobox:node(p.add_entry('Core Stepping', corestep))
+
corestep:wikitext(', ' .. arg('core stepping ' .. i))
 +
end
 +
infobox:node(p.add_entry('Core Stepping', corestep))
 
end
 
end
 
 
 
-- process
 
-- process
 
     if has_arg('process') then
 
     if has_arg('process') then
      local process = mw.html.create('td'):wikitext('[[process::' .. arg('process') .. ']]')
+
p.set_val('process', arg('process'))
      for i = 2, 10 do
+
      local process = mw.html.create('td'):wikitext('[[' .. arg('process') .. ' process|' .. arg('process') .. ']]')
      if not has_arg('process ' .. i) then break end
+
      for i = 2, 10 do
      process:wikitext(', [[process::' .. arg('process ' .. i) .. ']]')
+
      if not has_arg('process ' .. i) then break end
      end
+
p.set_val('process', arg('process ' .. i))
    infobox:node(p.add_entry('Process', process))
+
      process:wikitext(', ' .. '[[' .. arg('process ' .. i) .. ' process|' .. arg('process ' .. i) .. ']]')
 +
      end
 +
    infobox:node(p.add_entry('Process', process))
 
end
 
end
 
 
 
-- Transistors
 
-- Transistors
 
if has_arg('transistors') then
 
if has_arg('transistors') then
  infobox:node(p.add_entry('Transistors', mw.html.create('td'):wikitext('[[transistors::' .. arg('transistors') .. ']]')))
+
p.set_val('transistor count', arg('transistors'))
 +
  infobox:node(p.add_entry('Transistors', mw.html.create('td'):wikitext(arg('transistors'))))
 
end
 
end
 
 
 
-- Technology
 
-- Technology
 
if has_arg('technology') then
 
if has_arg('technology') then
  infobox:node(p.add_entry('Technology', mw.html.create('td'):wikitext('[[technology::' .. arg('technology') .. ']]')))
+
p.set_val('technology', arg('technology'))
 +
  infobox:node(p.add_entry('Technology', mw.html.create('td'):wikitext(arg('technology'))))
 
end
 
end
 
 
Line 409: Line 711:
 
local die
 
local die
 
if has_arg('die size') then
 
if has_arg('die size') then
       die = mw.html.create('td'):wikitext('[[die area::' .. arg('die size') .. ']]')
+
p.set_val('die area', arg('die size'))
 +
       die = mw.html.create('td'):wikitext(arg('die size'))
 
else
 
else
die = mw.html.create('td'):wikitext('[[die area::' .. arg('die area') .. ']]')
+
p.set_val('die area', arg('die area'))
 +
die = mw.html.create('td'):wikitext(arg('die area'))
 
end
 
end
 
if has_arg('die length') and has_arg('die width') then
 
if has_arg('die length') and has_arg('die width') then
die:wikitext('<br>' .. '[[die length::' .. arg('die length') .. '| ]]' ..
+
p.set_val('die length', arg('die length'))
arg('die length') .. ' × [[die width::' .. arg('die width') .. '| ]]' ..
+
p.set_val('die width', arg('die width'))
arg('die width'))
+
die:wikitext('<br>' .. arg('die length') .. ' × ' .. arg('die width'))
 +
end
 +
  infobox:node(p.add_entry('Die', die))
 +
end
 +
 +
if has_arg('mcp') then
 +
p.set_val('is multi-chip package', arg('mcp'))
 +
  mcp = mw.html.create('td'):wikitext(arg('mcp'))
 +
if has_arg('die count') then
 +
p.set_val('die count', arg('die count'))
 +
      mcp:wikitext(' (' .. arg('die count') .. ' dies)')
 
end
 
end
 +
  infobox:node(p.add_entry('MCP', mcp))
 
end
 
end
 
 
 
-- word size
 
-- word size
 
if has_arg('word size') then
 
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'))))
+
p.set_val('word size', arg('word size'))
 +
infobox:node(p.add_entry('Word Size', mw.html.create('td'):wikitext(arg('word size'))))
 
end
 
end
 
 
 
-- core count
 
-- core count
 
if has_arg('core count') then
 
if has_arg('core count') then
  infobox:node(p.add_entry('Cores', mw.html.create('td'):wikitext('[[core count::' .. arg('core count') .. ']]')))
+
p.set_val('core count', arg('core count'))
 +
  infobox:node(p.add_entry('Cores', mw.html.create('td'):wikitext(arg('core count'))))
 
end
 
end
 
 
 
-- thread count
 
-- thread count
 
if has_arg('thread count') then
 
if has_arg('thread count') then
  infobox:node(p.add_entry('Threads', mw.html.create('td'):wikitext('[[thread count::' .. arg('thread count') .. ']]')))
+
p.set_val('thread count', arg('thread count'))
 +
  infobox:node(p.add_entry('Threads', mw.html.create('td'):wikitext(arg('thread count'))))
 +
end
 +
 +
-- max memory
 +
if has_arg('max memory') then
 +
p.set_val('max memory', arg('max memory'))
 +
infobox:node(p.add_entry('Max Memory', mw.html.create('td'):wikitext(arg('max memory'))))
 +
end
 +
 +
-- max memory addr
 +
if has_arg('max memory addr') then
 +
p.set_val('max memory address', arg('max memory addr'))
 +
  infobox:node(p.add_entry('Max Address Mem', mw.html.create('td'):wikitext(arg('max memory addr'))))
 +
end
 +
 +
 +
    -- ####################################################################
 +
    -- Multiprocessing
 +
    if has_arg('max cpus') or has_arg('smp interconnect')
 +
    or has_arg('smp interconnect links')
 +
    or has_arg('smp interconnect rate') then
 +
p.add_separator(infobox, 'Multiprocessing')
 
end
 
end
 
 
 
-- max cpus
 
-- max cpus
 
if has_arg('max cpus') then
 
if has_arg('max cpus') then
  infobox:node(p.add_entry('Max CPUs', mw.html.create('td'):wikitext('[[max cpu count::' .. arg('max cpus') .. ']]')))
+
local type = tonumber(arg('max cpus')) == 1 and ' (Uniprocessor)' or ' (Multiprocessor)'
 +
p.set_val('max cpu count', arg('max cpus'))
 +
p.set_val('smp max ways', arg('max cpus'))
 +
infobox:node(p.add_entry('Max SMP', mw.html.create('td'):wikitext(arg('max cpus') .. '-Way' .. type)))
 +
end
 +
 +
-- smp interconnect
 +
if has_arg('smp interconnect') then
 +
p.set_val('smp interconnect', arg('smp interconnect'))
 +
infobox:node(p.add_entry('Interconnect', mw.html.create('td'):wikitext(arg('smp interconnect'))))
 
end
 
end
 
 
-- max memory
+
-- smp interconnect links
if has_arg('max memory') then
+
if has_arg('smp interconnect links') then
  infobox:node(p.add_entry('Max Memory', mw.html.create('td'):wikitext('[[max memory::' .. arg('max memory') .. '| ]]' .. arg('max memory'))))
+
p.set_val('smp interconnect links', arg('smp interconnect links'))
 +
infobox:node(p.add_entry('Interconnect Links', mw.html.create('td'):wikitext(arg('smp interconnect links'))))
 
end
 
end
 
 
-- max memory addr
+
-- smp interconnect rate
if has_arg('max memory addr') then
+
if has_arg('smp interconnect rate') then
  infobox:node(p.add_entry('Max Address Mem', mw.html.create('td'):wikitext('[[max memory address::' .. arg('max memory addr') .. ']]')))
+
p.set_val('smp interconnect rate', arg('smp interconnect rate'))
 +
infobox:node(p.add_entry('Interconnect Rate', mw.html.create('td'):wikitext(arg('smp interconnect rate'))))
 
end
 
end
  
 
     -- ####################################################################
 
     -- ####################################################################
 
     -- Electrical
 
     -- Electrical
     p.add_separator(infobox, 'Electrical')
+
     if has_arg('power') or has_arg('average power') or has_arg('idle power')
 +
    or has_arg('v core') or has_arg('v io') or has_arg('sdp') or has_arg('tdp')
 +
    or has_arg('tdp typical') or has_arg('ctdp down') or has_arg('ctdp down frequency')
 +
or has_arg('ctdp up') or has_arg('ctdp up frequency')
 +
or has_arg('temp min') or has_arg('tjunc min')
 +
or has_arg('tcase min') or has_arg('tstorage min') or has_arg('tambient min') then
 +
p.add_separator(infobox, 'Electrical')
 +
    end
 
 
 
-- power
 
-- power
 
if has_arg('power') then
 
if has_arg('power') then
  infobox:node(p.add_entry('Power dissipation', mw.html.create('td'):wikitext('[[power dissipation::' .. arg('power') .. '| ]]' .. arg('power'))))
+
p.set_val('power dissipation', arg('power'))
 +
  infobox:node(p.add_entry('Power dissipation', mw.html.create('td'):wikitext(arg('power'))))
 
end
 
end
 
 
 
-- average power
 
-- average power
 
if has_arg('average power') then
 
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') .. ']]')))
+
p.set_val('power dissipation (average)', arg('average power'))
 +
  infobox:node(p.add_entry('Power dissipation (average)', mw.html.create('td'):wikitext(arg('average power'))))
 
end
 
end
 
 
 
-- power
 
-- power
 
if has_arg('idle power') then
 
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') .. ']]')))
+
p.set_val('power dissipation (idle)', arg('idle power'))
 +
infobox:node(p.add_entry('Power (idle)', mw.html.create('td'):wikitext(arg('idle power'))))
 
end
 
end
 
 
 
-- vcore
 
-- vcore
 
if has_arg('v core') then
 
if has_arg('v core') then
local vcore =  mw.html.create('td'):wikitext('[[core voltage::' .. arg('v core') .. ']]')
+
p.set_val('core voltage', arg('v core'))
 +
local vcore =  mw.html.create('td'):wikitext(arg('v core'))
 
if has_arg('v core tolerance') then
 
if has_arg('v core tolerance') then
vcore:wikitext(' ± [[core voltage tolerance::' .. arg('v core tolerance') .. ']]')
+
p.set_val('core voltage tolerance', arg('v core tolerance'))
 +
vcore:wikitext(' ± ' .. arg('v core tolerance'))
 
end
 
end
 
infobox:node(p.add_entry('V<sub>core</sub>', vcore))
 
infobox:node(p.add_entry('V<sub>core</sub>', vcore))
 
end
 
end
 
if has_arg('v core min') then
 
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') .. ']]-' ..
+
p.set_val('core voltage (min)', arg('v core min'))
'[[core voltage (max)::' .. arg('v core max') .. ']]')))
+
p.set_val('core voltage (max)', arg('v core max'))
 +
infobox:node(p.add_entry('V<sub>core</sub>', mw.html.create('td'):wikitext(arg('v core min') .. '-' .. arg('v core max'))))
 
end
 
end
  
 
-- io
 
-- io
 
if has_arg('v io') then
 
if has_arg('v io') then
local vcore =  mw.html.create('td'):wikitext('[[io voltage::' .. arg('v io') .. ']]')
+
p.set_val('io voltage', arg('v io'))
 +
local vcore =  mw.html.create('td'):wikitext(arg('v io'))
 
if has_arg('v io tolerance') then
 
if has_arg('v io tolerance') then
vcore:wikitext(' ± [[io voltage tolerance::' .. arg('v io tolerance') .. ']]')
+
p.set_val('io voltage tolerance', arg('v io tolerance'))
 +
vcore:wikitext(' ± ' .. arg('v io tolerance'))
 
end
 
end
 
for i = 2, 10 do
 
for i = 2, 10 do
 
  if not has_arg('v io ' .. i) then break end
 
  if not has_arg('v io ' .. i) then break end
  corestep:wikitext(', [[io voltage::' .. arg('v io ' .. i) .. ']]')
+
p.set_val('io voltage', arg('v io ' .. i))
 +
  vcore:wikitext(', ' .. arg('v io ' .. i))
 
end
 
end
 
infobox:node(p.add_entry('V<sub>I/O</sub>', vcore))
 
infobox:node(p.add_entry('V<sub>I/O</sub>', vcore))
Line 497: Line 863:
 
-- sdp
 
-- sdp
 
if has_arg('sdp') then
 
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') .. ']]')))
+
p.set_val('sdp', arg('sdp'))
 +
  infobox:node(p.add_entry('<abbr title="Scenario Design Power">SDP</abbr>', mw.html.create('td'):wikitext(arg('sdp'))))
 
end
 
end
 
 
 
-- tdp
 
-- tdp
 
if has_arg('tdp') then
 
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') .. ']]')))
+
p.set_val('tdp', arg('tdp'))
 +
local tdp =  mw.html.create('td'):wikitext(arg('tdp'))
 +
for i = 2, 10 do
 +
  if not has_arg('tdp ' .. i) then break end
 +
p.set_val('tdp', arg('tdp ' .. i))
 +
  tdp:wikitext(', ' .. arg('tdp ' .. i))
 +
end
 +
  infobox:node(p.add_entry('<abbr title="Thermal Design Power">TDP</abbr>', tdp))
 
end
 
end
 
 
 
-- tdp typical
 
-- tdp typical
 
if has_arg('tdp typical') then
 
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') .. ']]')))
+
p.set_val('tdp (typical)', arg('tdp typical'))
 +
infobox:node(p.add_entry('<abbr title="Thermal Design Power">TDP</abbr> (Typical)', mw.html.create('td'):wikitext(arg('tdp typical'))))
 
end
 
end
 
 
 
-- ctdp down
 
-- ctdp down
 
if has_arg('ctdp down') then
 
if has_arg('ctdp down') then
  infobox:node(p.add_entry('cTDP down', mw.html.create('td'):wikitext('[[tdp down::' .. arg('ctdp down') .. ']]')))
+
p.set_val('tdp down', arg('ctdp down'))
 +
  infobox:node(p.add_entry('cTDP down', mw.html.create('td'):wikitext(arg('ctdp down'))))
 
end
 
end
 
 
 
-- ctdp down
 
-- ctdp down
 
if has_arg('ctdp down frequency') then
 
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') .. ']]')))
+
p.set_val('tdp down frequency', arg('ctdp down frequency'))
 +
infobox:node(p.add_entry('cTDP down frequency', mw.html.create('td'):wikitext(arg('ctdp down frequency'))))
 
end
 
end
 
 
 
-- ctdp up
 
-- ctdp up
 
if has_arg('ctdp up') then
 
if has_arg('ctdp up') then
  infobox:node(p.add_entry('cTDP up', mw.html.create('td'):wikitext('[[tdp up::' .. arg('ctdp up') .. ']]')))
+
p.set_val('tdp up', arg('ctdp up'))
 +
  infobox:node(p.add_entry('cTDP up', mw.html.create('td'):wikitext(arg('ctdp up'))))
 
end
 
end
 
 
 
-- ctdp up
 
-- ctdp up
 
if has_arg('ctdp up frequency') then
 
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') .. ']]')))
+
p.set_val('tdp up frequency', arg('ctdp up frequency'))
 +
  infobox:node(p.add_entry('cTDP up frequency', mw.html.create('td'):wikitext(arg('ctdp up frequency'))))
 
end
 
end
 
 
 
-- temp min
 
-- temp min
if has_arg('temp min') then
+
if has_arg('temp min') or has_arg('temp max') then
  infobox:node(p.add_entry('OP Temperature', mw.html.create('td'):wikitext('[[min operating temperature::' .. arg('temp min') .. ']]&nbsp;–&nbsp;' ..
+
if has_arg('temp min') then p.set_val('min operating temperature', arg('temp min')) end
  '[[max operating temperature::' .. arg('temp max') .. ']]')))
+
if has_arg('temp max') then p.set_val('max operating temperature', arg('temp max')) end
 +
  infobox:node(p.add_entry('OP Temperature', mw.html.create('td'):wikitext(arg('temp min') .. '&nbsp;–&nbsp;' .. arg('temp max'))))
 
end
 
end
 
 
 
-- tjunc min
 
-- tjunc min
if has_arg('tjunc min') then
+
if has_arg('tjunc min') or has_arg('tjunc max') then
  infobox:node(p.add_entry('T<sub>junction</sub>', mw.html.create('td'):wikitext('[[min junction temperature::' .. arg('tjunc min') .. ']]&nbsp;–&nbsp;' ..
+
if has_arg('tjunc min') then p.set_val('min junction temperature', arg('tjunc min')) end
  '[[max junction temperature::' .. arg('tjunc max') .. ']]')))
+
if has_arg('tjunc max') then p.set_val('max junction temperature', arg('tjunc max')) end
 +
  infobox:node(p.add_entry('T<sub>junction</sub>', mw.html.create('td'):wikitext(arg('tjunc min') .. '&nbsp;–&nbsp;' .. arg('tjunc max'))))
 
end
 
end
 
 
 
-- tcase min
 
-- tcase min
if has_arg('tcase min') then
+
if has_arg('tcase min') or has_arg('tcase max') then
  infobox:node(p.add_entry('T<sub>case</sub>', mw.html.create('td'):wikitext('[[min case temperature::' .. arg('tcase min') .. ']]&nbsp;–&nbsp;' ..
+
if has_arg('tcase min') then p.set_val('min case temperature', arg('tcase min')) end
  '[[max case temperature::' .. arg('tcase max') .. ']]')))
+
if has_arg('tcase max') then p.set_val('max case temperature', arg('tcase max')) end
 +
  infobox:node(p.add_entry('T<sub>case</sub>', mw.html.create('td'):wikitext(arg('tcase min') .. '&nbsp;–&nbsp;' .. arg('tcase max'))))
 
end
 
end
 
 
 
-- tstorage min
 
-- tstorage min
if has_arg('tstorage min') then
+
if has_arg('tstorage min') or has_arg('tstorage max') then
  infobox:node(p.add_entry('T<sub>storage</sub>', mw.html.create('td'):wikitext('[[min storage temperature::' .. arg('tstorage min') .. ']]&nbsp;–&nbsp;' ..
+
if has_arg('tstorage min') then p.set_val('min storage temperature', arg('tstorage min')) end
  '[[max storage temperature::' .. arg('tstorage max') .. ']]')))
+
if has_arg('tstorage max') then p.set_val('max storage temperature', arg('tstorage max')) end
 +
  infobox:node(p.add_entry('T<sub>storage</sub>', mw.html.create('td'):wikitext(arg('tstorage min') .. '&nbsp;–&nbsp;' .. arg('tstorage max'))))
 
end
 
end
 
 
 
-- tambient min
 
-- tambient min
if has_arg('tambient min') then
+
if has_arg('tambient min') or has_arg('tambient max') then
  infobox:node(p.add_entry('T<sub>ambient</sub>', mw.html.create('td'):wikitext('[[min ambient temperature::' .. arg('tambient min') .. ']]&nbsp;–&nbsp;' ..
+
if arg('tambient min') then p.set_val('min ambient temperature', arg('tambient min')) end
  '[[max ambient temperature::' .. arg('tambient max') .. ']]')))
+
if arg('tambient max') then p.set_val('max ambient temperature', arg('tambient max')) end
 +
infobox:node(p.add_entry('T<sub>ambient</sub>', mw.html.create('td'):wikitext(arg('tambient min') .. '&nbsp;–&nbsp;' .. arg('tambient max'))))
 +
end
 +
 +
-- dts min/max
 +
if has_arg('dts min') or has_arg('dts max') then
 +
if has_arg('dts min') then p.set_val('min dts temperature', arg('dts min')) end
 +
if has_arg('dts max') then p.set_val('max dts temperature', arg('dts max')) end
 +
infobox:node(p.add_entry('T<sub>DTS</sub>', mw.html.create('td'):wikitext(arg('dts min') .. '&nbsp;–&nbsp;' .. arg('dts max'))))
 
end
 
end
 
 
Line 563: Line 954:
  
 
     -- ####################################################################
 
     -- ####################################################################
 +
    -- Packaging
 +
    local has_arg_pkg_name = has_arg('package name') or has_arg('package name 1')
 +
    if has_arg('package module 1') or has_arg_pkg_name or has_arg('back image') then
 +
        p.add_separator(infobox, 'Packaging')
 +
    end
 +
 +
    -- Packaging
 +
    if has_arg_pkg_name then
 +
        local pdata = require('Module:packaging data')
 +
        -- Also accept name, name 2, name 3 for consistency.
 +
        local add_space = append_packaging_data(infobox, 'package name', pdata, false)
 +
        for i = 1, 10 do
 +
            add_space = append_packaging_data(infobox, 'package name ' .. i, pdata, add_space)
 +
        end
 +
    end
 +
 
     -- Packaging
 
     -- Packaging
 
     if has_arg('package module 1') then
 
     if has_arg('package module 1') then
    p.add_separator(infobox, 'Packaging')
 
 
for i = 1, 10 do
 
for i = 1, 10 do
 
    if has_arg('package module ' .. i) then
 
    if has_arg('package module ' .. i) then
 
infobox
 
infobox
:tag('tr'):tag('td'):attr('colspan', '2')
+
:tag('tr'):tag('td'):attr('colspan', '2'):attr('style', 'padding: 5px;')
 
:wikitext(frame:preprocess(arg('package module ' .. i)))
 
:wikitext(frame:preprocess(arg('package module ' .. i)))
 
end
 
end
 
end
 
end
 
end
 
end
 +
 +
    -- back_image
 +
if has_arg('back image') then
 +
local back_image = p.add_file_prefix(arg('back image'))
 +
local back_image_size = has_arg('back image size') and arg('back image size') or "200px"
 +
infobox
 +
:tag('tr')
 +
  :tag('td')
 +
    :attr('style', 'text-align: center;')
 +
    :attr('colspan', '2')
 +
    -- make sure it's the ogimage
 +
    :wikitext('[[' .. back_image .. '|link=|' .. back_image_size .. ']]')
 +
 +
p.set_val('back image', back_image)
 +
end
 +
 +
 +
    -- ####################################################################
 +
    -- ####################################################################
 +
    -- Successon
 +
if has_arg('successor') or has_arg('predecessor') then
 +
        p.add_separator(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
 +
        p.add_separator(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
 +
 +
 +
  
  
Line 580: Line 1,091:
 
end
 
end
 
 
    infobox:wikitext('[[Category:all microprocessor models]]')
+
p.set_val('full page name', frame:preprocess('{{FULLPAGENAME}}'))
    infobox:wikitext('[[full page name::' .. frame:preprocess('{{FULLPAGENAME}}') .. '| ]]')
 
 
      
 
      
 
     if has_arg('future') and
 
     if has_arg('future') and
 
     (string.lower(arg('future')) == 'yes' or string.lower(arg('future')) == 'true') then
 
     (string.lower(arg('future')) == 'yes' or string.lower(arg('future')) == 'true') then
     infobox:wikitext('[[Category:future microprocessor models]][[ldate::3000| ]]')
+
p.set_val('ldate', '3000')
 +
     infobox:wikitext('[[Category:future ' .. chip_type .. ' models]]')
 
elseif has_arg('first launched') then
 
elseif has_arg('first launched') then
    infobox:wikitext('[[ldate::' .. arg('first launched') .. '| ]]')
+
p.set_val('ldate', arg('first launched'))
 +
elseif has_arg('first announced') then
 +
p.set_val('ldate', arg('first announced'))
 +
else --alright launched but no date?
 +
p.set_val('ldate', '1900')
 
     end
 
     end
 
 

Latest revision as of 23:47, 1 April 2023

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)
	if has_arg(name) then
		return origArgs[name]
	end
	return ''
end

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

local function append_packaging_data(infobox, arg_name, pdata, add_space)
    local package_name = origArgs[arg_name]
    if not package_name or package_name == '' then return add_space end

    local need_space = add_space
    local function may_add_space()
        need_space = true
        if add_space then
            infobox:tag('tr'):tag('td'):attr('colspan', '2'):tag('hr')
            add_space = false
        end
    end

    local function show_error(text)
        infobox:wikitext('[[Category:Articles with invalid parameter in template]]')
        may_add_space()
        local e = mw.html.create('tr')
        e:tag('td')
            :attr('colspan', '2')
            :attr('style', 'color: #c00;')
            :wikitext(text)
        infobox:node(e)
    end

    -- Reject unexpected input, esp. smw.ask operators []:|?*~
    if mw.ustring.find(package_name, '[^%w %-+._,/]') then
        show_error('Invalid package name')
        return need_space
    end

    local package_location, info, result = {}
    local page_name = package_name
    for field in string.gmatch(package_name, "([^,]+),?") do
        table.insert(package_location, field)
    end
    if #package_location > 1 then
        page_name = package_location[1] .. '/packages/' .. package_location[2]
        if pdata['packages'][package_location[1]] then
            info = pdata['packages'][package_location[1]][package_location[2]]
        end
    end
    if mw.smw then
        result = mw.smw.ask('[[Category:all ic packages]][[' .. page_name .. ']]' ..
            '|?package|?package type|?package contacts#-|?package pitch#-' ..
            '|?package length#-|?package width#-|?package height#-|?socket')
    end
    local dim_props = {'package length', 'package width', 'package height'}
    if type(result) == 'table' and #result >= 1 and result[1]['package'] then
        info = result[1]
    else
        if not info then
            show_error('Unknown package "' .. package_name .. '"')
            return need_space
        end
        page_name = nil
        for i, name in ipairs(dim_props)
            do info[name] = info.p_size and info.p_size[i] or nil end
    end

    local function tabled(x) return type(x) == 'table' and x or { x } end
    local function show(label, text)
        if not text or text == '' then return end
        may_add_space()
        infobox:node(p.add_entry(label, mw.html.create('td'):wikitext(text)))
    end
    local function param(a)
        local prop_names = unpack(a)
        local text, sep = '', ''
        for i, prop_name in ipairs(tabled(prop_names)) do
            local values = info[prop_name] -- single value or table
            if values then
                local n_values = 0
                for j, value in ipairs(tabled(values)) do
                    if value and value ~= '' then
                        if a.set_prop then p.set_val(a.set_prop, value) end
                        text = text .. sep .. value
                        sep = a.sep or ', '
                        n_values = n_values + 1
                        if n_values >= (a.max_values or 1) then break end
                    end
                end
            end
        end
        return text
    end
    local p_type_text, p_type_abbr = param{{'package type', 'p_type'}}, ''
    if p_type_text ~= '' and mw.ustring.len(p_type_text) <= 10 then
        p_type_abbr = ' (' .. p_type_text .. ')'
        p_type_text = ''
    end
    local p_name = param{{'package', 'p_name'}, set_prop='package', max_values=10}
    if p_name ~= '' then
        if page_name then p_name = '[[' .. page_name .. '|' .. p_name .. ']]' end
        show('Package', p_name .. p_type_abbr)
    end
    show('Package Type', p_type_text)
    show('Dimension', param{dim_props, sep=' × '})
    show('Pitch', param{{'package pitch', 'p_pitch'}, max_values=2, sep=' × '})
    show('Contacts', param{{'package contacts', 'p_contacts'}})
    show('Socket', param{{'socket', 'p_socket'}, set_prop='socket', max_values=10})
    return need_space
end

function p.chip(frame)
	
	p.frame = frame
    if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame.args
    end
    
    
    local infobox = mw.html.create('table')
    
    -- by default it's a microprocessor
    local chip_type = 'microprocessor'
    if has_arg('chip type') then
		chip_type = arg('chip type')
	end
	
	-- define it as an instance of that chip
	p.set_val('instance of', chip_type)
	
	-- same for category
    infobox:wikitext('[[Category:all ' .. chip_type .. ' models]]')
	

    infobox
        :attr('class', 'infobox')
        
    infobox
    	:tag('tr')
			:tag('td'):attr('colspan', '2')
			:tag('small'):attr('style', 'float: left; font-weight: bold;')
            :wikitext('[[Special:FormEdit/chip/' .. frame:preprocess('{{FULLPAGENAME}}') .. '|<i class="fa fa-edit"></i>Edit Values]]')

    -- header
    if has_arg('name') then
		infobox
			:tag('tr')
			:tag('td')
			:attr('class', 'header-main')
			:attr('colspan', '2')
			:wikitext(arg('name'))
		p.set_val('name', arg('name'))
    end

    -- image
	if 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')
		    -- make sure it's the ogimage
		    :wikitext('[[' .. image .. '|link=|class=wikichip_ogimage|' .. image_size .. ']]')
		
		p.set_val('main image', image)

      -- add a caption, if provided
      if has_arg('caption') then
		infobox
			:tag('tr')
			:tag('td')
			:attr('style', 'text-align: center;')
			:attr('colspan', '2')
			:wikitext(arg('caption'))
		p.set_val('main image caption', arg('caption'))
      end
	elseif not 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]]')
    end
    
    

    -- image
	if has_arg('image 2') then
		local image = p.add_file_prefix(arg('image 2'))
		local image_size = has_arg('image 2 size') and arg('image 2 size') or "200px" 
		infobox
		:tag('tr')
		  :tag('td')
		    :attr('style', 'text-align: center;')
		    :attr('colspan', '2')
		    -- make sure it's the ogimage
		    :wikitext('[[' .. image .. '|link=|' .. image_size .. ']]')
	end

    -- ####################################################################
    -- some general info first
    p.add_separator(infobox, 'General Info')
    
    -- designer
    if has_arg('designer') then
      	local designers = mw.html.create('td'):attr('style', 'width: 99%;')
      	p.set_val('designer', arg('designer'))
      	designers:wikitext('[[' .. arg('designer') .. ']]' ..
      				'[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer')) .. ']]')
		if has_arg('microarch') then
			designers:wikitext('[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer')) ..
					' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
		end
		
		for i = 2, 10 do
			if has_arg('microarch ' .. i) then
			designers:wikitext('[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer')) ..
			  		' based on ' .. mw.ustring.lower(arg('microarch ' .. i)) .. ']]')
			end
		end
      
      for i = 2, 10 do
      	if not has_arg('designer ' .. i) then break end
      		p.set_val('designer', arg('designer ' .. i))
      		designers:wikitext(',<br>[[' .. arg('designer ' .. i) .. ']]' ..
      				'[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer ' .. i)) .. ']]')
      			
		if has_arg('microarch') then
			designers:wikitext('[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer ' .. i)) ..
					' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
		end
		
		for j = 2, 10 do
			if has_arg('microarch ' .. j) then
			designers:wikitext('[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('designer ' .. i)) ..
			  		' based on ' .. mw.ustring.lower(arg('microarch ' .. j)) .. ']]')
			end
		end
      end
   	  infobox:node(p.add_entry('Designer', designers))
	end
    
    -- manufacturer
    if has_arg('manufacturer') then
      local manufacturers = '[[' .. arg('manufacturer') .. ']]' ..
      		'[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('manufacturer')) .. ']]'
  		p.set_val('manufacturer', arg('manufacturer'))
      		
      for i = 2, 10 do
      	if not has_arg('manufacturer ' .. i) then break end
      	manufacturers = manufacturers .. ', [[' .. arg('manufacturer ' .. i) .. ']]' ..
      		'[[category:' .. chip_type .. ' models by ' .. mw.ustring.lower(arg('manufacturer ' .. i)) .. ']]'
  		p.set_val('manufacturer', 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
		p.set_val('model number', arg('model number'))
	  	infobox:node(p.add_entry('Model Number', mw.html.create('td'):attr('style', 'width: 99%;'):wikitext(arg('model number'))))
	end
    
    -- part number
    if has_arg('part number') then
		p.set_val('part number', arg('part number'))
		local parts = arg('part number')
		for i = 2, 10 do
			if not has_arg('part number ' .. i) then break end
			p.set_val('part number', arg('part number ' .. i))
			parts = parts .. ',<br> ' .. 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
      	p.set_val('s-spec', arg('s-spec'))
        sspec = arg('s-spec')
        for i = 2, 30 do
        	if not has_arg('s-spec ' .. i) then break end
      		p.set_val('s-spec', arg('s-spec ' .. i))
        	sspec = sspec .. ', ' .. arg('s-spec ' .. i)
        end
      end
      if has_arg('s-spec qs') then
      	if has_arg('s-spec') then sspec = sspec .. '<br>' end
      	p.set_val('s-spec (qs)', arg('s-spec qs'))
        sspec = sspec .. arg('s-spec qs') .. ' ([[qualification sample|QS]])'
        for i = 2, 30 do
        	if not has_arg('s-spec qs ' .. i) then break end
      		p.set_val('s-spec (qs)', arg('s-spec qs ' .. i))
        	sspec = sspec .. ', ' .. arg('s-spec qs ' .. i) .. ' ([[qualification sample|QS]])'
        end
      end
   	  infobox:node(p.add_entry('S-Spec', mw.html.create('td'):wikitext(sspec)))
	end
	
	-- market segment
    if has_arg('market') then
		p.set_val('market segment', arg('market'))
      	local markets = mw.html.create('td'):wikitext(arg('market'))
      	for i = 2, 5 do
  			if not has_arg('market ' .. i) then break end
			p.set_val('market segment', arg('market ' .. i))
      		markets:wikitext(', ' .. 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
	  	p.set_val('first announced', arg('first announced'))
	    release:wikitext(arg('first announced') .. ' (announced)')
	  end
	  if has_arg('first launched') then
	  	if has_arg('first announced') then
	  	  release:wikitext('<br>')	
  		end
  		p.set_val('first launched', arg('first launched'))
	    release:wikitext(arg('first launched') .. ' (launched)')
	  end
	  infobox:node(p.add_entry('Introduction', 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
	  	p.set_val('last order', arg('last order'))
	    release:wikitext(arg('last order') .. ' (last order)')
	  end
	  if has_arg('last shipment') then
	  	if has_arg('last order') then
	  	  release:wikitext('<br>')	
  		end
  		p.set_val('last shipment', arg('last shipment'))
	    release:wikitext(arg('last shipment') .. ' (last shipment)')
	  end
	  infobox:node(p.add_entry('End-of-life', release))
	end
	
	-- release price
	if has_arg('release price') or has_arg('release price (box)') or has_arg('release price (tray)') then
		local release_price = ''
		
		if has_arg('release price') then
			release_price = arg('release price')
			p.set_val('release price', arg('release price'))
		end
		if has_arg('release price (tray)') then
			if release_price ~= "" then release_price = release_price .. '<br>' end
			release_price = release_price .. arg('release price (tray)') .. ' (tray)'
			p.set_val('release price (tray)', arg('release price (tray)'))
			p.set_val('release price', arg('release price (tray)')) --add it there as well
		end
		if has_arg('release price (box)') then
			if release_price ~= "" then release_price = release_price .. '<br>' end
			release_price = release_price .. arg('release price (box)') .. ' (box)'
			p.set_val('release price (box)', arg('release price (box)'))
			p.set_val('release price', arg('release price (box)')) --add it there as well
		end
		
		infobox:node(p.add_entry('Release Price', mw.html.create('td'):wikitext(release_price)))
	end
	
	-- Shop links
	if has_arg('designer') and has_arg('name') then
		if string.len(string.match(string.lower(arg('designer')), '^intel') or '') > 0
			or string.len(string.match(string.lower(arg('designer')), '^amd') or '') > 0 then
			
			local name = string.gsub(arg('designer') .. ' ' .. arg('name'), " ", "%%20")
			local link = '[https://www.amazon.com/gp/search?ie=UTF8&tag=wikichip-20&linkCode=ur2&linkId=aed902a15f809f6661ea2887020a7a0e&camp=1789&creative=9325&index=electronics&keywords=' .. name .. ' Amazon]'
			infobox:node(p.add_entry('Shop', mw.html.create('td'):wikitext(link)))
		end
	end
	
	
	

    -- ####################################################################
    -- Generla Specs 
    
    -- early checks
    local hasTurbo = false
    for i = 1, 42 do
    	if has_arg('turbo frequency' .. i) then hasTurbo = true break end
	end
	
	
    -- some general specs
	if has_arg('family') or has_arg('series') or has_arg('locked') or 
		has_arg('frequency') or hasTurbo or has_arg('turbo frequency') or 
		has_arg('bus type') or has_arg('bus speed') or has_arg('bus rate') or
		has_arg('clock multiplier') or has_arg('cpuid') then
    	p.add_separator(infobox, 'General Specs')
    end
	
	-- family
	if has_arg('family') then
		local families = mw.html.create('td')
		
		p.set_val('family', arg('family'))
		families:wikitext(
	  				'[[' .. mw.ustring.lower(arg('designer') .. '/' .. arg('family')) .. '|' .. arg('family') .. ']]')

		for i = 2, 10 do
			if not has_arg('family ' .. i) then break end
			p.set_val('family', arg('family ' .. i))
		
			families:wikitext(
  				', [[' .. mw.ustring.lower(arg('designer') .. '/' .. arg('family ' .. i)) .. '|' .. arg('family ' .. i) .. ']]')
		end
		
		
		infobox:node(p.add_entry('Family', families))
	end
	
	-- series
	if has_arg('series') then
		p.set_val('series', arg('series'))
	  	infobox:node(p.add_entry('Series', mw.html.create('td'):wikitext(arg('series'))))
	end
	
	-- locked?
	if has_arg('locked') then
		p.set_val('has locked clock multiplier', arg('locked'))
		infobox:node(p.add_entry('Locked', mw.html.create('td'):wikitext(arg('locked'))))
	end
    
    -- frequency
    if has_arg('frequency') then
		p.set_val('base frequency', arg('frequency'))
		local frequencies = mw.html.create('td'):wikitext( arg('frequency'))
		for i = 2, 10 do
			if not has_arg('frequency ' .. i) then break end
			p.set_val('base frequency', arg('frequency ' .. i))
			frequencies:wikitext(', ' .. arg('frequency ' .. i))
		end
		infobox:node(p.add_entry('Frequency', frequencies))
	end
    
    -- lone turbo
    if has_arg('turbo frequency') then
		local turbo = mw.html.create('td')
		p.set_val('turbo frequency', arg('turbo frequency'))
		turbo:wikitext(arg('turbo frequency'))
		infobox:node(p.add_entry('Turbo Frequency', turbo))
	end
	
    -- turbo frequency
    if hasTurbo then
      local turbo = mw.html.create('td')
      local sep = ''
      for i = 1, 42 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 ''
        	p.set_val('turbo frequency (' .. i .. ' core' .. s .. ')', arg('turbo frequency' .. i))
			turbo:wikitext(sep .. arg('turbo frequency' .. i) .. ' (' .. i .. ' core' .. s .. ')')
        	sep = ',<br>'
      	end
      end
   	  infobox:node(p.add_entry('Turbo Frequency', turbo))
	end
	
	-- bus type
	if has_arg('bus type') then
		p.set_val('bus type', arg('bus type'))
		infobox:node(p.add_entry('Bus type', mw.html.create('td'):wikitext(arg('bus type'))))
	end
	
	-- bus speed
	if has_arg('bus speed') then
		p.set_val('bus speed', arg('bus speed'))
		infobox:node(p.add_entry('Bus speed', mw.html.create('td'):wikitext(arg('bus speed'))))
	end
	
	-- bus rate
	if has_arg('bus rate') then
		local links = ''
		if has_arg('bus links') then
			p.set_val('bus links', arg('bus links'))
			links = arg('bus links') .. '&nbsp;×&nbsp;'
		end
		p.set_val('bus rate', arg('bus rate'))
		infobox:node(p.add_entry('Bus rate', mw.html.create('td'):wikitext(links .. arg('bus rate'))))
	end
	
	-- clock mult
	if has_arg('clock multiplier') then
		p.set_val('clock multiplier', arg('clock multiplier'))
		infobox:node(p.add_entry('Clock multiplier', mw.html.create('td'):wikitext(arg('clock multiplier'))))
	end
	
	-- CPUID
    if has_arg('cpuid') then
		p.set_val('cpuid', arg('cpuid'))
		local cpuid = mw.html.create('td'):wikitext(arg('cpuid'))
		for i = 2, 10 do
			if not has_arg('cpuid ' .. i) then break end
			p.set_val('cpuid', arg('cpuid ' .. i))
			cpuid:wikitext(', ' .. arg('cpuid ' .. i))
		end
   	  infobox:node(p.add_entry('CPUID', cpuid))
	end
	
	
    -- ####################################################################
    -- Neuromorphic Chip 
    
    -- some general specs
	if has_arg('neuron count') or has_arg('synapse count') then
    	p.add_separator(infobox, 'Neuromorphic Specs')
    end
    
	-- neurons count
	if has_arg('neuron count') then
		p.set_val('neuron count', arg('neuron count'))
	  infobox:node(p.add_entry('Neurons', mw.html.create('td'):wikitext(arg('neuron count'))))
	end

	-- synapse count
	if has_arg('synapse count') then
		p.set_val('synapse count', arg('synapse count'))
	  infobox:node(p.add_entry('Synapses', mw.html.create('td'):wikitext(arg('synapse count'))))
	end

    -- ####################################################################
    -- some general info first
    p.add_separator(infobox, 'Microarchitecture')
	
	-- ISA
    if has_arg('isa') or has_arg('isa family') then
  		p.set_val('isa', arg('isa'))
      	local isa = mw.html.create('td'):wikitext(arg('isa'))
		if has_arg('isa family') then
			p.set_val('isa family', arg('isa family'))
			isa:wikitext('&nbsp;(' .. arg('isa family') .. ')')
		end
      	for i = 2, 10 do
      		if not has_arg('isa ' .. i) then break end
      		p.set_val('isa', arg('isa ' .. i))
      		isa:wikitext(', ' .. arg('isa ' .. i))
			if has_arg('isa ' .. i .. ' family') then
				p.set_val('isa family', arg('isa ' .. i .. ' family'))
				isa:wikitext('&nbsp;(' .. arg('isa ' .. i .. ' family') .. ')')
			end
      	end
   	  infobox:node(p.add_entry('ISA', isa))
	end
	
	-- microarch
    if has_arg('microarch') then
      local microarchs = mw.html.create('td')
      p.set_val('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
      	p.set_val('microarchitecture', arg('microarch ' .. i))
        microarchs:wikitext(', [[' .. mw.ustring.lower(arg('designer')) .. '/microarchitectures/' ..
      		mw.ustring.lower(arg('microarch ' .. i)) .. '|' .. arg('microarch ' .. i) .. ']]')
      end
   	  infobox:node(p.add_entry('Microarchitecture', microarchs))
	end
	
	-- platform
	if has_arg('platform') then
		p.set_val('platform', arg('platform'))
		infobox:node(p.add_entry('Platform', mw.html.create('td'):wikitext(arg('platform'))))
	end
	
	-- chipset
    if has_arg('chipset') then
		p.set_val('chipset', arg('chipset'))
		local chipset = mw.html.create('td'):wikitext(arg('chipset'))
		for i = 2, 10 do
			if not has_arg('chipset ' .. i) then break end
			p.set_val('chipset', arg('chipset ' .. i))
			chipset:wikitext(', ' .. arg('chipset ' .. i))
      	end
		infobox:node(p.add_entry('Chipset', chipset))
	end
	
	-- core name
    if has_arg('core name') then
		p.set_val('core name', arg('core name'))
      	local core_name = mw.html.create('td'):wikitext(
      				'[[' .. 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
      	p.set_val('core name', arg('core name ' .. i))
      	core_name:wikitext(', ' ..
      				'[[' .. 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
    	p.set_val('core family', arg('core family'))
      	local corefam = mw.html.create('td'):wikitext(arg('core family'))
      for i = 2, 10 do
      	if not has_arg('core family ' .. i) then break end
      	p.set_val('core family', arg('core family ' .. i))
      	corefam:wikitext(', ' .. arg('core family ' .. i))
      end
   	  infobox:node(p.add_entry('Core Family', corefam))
	end
	
	-- core model
    if has_arg('core model') then
    	p.set_val('core model', arg('core model'))
		local coremodel = mw.html.create('td'):wikitext(arg('core model'))
		for i = 2, 10 do
			if not has_arg('core model ' .. i) then break end
    		p.set_val('core model', arg('core model ' .. i))
			coremodel:wikitext(', ' .. arg('core model ' .. i))
		end
		 infobox:node(p.add_entry('Core Model', coremodel))
	end
	
	-- core stepping
    if has_arg('core stepping') then
    	p.set_val('core stepping', arg('core stepping'))
		local corestep = mw.html.create('td'):wikitext(arg('core stepping'))
		for i = 2, 10 do
			if not has_arg('core stepping ' .. i) then break end
    		p.set_val('core stepping', arg('core stepping ' .. i))
			corestep:wikitext(', ' .. arg('core stepping ' .. i))
		end
		infobox:node(p.add_entry('Core Stepping', corestep))
	end
	
	-- process
    if has_arg('process') then
		p.set_val('process', arg('process'))
      	local process = mw.html.create('td'):wikitext('[[' .. arg('process') .. ' process|' .. arg('process') .. ']]')
      	for i = 2, 10 do
      		if not has_arg('process ' .. i) then break end
			p.set_val('process', arg('process ' .. i))
      		process:wikitext(', ' .. '[[' .. arg('process ' .. i) .. ' process|' .. arg('process ' .. i) .. ']]')
      	end
   	  	infobox:node(p.add_entry('Process', process))
	end
	
	-- Transistors
	if has_arg('transistors') then
		p.set_val('transistor count', arg('transistors'))
	  	infobox:node(p.add_entry('Transistors', mw.html.create('td'):wikitext(arg('transistors'))))
	end
	
	-- Technology
	if has_arg('technology') then
		p.set_val('technology', arg('technology'))
	  	infobox:node(p.add_entry('Technology', mw.html.create('td'):wikitext(arg('technology'))))
	end
	
	-- die size
	if has_arg('die area') or has_arg('die size') then
		local die
		if has_arg('die size') then
			p.set_val('die area', arg('die size'))
      		die = mw.html.create('td'):wikitext(arg('die size'))
		else
			p.set_val('die area', arg('die area'))
			die = mw.html.create('td'):wikitext(arg('die area'))
		end
		if has_arg('die length') and has_arg('die width') then
			p.set_val('die length', arg('die length'))
			p.set_val('die width', arg('die width'))
			die:wikitext('<br>' .. arg('die length') .. ' × ' .. arg('die width'))	
		end
	  	infobox:node(p.add_entry('Die', die))
	end
	
	if has_arg('mcp') then
		p.set_val('is multi-chip package', arg('mcp'))
  		mcp = mw.html.create('td'):wikitext(arg('mcp'))
		if has_arg('die count') then
			p.set_val('die count', arg('die count'))
      		mcp:wikitext(' (' .. arg('die count') .. ' dies)')
		end
	  	infobox:node(p.add_entry('MCP', mcp))
	end
	
	-- word size
	if has_arg('word size') then
		p.set_val('word size', arg('word size'))
		infobox:node(p.add_entry('Word Size', mw.html.create('td'):wikitext(arg('word size'))))
	end
	
	-- core count
	if has_arg('core count') then
		p.set_val('core count', arg('core count'))
	  infobox:node(p.add_entry('Cores', mw.html.create('td'):wikitext(arg('core count'))))
	end
	
	-- thread count
	if has_arg('thread count') then
		p.set_val('thread count', arg('thread count'))
	  infobox:node(p.add_entry('Threads', mw.html.create('td'):wikitext(arg('thread count'))))
	end
	
	-- max memory
	if has_arg('max memory') then
		p.set_val('max memory', arg('max memory'))
		infobox:node(p.add_entry('Max Memory', mw.html.create('td'):wikitext(arg('max memory'))))
	end
	
	-- max memory addr
	if has_arg('max memory addr') then
		p.set_val('max memory address', arg('max memory addr'))
	  infobox:node(p.add_entry('Max Address Mem', mw.html.create('td'):wikitext(arg('max memory addr'))))
	end
	
	
    -- ####################################################################
    -- Multiprocessing
    if has_arg('max cpus') or has_arg('smp interconnect')
    	 or has_arg('smp interconnect links') 
    	 or has_arg('smp interconnect rate') then
		p.add_separator(infobox, 'Multiprocessing')
	end
	
	-- max cpus
	if has_arg('max cpus') then
		local type = tonumber(arg('max cpus')) == 1 and ' (Uniprocessor)' or ' (Multiprocessor)'
		p.set_val('max cpu count', arg('max cpus'))
		p.set_val('smp max ways', arg('max cpus'))
		infobox:node(p.add_entry('Max SMP', mw.html.create('td'):wikitext(arg('max cpus') .. '-Way' .. type)))
	end
	
	-- smp interconnect
	if has_arg('smp interconnect') then
		p.set_val('smp interconnect', arg('smp interconnect'))
		infobox:node(p.add_entry('Interconnect', mw.html.create('td'):wikitext(arg('smp interconnect'))))
	end
	
	-- smp interconnect links
	if has_arg('smp interconnect links') then
		p.set_val('smp interconnect links', arg('smp interconnect links'))
		infobox:node(p.add_entry('Interconnect Links', mw.html.create('td'):wikitext(arg('smp interconnect links'))))
	end
	
	-- smp interconnect rate
	if has_arg('smp interconnect rate') then
		p.set_val('smp interconnect rate', arg('smp interconnect rate'))
		infobox:node(p.add_entry('Interconnect Rate', mw.html.create('td'):wikitext(arg('smp interconnect rate'))))
	end

    -- ####################################################################
    -- Electrical
    if has_arg('power') or has_arg('average power') or has_arg('idle power')
    	or has_arg('v core') or has_arg('v io') or has_arg('sdp') or has_arg('tdp')
    	or has_arg('tdp typical') or has_arg('ctdp down') or has_arg('ctdp down frequency')
		or has_arg('ctdp up') or has_arg('ctdp up frequency')
		or has_arg('temp min') or has_arg('tjunc min')
		or has_arg('tcase min') or has_arg('tstorage min') or has_arg('tambient min') then
		p.add_separator(infobox, 'Electrical')
    end
	
	-- power
	if has_arg('power') then
		p.set_val('power dissipation', arg('power'))
	  infobox:node(p.add_entry('Power dissipation', mw.html.create('td'):wikitext(arg('power'))))
	end
	
	-- average power
	if has_arg('average power') then
		p.set_val('power dissipation (average)', arg('average power'))
	  infobox:node(p.add_entry('Power dissipation (average)', mw.html.create('td'):wikitext(arg('average power'))))
	end
	
	-- power
	if has_arg('idle power') then
		p.set_val('power dissipation (idle)', arg('idle power'))
		infobox:node(p.add_entry('Power (idle)', mw.html.create('td'):wikitext(arg('idle power'))))
	end
	
	-- vcore
	if has_arg('v core') then
		p.set_val('core voltage', arg('v core'))
		local vcore =  mw.html.create('td'):wikitext(arg('v core'))
		if has_arg('v core tolerance') then
			p.set_val('core voltage tolerance', arg('v core tolerance'))
			vcore:wikitext(' ± ' .. arg('v core tolerance'))	
		end
		infobox:node(p.add_entry('V<sub>core</sub>', vcore))
	end
	if has_arg('v core min') then
		p.set_val('core voltage (min)', arg('v core min'))
		p.set_val('core voltage (max)', arg('v core max'))
		infobox:node(p.add_entry('V<sub>core</sub>', mw.html.create('td'):wikitext(arg('v core min') .. '-' .. arg('v core max'))))
	end

	-- io
	if has_arg('v io') then
		p.set_val('io voltage', arg('v io'))
		local vcore =  mw.html.create('td'):wikitext(arg('v io'))
		if has_arg('v io tolerance') then
			p.set_val('io voltage tolerance', arg('v io tolerance'))
			vcore:wikitext(' ± ' .. arg('v io tolerance'))
		end
		for i = 2, 10 do
	  		if not has_arg('v io ' .. i) then break end
			p.set_val('io voltage', arg('v io ' .. i))
	  		vcore:wikitext(', ' .. arg('v io ' .. i))
		end
		infobox:node(p.add_entry('V<sub>I/O</sub>', vcore))
	end
	
	-- sdp
	if has_arg('sdp') then
		p.set_val('sdp', arg('sdp'))
	  infobox:node(p.add_entry('<abbr title="Scenario Design Power">SDP</abbr>', mw.html.create('td'):wikitext(arg('sdp'))))
	end
	
	-- tdp
	if has_arg('tdp') then
		p.set_val('tdp', arg('tdp'))
		local tdp =  mw.html.create('td'):wikitext(arg('tdp'))
		for i = 2, 10 do
	  		if not has_arg('tdp ' .. i) then break end
			p.set_val('tdp', arg('tdp ' .. i))
	  		tdp:wikitext(', ' .. arg('tdp ' .. i))
		end
	  	infobox:node(p.add_entry('<abbr title="Thermal Design Power">TDP</abbr>', tdp))
	end
	
	-- tdp typical
	if has_arg('tdp typical') then
		p.set_val('tdp (typical)', arg('tdp typical'))
		infobox:node(p.add_entry('<abbr title="Thermal Design Power">TDP</abbr> (Typical)', mw.html.create('td'):wikitext(arg('tdp typical'))))
	end
	
	-- ctdp down
	if has_arg('ctdp down') then
		p.set_val('tdp down', arg('ctdp down'))
	  	infobox:node(p.add_entry('cTDP down', mw.html.create('td'):wikitext(arg('ctdp down'))))
	end
	
	-- ctdp down
	if has_arg('ctdp down frequency') then
		p.set_val('tdp down frequency', arg('ctdp down frequency'))
		infobox:node(p.add_entry('cTDP down frequency', mw.html.create('td'):wikitext(arg('ctdp down frequency'))))
	end
	
	-- ctdp up
	if has_arg('ctdp up') then
		p.set_val('tdp up', arg('ctdp up'))
	  	infobox:node(p.add_entry('cTDP up', mw.html.create('td'):wikitext(arg('ctdp up'))))
	end
	
	-- ctdp up
	if has_arg('ctdp up frequency') then
		p.set_val('tdp up frequency', arg('ctdp up frequency'))
	  	infobox:node(p.add_entry('cTDP up frequency', mw.html.create('td'):wikitext(arg('ctdp up frequency'))))
	end
	
	-- temp min
	if has_arg('temp min') or has_arg('temp max') then
		if has_arg('temp min') then p.set_val('min operating temperature', arg('temp min')) end
		if has_arg('temp max') then p.set_val('max operating temperature', arg('temp max')) end
	  	infobox:node(p.add_entry('OP Temperature', mw.html.create('td'):wikitext(arg('temp min') .. '&nbsp;–&nbsp;' .. arg('temp max'))))
	end
	
	-- tjunc min
	if has_arg('tjunc min') or has_arg('tjunc max') then
		if has_arg('tjunc min') then p.set_val('min junction temperature', arg('tjunc min')) end
		if has_arg('tjunc max') then p.set_val('max junction temperature', arg('tjunc max')) end
	  	infobox:node(p.add_entry('T<sub>junction</sub>', mw.html.create('td'):wikitext(arg('tjunc min') .. '&nbsp;–&nbsp;' .. arg('tjunc max'))))
	end
	
	-- tcase min
	if has_arg('tcase min') or has_arg('tcase max') then
		if has_arg('tcase min') then p.set_val('min case temperature', arg('tcase min')) end
		if has_arg('tcase max') then p.set_val('max case temperature', arg('tcase max')) end
	  	infobox:node(p.add_entry('T<sub>case</sub>', mw.html.create('td'):wikitext(arg('tcase min') .. '&nbsp;–&nbsp;' .. arg('tcase max'))))
	end
	
	-- tstorage min
	if has_arg('tstorage min') or has_arg('tstorage max') then
		if has_arg('tstorage min') then p.set_val('min storage temperature', arg('tstorage min')) end
		if has_arg('tstorage max') then p.set_val('max storage temperature', arg('tstorage max')) end
	  	infobox:node(p.add_entry('T<sub>storage</sub>', mw.html.create('td'):wikitext(arg('tstorage min') .. '&nbsp;–&nbsp;' .. arg('tstorage max'))))
	end
	
	-- tambient min
	if has_arg('tambient min') or has_arg('tambient max') then
		if arg('tambient min') then p.set_val('min ambient temperature', arg('tambient min')) end
		if arg('tambient max') then p.set_val('max ambient temperature', arg('tambient max')) end
		infobox:node(p.add_entry('T<sub>ambient</sub>', mw.html.create('td'):wikitext(arg('tambient min') .. '&nbsp;–&nbsp;' .. arg('tambient max'))))
	end
	
	-- dts min/max
	if has_arg('dts min') or has_arg('dts max') then
		if has_arg('dts min') then p.set_val('min dts temperature', arg('dts min')) end
		if has_arg('dts max') then p.set_val('max dts temperature', arg('dts max')) end
		infobox:node(p.add_entry('T<sub>DTS</sub>', mw.html.create('td'):wikitext(arg('dts min') .. '&nbsp;–&nbsp;' .. arg('dts max'))))
	end
	
	

    -- ####################################################################
    -- Packaging
    local has_arg_pkg_name = has_arg('package name') or has_arg('package name 1')
    if has_arg('package module 1') or has_arg_pkg_name or has_arg('back image') then
        p.add_separator(infobox, 'Packaging')
    end

    -- Packaging
    if has_arg_pkg_name then
        local pdata = require('Module:packaging data')
        -- Also accept name, name 2, name 3 for consistency.
        local add_space = append_packaging_data(infobox, 'package name', pdata, false)
        for i = 1, 10 do
            add_space = append_packaging_data(infobox, 'package name ' .. i, pdata, add_space)
        end
    end

    -- Packaging
    if has_arg('package module 1') then
		for i = 1, 10 do
		    if has_arg('package module ' .. i) then
				infobox
					:tag('tr'):tag('td'):attr('colspan', '2'):attr('style', 'padding: 5px;')
					:wikitext(frame:preprocess(arg('package module ' .. i)))
			end
		end
	end

    -- back_image
	if has_arg('back image') then
		local back_image = p.add_file_prefix(arg('back image'))
		local back_image_size = has_arg('back image size') and arg('back image size') or "200px" 
		infobox
		:tag('tr')
		  :tag('td')
		    :attr('style', 'text-align: center;')
		    :attr('colspan', '2')
		    -- make sure it's the ogimage
		    :wikitext('[[' .. back_image .. '|link=|' .. back_image_size .. ']]')
		
		p.set_val('back image', back_image)
	end


    -- ####################################################################
    -- ####################################################################
    -- Successon
	if has_arg('successor') or has_arg('predecessor') then
        p.add_separator(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
        p.add_separator(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





	if has_arg('packaging') or has_arg('package 0') then
		infobox:wikitext('[[Category:Articles with invalid parameter in template]]')	
	end
	
	p.set_val('full page name', frame:preprocess('{{FULLPAGENAME}}'))
    
    if has_arg('future') and
    	(string.lower(arg('future')) == 'yes' or string.lower(arg('future')) == 'true') then
		p.set_val('ldate', '3000')
    	infobox:wikitext('[[Category:future ' .. chip_type .. ' models]]')
	elseif has_arg('first launched') then
		p.set_val('ldate', arg('first launched'))
	elseif has_arg('first announced') then
		p.set_val('ldate', arg('first announced'))
	else --alright launched but no date?
		p.set_val('ldate', '1900')
    end
	
    return infobox
end

return p