From WikiChip
Difference between revisions of "Module:chip"

Line 63: Line 63:
 
     -- 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
  
Line 86: Line 87:
 
       -- add a caption, if provided
 
       -- add a caption, if provided
 
       if has_arg('caption') then
 
       if has_arg('caption') then
        infobox
+
infobox
          :tag('tr')
+
:tag('tr')
            :tag('td')
+
:tag('td')
            :attr('style', 'text-align: center;')
+
:attr('style', 'text-align: center;')
              :attr('colspan', '2')
+
:attr('colspan', '2')
              :wikitext('[[main image caption::' .. arg('caption') .. ']]')
+
:wikitext(arg('caption'))
 +
p.set_val('main image caption', arg('caption'))
 
       end
 
       end
 
elseif not has_arg('no image') then
 
elseif not has_arg('no image') then
Line 148: Line 150:
 
-- 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'):attr('style', 'width: 99%;'):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 = 2, 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 .. ', ' .. arg('part number ' .. i)
 +
end
 +
infobox:node(p.add_entry('Part Number', mw.html.create('td'):wikitext(parts)))
 
end
 
end
 
      
 
      
Line 165: Line 170:
 
       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) .. ']] ([[qualification sample|QS]])'
+
      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 184: Line 193:
 
-- 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 196: Line 207:
 
  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 202: Line 214:
 
    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('Introduction', release))
 
  infobox:node(p.add_entry('Introduction', release))
Line 211: Line 224:
 
  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 217: Line 231:
 
    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 288: Line 303:
 
-- 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 300: Line 316:
 
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
 
end

Revision as of 00:44, 20 July 2017

To add this template, simple add
{{chip}}
to the page and save. The chip infobox will have a small [Edit Values] button at the top-right corner which can be used to add values using a form.
local p = {}
local origArgs

function p.add_file_prefix(str)
  if string.match(string.lower(str), '^file:') then
    return str
  else
    return 'File:' .. str
  end
end

function p.add_separator(box, title)
  box:tag('tr')
           :tag('td')
           :attr('class', 'header')
           :attr('colspan', '2')
           :wikitext(title)
end

function p.add_entry(value, right)
  local e = mw.html.create('tr')
  e:tag('td')
    :attr('class', 'label')
    :wikitext(value)
  e:node(right)
  return e   
end

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

function arg(name)
	return origArgs[name]
end

function p.set_val(prop, val)
	p.frame:preprocess('{{#set: ' .. prop .. '=' .. val .. '}}')	
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')

    infobox
        :attr('class', 'infobox')
        
    infobox
    	:tag('tr')
			:tag('td'):attr('colspan', '2')
			:tag('small'):attr('style', 'float: right;')
            :wikitext('[[Special:FormEdit/mpu/' .. 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')
		    :wikitext('[[' .. image .. '|' .. 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

    -- ####################################################################
    -- 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:microprocessor models by ' .. mw.ustring.lower(arg('designer')) .. ']]')
		if has_arg('microarch') then
			designers:wikitext('[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer')) ..
					' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
		end
      
      for i = 2, 10 do
      	if not has_arg('designer ' .. i) then break end
      		p.set_val('designer',arg('designer ' .. i))
      		designers:wikitext(', [[' .. arg('designer ' .. i) .. ']]' ..
      				'[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer ' .. i)) .. ']]')
  		if has_arg('microarch') then
			designers:wikitext('[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer ' .. i)) ..
  					' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
  		end
      end
   	  infobox:node(p.add_entry('Designer', designers))
	end
    
    -- manufacturer
    if has_arg('manufacturer') then
      local manufacturers = '[[' .. arg('manufacturer') .. ']]' ..
      		'[[category:microprocessor 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:microprocessor 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 .. ', ' .. 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') then
		infobox:node(p.add_entry('Release Price', mw.html.create('td'):wikitext(arg('release price'))))
		p.set_val('release price', arg('release price'))
	end
	
	
	

    -- ####################################################################
    -- some general specs
    p.add_separator(infobox, 'General Specs')
	
	-- family
	if has_arg('family') then
		p.set_val('microprocessor family', arg('family'))
		infobox:node(p.add_entry('Family', mw.html.create('td'):wikitext(
	  				'[[' .. mw.ustring.lower(arg('designer') .. '/' .. arg('family')) .. '|' .. arg('family') .. ']]')))
	end
	
	-- series
	if has_arg('series') then
		p.set_val('microprocessor 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
    
    -- turbo frequency
    local hasTurbo = false
    for i = 1, 42 do
    	if has_arg('turbo frequency' .. i) then hasTurbo = true break end
	end
    if hasTurbo then
      local turbo = mw.html.create('td')
      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 ''
        	local br = i > 1 and ',<br>' or ''
        	p.set_val('turbo frequency (' .. i .. ' core' .. s .. ')', arg('turbo frequency' .. i))
			turbo:wikitext(br .. arg('turbo frequency' .. i) .. ' (' .. i .. ' core' .. s .. ')')
      	end
      end
   	  infobox:node(p.add_entry('Turbo Frequency', turbo))
	end
	
	-- bus type
	if has_arg('bus type') then
		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

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

    -- ####################################################################
    -- Electrical
    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
	  infobox:node(p.add_entry('Power dissipation', mw.html.create('td'):wikitext('[[power dissipation::' .. arg('power') .. '| ]]' .. arg('power'))))
	end
	
	-- average power
	if has_arg('average power') then
	  infobox:node(p.add_entry('power dissipation (average)', mw.html.create('td'):wikitext('[[power dissipation (average)::' .. arg('average power') .. ']]')))
	end
	
	-- power
	if has_arg('idle power') then
	  infobox:node(p.add_entry('Power dissipation (idle)', mw.html.create('td'):wikitext('[[power dissipation (idle)::' .. arg('idle power') .. ']]')))
	end
	
	-- vcore
	if has_arg('v core') then
		local vcore =  mw.html.create('td'):wikitext('[[core voltage::' .. arg('v core') .. ']]')
		if has_arg('v core tolerance') then
			vcore:wikitext(' ± [[core voltage tolerance::' .. arg('v core tolerance') .. ']]')	
		end
		infobox:node(p.add_entry('V<sub>core</sub>', vcore))
	end
	if has_arg('v core min') then
		infobox:node(p.add_entry('V<sub>core</sub>', mw.html.create('td'):wikitext('[[core voltage (min)::' .. arg('v core min') .. ']]-' ..
			'[[core voltage (max)::' .. arg('v core max') .. ']]')))
	end

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

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


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

return p